• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it okay  RSS feed

 
Ranch Hand
Posts: 471
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am asking a question related to design.
1) Is it okay have in a variable and a method in Main class:
private static MainClass mainclass;
And
public static MainClass getApplication(){
return mainclass;
}

And
public void actionPerformed(ActionEvent e){
//do some work
}

(No setter, as I don't want other classes to change variable mainclass).
And the other classes call methods in Main by :
private static MainClass callmain=MainClass.getApplication();
And
public void actionPerformed(ActionEvent e){
callmain.actionPerformed(e);
}

The second class provides butttons set to the main. As the buttons are clicked the call comes to the second class methods and then back to the main class.
This is not srictly Awt/Swing question but of designing and of performance of my application.
Could there be a better strategy?

2) Is it better to start all the classes in the same JVM rather than create one JVM per class?
Performance - Jack Shirazi at Onjava.com
My program has five JInternalFrame classes and one buttons panel which are loaded in the MainClass. So what is better?
Please remember that my application is not very big!

Thanx in Advance!
Maki Jav
[ March 09, 2004: Message edited by: Maki Jav ]
 
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sure you can hold global variables and use them. But this is probably poor OO design. A better strategy is to insert the main class into the actions as needed as opposed to globally calling it.
You do not start multiple classes in multiple JVMs. How will they talk to each other?
 
Maki Jav
Ranch Hand
Posts: 471
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be more clear on main class action
Thank you
Maki Jav
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!