📄 portsetdialog.java~9~
字号:
import java.awt.BorderLayout;
import java.awt.Frame;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTextField;
import java.awt.FlowLayout;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JToggleButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
public class PortSetDialog extends JDialog {
JPanel panel1 = new JPanel();
JTextField jTextField1 = new JTextField();
FlowLayout flowLayout1 = new FlowLayout();
JLabel jLabel1 = new JLabel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
public PortSetDialog(Frame owner, String title, boolean modal) {
super(owner, title, modal);
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
jbInit();
pack();
} catch (Exception exception) {
exception.printStackTrace();
}
}
public PortSetDialog() {
this(new Frame(), "PortSetDialog", false);
}
private void jbInit() throws Exception {
panel1.setLayout(flowLayout1);
jLabel1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 12));
jLabel1.setText("服务器端口:");
jButton1.setText("确定");
jButton1.addActionListener(new PortSetDialog_jButton1_actionAdapter(this));
jButton2.setText("取消");
jButton2.addActionListener(new PortSetDialog_jButton2_actionAdapter(this));
jTextField1.setColumns(8);
getContentPane().add(panel1);
panel1.add(jLabel1);
panel1.add(jTextField1, null);
panel1.add(jButton1);
panel1.add(jButton2);
}
public void jButton1_actionPerformed(ActionEvent e) {
System.out.println("确定");
ChatServer frame = (ChatServer) this.getParent();
String strPort = this.jTextField1.getText();
try {
int port = Integer.parseInt(strPort);
} catch(Exception e) {}
dispose();
}
public void jButton2_actionPerformed(ActionEvent e) {
System.out.println("取消");
dispose();
}
}
class PortSetDialog_jButton2_actionAdapter implements ActionListener {
private PortSetDialog adaptee;
PortSetDialog_jButton2_actionAdapter(PortSetDialog adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class PortSetDialog_jButton1_actionAdapter implements ActionListener {
private PortSetDialog adaptee;
PortSetDialog_jButton1_actionAdapter(PortSetDialog adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -