📄 dcommon.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package xechanger;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.text.AttributeSet;import javax.swing.text.BadLocationException;import javax.swing.text.PlainDocument;/** * * @author Chohei */public class DCommon extends JDialog { private JPanel inpn; private JPanel lin2; private JPanel lin1; private JButton jbOK; private JButton jbCL; private boolean sts; public DCommon(JFrame aFrame, JPanel insid, String txt) { super(aFrame, true); sts = false; jbOK = new JButton(txt); jbCL = new JButton("取消"); setTitle(txt); lin1 = insid; lin2 = new JPanel(new GridLayout(2, 1, 5, 5)); inpn = new JPanel(); lin2.add(jbOK); lin2.add(jbCL); inpn.add(lin1); inpn.add(lin2); setContentPane(inpn); this.setResizable(false); jbCL.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { clClick(e); } }); jbOK.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okClick(e); } }); } private void clClick(ActionEvent e) { sts = false; this.setVisible(false); } private void okClick(ActionEvent e) { sts = true; this.setVisible(false); } public JPanel getMain() { return lin1; } public boolean isOK() { return sts; }}class LimitDocument extends PlainDocument { int maxChars; String[] disb = {"\\", "/", ":", "*", "?", "\"", "|", "<", ">"}; public LimitDocument(int maxlen) { maxChars = maxlen; } @Override public void insertString(int offset, String s, AttributeSet a) throws BadLocationException { if (getLength() + s.length() > maxChars) { return; } super.insertString(offset, s, a); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -