I am very new to java forms. Sorry about this easy question, I’ve searched too many forums but still couldn’t find the issue. I have a simple java form, it shows fine on Preview but when I run the code, it doesn’t show the form. I used another version which Extends the Jframe but this one shows an empty blank form. Please help me, advise a good document if you know. Thanks
package GUIpkg; import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class MainForm implements ActionListener { private JPanel panel1; private JButton Mathematica; private JTextArea textArea1; private JTextArea textArea2; private JButton SourceCode; public MainForm () { } import GUIpkg.MainForm; import java.awt.event.ActionEvent; public class Main { static public void main (String argv[]) { MainForm mf = new MainForm(); } }
EDITED
I thought It could be like C#, when you add an object from ToolBox to your frame, the codes also automatically will be added to your behind code. like size, position etc. but here there is not anything in my constructor. So how to add objects without hardcoding the properties? I simply dragged the objects to my frame.
Advertisement
Answer
This definitely does not look like a form that Java could render on the screen. Did you show all your code?
Independently of that, a good tutorial to look at is https://docs.oracle.com/javase/tutorial/uiswing/