📄 mylinkdialog.java
字号:
package mydesktop;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MyLinkDialog extends JDialog{
JPanel northPanel = new JPanel();
JPanel north2Panel = new JPanel();
JPanel southPanel = new JPanel();
JTextField textField = new JTextField(10);
JTextField urlField = new JTextField(10);
JButton butOk = new JButton("确定");
JButton butCancel = new JButton("取消");
MyLinkDialog(JFrame frame,String title,boolean modal){
super(frame,title,modal);
jInit();
pack();
}
public void jInit(){
north2Panel.setLayout(new BorderLayout());
north2Panel.add(textField,BorderLayout.NORTH);
north2Panel.add(urlField,BorderLayout.CENTER);
northPanel.add(north2Panel);
southPanel.add(butOk,null);
southPanel.add(butCancel,null);
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(northPanel,BorderLayout.CENTER);
this.getContentPane().add(southPanel,BorderLayout.SOUTH);
butOk.addActionListener(new SureActionListener(this));
butCancel.addActionListener(new CancelActionListener(this));
}
public void actionListener(){
this.dispose();
}
public void setText(String str){
this.textField.setText(str);
}
public void setUrlText(String str){
this.urlField.setText(str);
}
public String getText(){
return textField.getText();
}
public String getUrlText(){
return urlField.getText();
}
}
class SureActionListener implements java.awt.event.ActionListener{
MyLinkDialog d;
SureActionListener(MyLinkDialog d){
this.d = d;
}
public void actionPerformed(ActionEvent e){
d.actionListener();
}
}
class CancelActionListener implements ActionListener{
MyLinkDialog d;
CancelActionListener(MyLinkDialog d){
this.d = d;
}
public void actionPerformed(ActionEvent e) {
d.actionListener();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -