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

calling another swing application to run when a button is click from my swing application

 
joseph okon
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is my code
the one that will call the other application when the Okbtn is clicked. this is the second code

all i want is to get the logic on how to call another application main method to run and be made visible.
i will really appreciate ,
thanks
joseph
 
Peter Taucher
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't want tu run the main method of TransferClass but instead to instantiate the TransferFrame and make it visible. Just insert your code from TransferClass#main to MyFramePanel#actionPerformed ... for a start.
 
Peter Taucher
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just curious. Is this topic still of interest?
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter Taucher wrote:I'm just curious. Is this topic still of interest?


Maybe not to the original poster, but it will be to future generations of Swing programmers.
 
joseph okon
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
am very much interested in the post i made only that am not always online thanks to some factors.

 
joseph okon
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have gotten it right. i had to put all the TransferFramePanel code into TransferClass Constructor and extends JFrame, then initialize TransferClass from MyClass action.
I want to exit MyClass window after TransferClass window is visible?
I use System.exit(1); but the whole Application was closed, that is MyClass and TransferClass window was closed.
what code can i use to close only MyClass window? am i little bit lost in the bush!!!
 
Peter Taucher
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://java.sun.com/docs/books/tutorial/uiswing/components/frame.html
http://java.sun.com/javase/6/docs/api/java/awt/Window.html#setVisible(boolean)
 
joseph okon
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is my action code

it is complaining
this is the error
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
joseph okon wrote:
it is complaining
this is the error


As well it should. You're calling dispose as if it were a static method of MyClass and per your code above it isn't. Perhaps you wish to get the reference to the JFrame and call dispose on it.
 
joseph okon
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have gotten it by using this code

after making the TransferClass visble i use the SwingUtilities to get the ancestor window before calling the dispose() method
thanks to you all
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic