📄 texteditframe.java~16~
字号:
}
// Check if file is dirty.
// If so, prompt for save/don't save/cancel save decision.
boolean okToAbandon()
{
if (!dirty)
{
return true;
}
int value = JOptionPane.showConfirmDialog(this, "Save changes?",
"Text Edit",
JOptionPane.
YES_NO_CANCEL_OPTION);
switch (value)
{
case JOptionPane.YES_OPTION:
// Yes, please save changes
return saveFile();
case JOptionPane.NO_OPTION:
// No, abandon edits; that is, return true without saving
return true;
case JOptionPane.CANCEL_OPTION:
default:
// Cancel the dialog without saving or closing
return false;
}
}
public void jMenuItem3_actionPerformed(ActionEvent e)
{
saveFile();
}
public void jMenuItem4_actionPerformed(ActionEvent e)
{
saveAsFile();
}
public void jButton1_actionPerformed(ActionEvent e)
{
}
void helpAbout()
{
TextEditFrame_AboutBox dlg = new TextEditFrame_AboutBox(this);
Dimension dlgSize = dlg.getPreferredSize();
Dimension frmSize = getSize();
Point loc = getLocation();
dlg.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
(frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.setModal(true);
dlg.pack();
dlg.show();
}
public void jButton3_actionPerformed(ActionEvent e)
{
helpAbout();
}
public void jButton2_actionPerformed(ActionEvent e)
{
saveFile();
}
public void document1_changedUpdate(DocumentEvent e)
{
dirty = true;
}
public void document1_insertUpdate(DocumentEvent e)
{
dirty = true;
}
public void document1_removeUpdate(DocumentEvent e)
{
dirty = true;
}
public void this_windowClosing(WindowEvent e)
{
if (okToAbandon())
{
System.exit(0);
}
}
}
class TextEditFrame_document1_documentAdapter
implements DocumentListener
{
private TextEditFrame adaptee;
TextEditFrame_document1_documentAdapter(TextEditFrame adaptee)
{
this.adaptee = adaptee;
}
public void changedUpdate(DocumentEvent e)
{
adaptee.document1_changedUpdate(e);
}
public void insertUpdate(DocumentEvent e)
{
adaptee.document1_insertUpdate(e);
}
public void removeUpdate(DocumentEvent e)
{
adaptee.document1_removeUpdate(e);
}
}
class TextEditFrame_jButton2_actionAdapter
implements ActionListener
{
private TextEditFrame adaptee;
TextEditFrame_jButton2_actionAdapter(TextEditFrame adaptee)
{
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e)
{
adaptee.jButton2_actionPerformed(e);
}
}
class TextEditFrame_this_windowAdapter
extends WindowAdapter
{
private TextEditFrame adaptee;
TextEditFrame_this_windowAdapter(TextEditFrame adaptee)
{
this.adaptee = adaptee;
}
public void windowClosing(WindowEvent e)
{
adaptee.this_windowClosing(e);
}
}
class TextEditFrame_jMenuItem2_actionAdapter
implements ActionListener
{
private TextEditFrame adaptee;
TextEditFrame_jMenuItem2_actionAdapter(TextEditFrame adaptee)
{
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e)
{
adaptee.jMenuItem2_actionPerformed(e);
}
}
class TextEditFrame_jButton3_actionAdapter
implements ActionListener
{
private TextEditFrame adaptee;
TextEditFrame_jButton3_actionAdapter(TextEditFrame adaptee)
{
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e)
{
adaptee.jButton3_actionPerformed(e);
}
}
class TextEditFrame_jMenuItem3_actionAdapter
implements ActionListener
{
private TextEditFrame adaptee;
TextEditFrame_jMenuItem3_actionAdapter(TextEditFrame adaptee)
{
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e)
{
adaptee.jMenuItem3_actionPerformed(e);
}
}
class TextEditFrame_jMenuItem4_actionAdapter
implements ActionListener
{
private TextEditFrame adaptee;
TextEditFrame_jMenuItem4_actionAdapter(TextEditFrame adaptee)
{
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e)
{
adaptee.jMenuItem4_actionPerformed(e);
}
}
class TextEditFrame_jButton1_actionAdapter
implements ActionListener
{
private TextEditFrame adaptee;
TextEditFrame_jButton1_actionAdapter(TextEditFrame adaptee)
{
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e)
{
adaptee.jButton1_actionPerformed(e);
}
}
class TextEditFrame_jMenuItem6_actionAdapter
implements ActionListener
{
private TextEditFrame adaptee;
TextEditFrame_jMenuItem6_actionAdapter(TextEditFrame adaptee)
{
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e)
{
adaptee.jMenuItem6_actionPerformed(e);
}
}
class TextEditFrame_jMenuItem5_actionAdapter
implements ActionListener
{
private TextEditFrame adaptee;
TextEditFrame_jMenuItem5_actionAdapter(TextEditFrame adaptee)
{
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e)
{
adaptee.jMenuItem5_actionPerformed(e);
}
}
class TextEditFrame_jMenuItem7_actionAdapter
implements ActionListener
{
private TextEditFrame adaptee;
TextEditFrame_jMenuItem7_actionAdapter(TextEditFrame adaptee)
{
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e)
{
adaptee.jMenuItem7_actionPerformed(e);
}
}
class TextEditFrame_jMenuItem1_actionAdapter
implements ActionListener
{
private TextEditFrame adaptee;
TextEditFrame_jMenuItem1_actionAdapter(TextEditFrame adaptee)
{
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e)
{
adaptee.jMenuItem1_actionPerformed(e);
}
}
class TextEditFrame_jMenuFileExit_ActionAdapter
implements ActionListener
{
TextEditFrame adaptee;
TextEditFrame_jMenuFileExit_ActionAdapter(TextEditFrame adaptee)
{
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent)
{
adaptee.jMenuFileExit_actionPerformed(actionEvent);
}
}
class TextEditFrame_jMenuHelpAbout_ActionAdapter
implements ActionListener
{
TextEditFrame adaptee;
TextEditFrame_jMenuHelpAbout_ActionAdapter(TextEditFrame adaptee)
{
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent actionEvent)
{
adaptee.jMenuHelpAbout_actionPerformed(actionEvent);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -