Home > Back-end >  Beginners JAVA GUI, every brother please jf. SetLayout (null), why don't show up blank.
Beginners JAVA GUI, every brother please jf. SetLayout (null), why don't show up blank.

Time:04-09

 import javax.mail. Swing. JFrame; 
The import javax.mail. Swing. JLabel;
The import javax.mail. Swing. JPanel;

Import the Java. The awt. Dimension;

The import javax.mail. Swing. JButton;
The import javax.mail. Swing. JTextField;
Public class Computor {
JButton b1=new JButton (" add ");//create a JButton objects
JButton b2=new JButton (" subtraction ");
JButton b3=new JButton (" reset all ");
JLabel label1=new JLabel (" operand ");//create the tag
JLabel label2=new JLabel (" operand 2 ");
JLabel label3=new JLabel (" result ");
JTextField txt1=new JTextField (20);
JTextField txt2=new JTextField (20);
JTextField txt3=new JTextField (20);
JFrame jf=new JFrame (" simple calculator ");
JPanel jp=new JPanel ();//create a JPanel object
Public Computor () {
Jf. SetSize (300400);
Jf. SetLayout (null);
Jp. SetLayout (null);

Jf. SetDefaultCloseOperation (JFrame. EXIT_ON_CLOSE);
Jp. Add (b1);
Jp. Add (b2);
Jp. Add (b3);
B1. SetBounds (60250,80,40);
B2. SetBounds (160250,80,40);
B3. SetBounds (90300120, 40);
Jf. Add (jp);
Jf. SetVisible (true);
}
//Settings window visible
Public static void main (String args []) {
New Computor ();
}
}

CodePudding user response:

Remove the jf. SetLayout (null); This is the result you want?

CodePudding user response:

This I also tried, but then don't remove the layout is not random?
  • Related