Here is the code:
public static void main (String [] args) {
new program1 () ;
System.out.println("123Test") ;
}
public class program1 {
public program1 () {
abc () ;
}
}
In the above case, 123Test will be printed when the program1 is running. What I want to ask is that how to address make 123Test print out until the program1 has been finished?
Somethings need to add is that in abc(), there will be a GUI, what I want to do is making a shutdown button. When someone press the button, the program1 will shutdown immediately like using frame.dispose(). Since I want to separate each JFrame into different classes, is there any ways to perform it better in the main? For example, I have program1 (), program2 (), program3 (), which represent different JFrame.
Like the comments mention, your question is extremely confusing, but I'll take a stab at it. I have no idea why you really need to have 5 separate classes for each JFrame, can't you simply make a method in your main class to do it?
private static void method1() {
//initialize gui with
Gui gui = new GUI();
gui.setVisible(true);
//do stuff
System.out.println("123Test");
}
If, for whatever reason, you really need to make a new Class, please follow coding conventions, as well as proper syntax. Your Class should be capitalized:
public static void main (String [] args) {
Program1 program = new Program1();
}
public class Program1 {
Program1() {
//initialize gui here
System.out.println("123Test") ;
}
}
To be honest, it doesn't seem like you understand basic Java and I recommend doing tutorials of simpler programs first before messing around with JFrames.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.