- import javax.swing.JFrame;
- import javax.swing.JLabel;
- public class Ch75 {
- public static void main(String[] args) {
- JFrame fm1031=new JFrame("視窗一");
- JLabel l1=new JLabel("預設");
- JLabel l2=new JLabel("靠左",JLabel.LEFT);
- JLabel l3=new JLabel("置中",JLabel.CENTER);
- JLabel l4=new JLabel("靠右",JLabel.RIGHT);
- JLabel l5=new JLabel("其他");
- l1.setBounds(8, 0, 180, 30);
- l2.setBounds(8, 35, 180, 30);
- l3.setBounds(8, 70, 180, 30);
- l4.setBounds(8, 105, 180, 30);
- l5.setBounds(50, 140, 100, 30);
- fm1031.setBounds(100, 100, 200, 200);
- fm1031.setVisible(true);
- fm1031.setResizable(false);
- fm1031.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- fm1031.setLayout(null);
- fm1031.add(l1);
- fm1031.add(l2);
- fm1031.add(l3);
- fm1031.add(l4);
- fm1031.add(l5);
- }
- }
複製代碼 |