Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Button question, hopefully an easy one...

 
Allen DeSantes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone. Just getting into Java and I have a question.
I have 2 Java programs, MenuFrame.java and BoxFrame.java.
My MenuFrame.java has two buttons in it, an "Exit" and "Open" button.
My BoxFrame.java just prints out a line of text.
My question is, how would I code the "Open" button so it creates an instance of the BoxFrame.java program in a new window?
my actionPerformed for my "Exit" button currently looks like this;
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The precise answer would depend on what sort of a class "BoxFrame" is. Is it a subclass of JFrame? Is it something that pritns to System.out?
 
Allen DeSantes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prints to System.out.
I'm hoping to learn how to call other programs from other programs. Or is the right terminology, creating an instance of one program form another program?
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Allen.
I have 2 Java programs

I think the first thing is to start thinking in Java/object oriented terms. Rather than having 2 programs you have 2 Java classes. You can create objects from these classes at runtime, so you can create an instance of BoxFrame within Menuframe when the Open button is clicked...

hope this helps you along a little
[ March 02, 2004: Message edited by: Ben Wood ]
[ March 02, 2004: Message edited by: Ben Wood ]
 
Allen DeSantes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ben!
That worked perfectly. I appreciate your help. I'm sure I'll be back with more questions as I progress.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic