Jump to content





Recent Status Updates

  • Photo
      16 Apr
    Kadence

    If you're reading this, you're on my profile and I know you're on my profile because I'm probably viewing yours.

    Show comments (6)
  • Photo
      10 Apr
    Poe

    Finally (and hopefully) i'm getting a team together that knows a little of this and a little of that; and maybe all my open source projects that are half written can begin to be released. :)

View All Updates
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,031 posts
  • Programming Language:Java, C#, PHP, JavaScript, Transact-SQL
  • Learning:C, Java, C++, C#, PHP, JavaScript, Transact-SQL, Assembly, Scheme

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,031 posts
  • Programming Language:Java, C#, PHP, JavaScript, Transact-SQL
  • Learning:C, Java, C++, C#, PHP, JavaScript, Transact-SQL, Assembly, Scheme

Posted 16 May 2011 - 03:37 AM

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





Also tagged with one or more of these keywords: jframe