Jump to content




Recent Status Updates

  • Photo
      16 Sep
    Kadence

    Some spammers sign up to CC and then they leave their account hidden so they think it won't get noticed but with an obvious name like "SaxophoneRetailSingapore" it's hard not to know they are a spam bot. #ModLife

    Show comments (3)
  • Photo
      15 Sep
    Error

    Programming is something that I enjoy and want to make a career out of. But, I usually tend to start things and not finish them. Any advice on how I can finish what I start?

    Show comments (1)
  • Photo
      12 Sep
    FacetiousTurtle33

    Just joined. Really enjoy this sight. Excited to become a great programmer, and helper.

    Show comments (3)
View All Updates

Developed by Kemal Taskin
Photo
- - - - -

Isit possible for me to call the JFrame from another class ?

jframe

  • Please log in to reply
3 replies to this topic

#1 xxxxjayxxx

xxxxjayxxx

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 123 posts

Posted 13 May 2011 - 08:18 AM

public class Jay {

public void Jay_Program() {

        Image image = Toolkit.getDefaultToolkit().getImage("\\logo.png");
        frame = new JFrame(");
        frame.setIconImage(image);
        frame.setSize(698, 500);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

How can I call this from from another class ? :confused:
  • 0

#2 chili5

chili5

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3,033 posts
  • Programming Language:Java, C#, PHP, JavaScript, Ruby, Transact-SQL
  • Learning:C, Java, C++, C#, PHP, JavaScript, Ruby, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 13 May 2011 - 01:49 PM

In your main function, you can create an instance of that class...

Jay j = new Jay();
j.Jay_Program();

The only thing you are missing in your Jay class is:
JFrame frame;

public class Jay { private JFrame frame; public void Jay_Program() {          Image image = Toolkit.getDefaultToolkit().getImage("\\logo.png");         frame = new JFrame(");         frame.setIconImage(image);         frame.setSize(698, 500);         frame.setLocationRelativeTo(null);         frame.setVisible(true);         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }

  • 0

#3 xxxxjayxxx

xxxxjayxxx

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 123 posts

Posted 13 May 2011 - 08:30 PM

which mean that if I use
Jay j = new Jay();
j.Jay_Program();
I can edit the JFrame from the new class ?
  • 0

#4 chili5

chili5

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3,033 posts
  • Programming Language:Java, C#, PHP, JavaScript, Ruby, Transact-SQL
  • Learning:C, Java, C++, C#, PHP, JavaScript, Ruby, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 16 May 2011 - 03:37 AM

What do you mean by "edit the JFrame"?
  • 0