?? servermainclass.java
字號:
package main;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import com.chat.server.Server;
@SuppressWarnings("serial")
public class ServerMainClass extends JFrame {
private JComboBox cbxPort;
public static void main(String args[]) {
try {
ServerMainClass frame = new ServerMainClass();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the frame
*/
public ServerMainClass() {
super();
getContentPane().setLayout(null);
setResizable(false);
setTitle("JavaQQ 演示版-登陸");
setBounds(100, 100, 368, 199);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JButton btnExit = new JButton();
btnExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
btnExit.setText("退出(E)");
btnExit.setBounds(255, 136, 77, 25);
getContentPane().add(btnExit);
final JButton btnStart = new JButton();
btnStart.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(cbxPort.getItemCount()==0 || cbxPort.getSelectedItem().toString().trim().equals("")){
javax.swing.JOptionPane.showMessageDialog(null,"請輸入端口號!");
return;
}
String port[]={cbxPort.getSelectedItem().toString().trim()};
if(port[0].length()!=4){
javax.swing.JOptionPane.showMessageDialog(null,"端口號長度必須是四位!");
return;
}
if(!base.util.StringTransform.isDigit(port[0])){
javax.swing.JOptionPane.showMessageDialog(null,"端口號必須是有效數字!");
return;
}
dispose();
Server.main(port);
}
});
btnStart.setText("啟動(S)");
btnStart.setBounds(158, 136, 77, 25);
getContentPane().add(btnStart);
cbxPort = new JComboBox();
cbxPort.setBounds(133, 61, 134, 23);
cbxPort.setEditable(true);
cbxPort.addItem("8888");
cbxPort.addItem("9000");
getContentPane().add(cbxPort);
final JLabel label = new JLabel();
label.setText("端口號:");
label.setBounds(54, 60, 57, 25);
getContentPane().add(label);
final JLabel label_1 = new JLabel();
label_1.setFont(new Font("", Font.PLAIN, 15));
label_1.setText("輸入端口號");
label_1.setBounds(10, 0, 88, 41);
getContentPane().add(label_1);
//
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -