Jump to content




Recent Status Updates

  • Photo
      30 Sep
    rhossis

    laptop hard disk seated beneath motherboard but with no access panel. 7 hours to replace :(

    Show comments (3)
  • Photo
      19 Sep
    Chall

    I love it when you go to write a help thread, then while writing, you reach an enlightenment, and figure it out yourself.

    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