1 package Test; 2 import java.awt.*; 3 import javax.swing.*; 4 public class Cha { 5 JFrame f; 6 JPanel p; 7 JLabel l1; 8 JButton b1,b2; 9 10 public Cha () { 11 f = new JFrame("emmmm"); 12 p = new JPanel(); 13 l1= new JLabel("明天还会下雨嘛"); 14 15 b1 = new JButton("也许"); 16 b2 = new JButton("不会"); 17 18 f.setVisible(true); 19 f.add(p); 20 p.add(l1); 21 22 p.add(b1); 23 p.add(b2); 24 25 f.setBounds(100, 100, 252, 250); 26 p.setFont(new Font("宋体",Font.CENTER_BASELINE,20)); 27 p.setBackground(new Color(123,172,209)); 28 29 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 30 31 } 32 33 public static void main(String[] args) { 34 // TODO Auto-generated method stub 35 new Cha(); 36 } 37 38 }
立刻
原文:https://www.cnblogs.com/shi-yuan/p/10878769.html