kuframe.java~42~

来自「这是java写的一个抢答器」· JAVA~42~ 代码 · 共 72 行

JAVA~42~
72
字号
package Frame;

import javax.swing.*;
import java.awt.Toolkit;
import java.awt.Dimension;
/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class KuFrame extends JFrame {
    public KuFrame() {
        super();
        this.getContentPane().setLayout(null);
        setSize(_width,_height);
        Toolkit kit=Toolkit.getDefaultToolkit();
        Dimension dim=kit.getScreenSize();
        setLocation(dim.width/2-_width/2,dim.height/2-_height/2);
        setVisible(true);
        try {
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    private int _width=350;
    private int _height=150;
    private JLabel IPLab=new JLabel("输入服务器IP:");
    private JLabel UserNameLab=new JLabel("输入您的名字:");
    private JTextArea IPText=new javax.swing.JTextArea("");
    private JTextArea UserNameText=new JTextArea("");
    private JButton TestButton=new JButton("测  试");
    private JButton OkButton=new JButton("确  定");
    private JButton ExitButton=new JButton("退  出");

    public static void main(String[] args) {
        KuFrame kuframe = new KuFrame();
    }

    private void jbInit() throws Exception {
        IPLab.setBounds(3,10,100,20);
         IPLab.setVisible(true);
         this.getContentPane().add(IPLab);
         IPText.setBounds(103,10,120,20);
         IPText.setVisible(true);
         this.getContentPane().add(IPText);
         UserNameLab.setBounds(3,35,100,20);
         UserNameLab.setVisible(true);
         this.getContentPane().add(UserNameLab);
         UserNameText.setBounds(103,35,120,20);
         UserNameText.setVisible(true);
         this.getContentPane().add(UserNameText);
         TestButton.setBounds(240,10,70,20);
         TestButton.setVisible(true);
         this.getContentPane().add(TestButton);
         OkButton.setBounds(40,70,70,20);
         OkButton.setVisible(true);
         this.getContentPane().add(OkButton);
         ExitButton.setBounds(180,70,70,20);
         ExitButton.setVisible(true);
         this.getContentPane().add(ExitButton);
     }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?