??
字號:
import javax.swing.*;
import java.awt.*;
public class customer
{
public static void main(String args[])
{
JFrame frameobj;
JPanel panelobj;
JLabel Labelobj_1,Labelobj_2;
JTextField textobj;
JComboBox Listobj;
GridBagLayout Girdobj;
GridBagconstraints constraintsobj;
frameobj=new JFrame("聊天室");
panelobj=new JPanel();
frameobj.getContentPane().add(panelobj);
frameobj.setDefaultCloseOperation(frameobj.EXIT_ON_CLOSE);
Labelobj_1=new JLabel("請輸入你的用戶名:");
Labelobj_1.setBackground(Color.green);
constraintsobj.gridx=0;
constraintsobj.gridy=0;
constraintsobj.anchor=GridBayConstraints.NORTHWEST;
constraintsobj.fill=GridBayConstraints.BOTH;
Girdobj.setConstraints(Labelobj_1,constraintsobj);
panelobj.add(Labelobj_1);
textobj=new JTextField(5);
textobj.setBackground(Color.white);
constraintsobj.gridx=0;
constraintsobj.gridy=1;
Gridobj.gridwidth=GridBagConstraints.REMAINDER;
Gridobj.setConstraints(textobj,constraintsobj);
panelobj.add(textobj);
Labelobj_2=new JLabel("請選擇你所在的城市:");
panelobj.add(Labelobj_2);
constraintsobj.gridx=1;
constraintsobj.gridy=2;
Girdobj.setConstraints(Labelobj_2,constraintsobj);
panelobj.add(Labelobj_2);
String city[]={"china","Ameriaca","Japne"};
Listobj=new JComboBox(city);
panelobj.add(Listobj);
constraintsobj.gridx=1;
constraintsobj.gridy=1;
constraintsobj.anchor=GridBayConstraints.NORTHWEST;
Girdobj.setConstraints(Listobj,constraintsobj);
panelobj.add(Listobj);
frameobj.setVisible(true);
frameobj.setSize(449,475);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -