• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Button question, hopefully an easy one...

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic