• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Java GUIs

LBJuice

n00b
Joined
Jan 23, 2005
Messages
27
I really like the Visual Studio Framework. I'm building a java application and I want my gui to be in a class called "Form" and I want my main method to be in a class "Program" so I can write a simple line of coding saying like Run(Form);

Form Class
public class Form {
private javax.swing.JFrame container;

public void Form() {
InitializeComponent();
}

public void InitializeComponent() {
this.container.setName("Frame");
this.container.setSize(500,500);
this.container.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
this.container.setVisible(true);
}
}

Program Class:

public class Program {
public static void main(String[] args) {
// what would I need to write here to launch an
// instance of Form and for it to be displayed?

}
}
 
it seems like it'd be simpler for your Form class to extend javax.swing.JFrame, then in your main method just put

new Form();

also, please use
Code:
 tags in the future.
anyway this is what you'd get if you put everything in Program.java

[code]
import javax.swing.*;

public class Program {
	public static void main(String[] args) {
		new Form();
	}
}

class Form extends JFrame {
	// note constructors do not have a return type in java
	public Form() {
		super();
		InitializeComponent();
	}

	public void InitializeComponent() {
		this.setName("Frame");
		this.setSize(500,500);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
	}
}
 
Back
Top