package jishiben;
import java.awt.event.KeyEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Event;
import java.awt.BorderLayout;
import java.awt.FileDialog;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.KeyStroke;
import java.awt.Point;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JFrame;
import javax.swing.JDialog;
import javax.swing.JTextArea;
public class jishiben {
private JFrame jFrame = null;
private JPanel jContentPane = null;
private JTextArea jTextArea = null;
private JMenuBar jJMenuBar = null;
private JMenu fileMenu = null;
private JMenu editMenu = null;
private JMenu helpMenu = null;
private JMenu objectMenu = null;
private JMenu viewMenu = null;
private JMenuItem exitMenuItem = null;
private JMenuItem aboutMenuItem = null;
private JMenuItem cutMenuItem = null;
private JMenuItem copyMenuItem = null;
private JMenuItem pasteMenuItem = null;
private JMenuItem saveMenuItem = null;
private JMenuItem newMenuItem = null;
private JMenuItem openMenuItem = null;
private JMenuItem setMenuItem = null;
private JMenuItem printMenuItem = null;
private JMenuItem findMenuItem = null;
private JMenuItem removeMenuItem = null;
private JMenuItem allMenuItem = null;
private JMenuItem zitiMenuItem = null;
private JMenuItem solutionMenuItem = null;
private JOptionPane jOPtionPane = null;
private JDialog aboutDialog = null;
private JPanel aboutContentPane = null;
private JLabel aboutVersionLabel = null;
/**
* This method initializes jFrame
*
* @return javax.swing.JFrame
*/
private JFrame getJFrame() {
if (jFrame == null) {
jFrame = new JFrame();
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jFrame.setJMenuBar(getJJMenuBar());
jFrame.setSize(300, 200);
jFrame.setContentPane(getJContentPane());
jFrame.setTitle("文本编辑器");
}
return jFrame;
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.add(getjTextArea());
}
return jContentPane;
}
private JTextArea getjTextArea(){
if(jTextArea == null){
jTextArea = new JTextArea();
}
return jTextArea;
}
/**
* This method initializes jJMenuBar
*
* @return javax.swing.JMenuBar
*/
private JMenuBar getJJMenuBar() {
if (jJMenuBar == null) {
jJMenuBar = new JMenuBar();
jJMenuBar.add(getFileMenu());
jJMenuBar.add(getEditMenu());
jJMenuBar.add(getobjectMenu());
jJMenuBar.add(getviewMenu());
jJMenuBar.add(getHelpMenu());
}
return jJMenuBar;
}
/**
* This method initializes jMenu
*
* @return javax.swing.JMenu
*/
private JMenu getFileMenu() {
if (fileMenu == null) {
fileMenu = new JMenu();
fileMenu.setText("文件");
fileMenu.add(getSaveMenuItem());
fileMenu.add(getExitMenuItem());
fileMenu.add(getopenMenuItem());
fileMenu.add(getnewMenuItem());
fileMenu.add(getsetMenuItem());
fileMenu.add(getprintMenuItem());
}
return fileMenu;
}
/**
* This method initializes jMenu
*
* @return javax.swing.JMenu
*/
private JMenu getEditMenu() {
if (editMenu == null) {
editMenu = new JMenu();
editMenu.setText("编辑");
editMenu.add(getCutMenuItem());
editMenu.add(getCopyMenuItem());
editMenu.add(getPasteMenuItem());
editMenu.add(getremoveMenuItem());
editMenu.add(getallMenuItem());
}
return editMenu;
}
/**
* This method initializes jMenu
*
* @return javax.swing.JMenu
*/
private JMenu getHelpMenu() {
if (helpMenu == null) {
helpMenu = new JMenu();
helpMenu.setText("帮助");
helpMenu.add(getAboutMenuItem());
}
return helpMenu;
}
private JMenu getobjectMenu() {
if (objectMenu == null) {
objectMenu = new JMenu();
objectMenu.setText("格式");
objectMenu.add(getAboutMenuItem());
objectMenu.add(getzitiMenuItem());
}
return objectMenu;
}
private JMenu getviewMenu() {
if (viewMenu == null) {
viewMenu = new JMenu();
viewMenu.setText("查看");
viewMenu.add(getAboutMenuItem());
viewMenu.add(getsolutionMenuItem());
}
return viewMenu;
}
/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getExitMenuItem() {
if (exitMenuItem == null) {
exitMenuItem = new JMenuItem();
exitMenuItem.setText("退出");
exitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,
Event.CTRL_MASK, true));
exitMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
}
return exitMenuItem;
}
private JMenuItem getopenMenuItem() {
if (openMenuItem == null) {
openMenuItem = new JMenuItem();
openMenuItem.setText("打开");
openMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,
Event.CTRL_MASK, true));
openMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("打开文件");
FileDialog fd = new FileDialog(jFrame, "打开");
fd.getFilenameFilter();
fd.setVisible(true);
fd.setLocation(400, 200);
fd.setResizable(false);
}
});
}
return openMenuItem;
}
private JMenuItem getnewMenuItem() {
if (newMenuItem == null) {
newMenuItem = new JMenuItem();
newMenuItem.setText("新建");
newMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,
Event.CTRL_MASK, true));
newMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("新建文件");
}
});
}
return newMenuItem;
}
private JMenuItem getsetMenuItem() {
if (setMenuItem == null) {
setMenuItem = new JMenuItem();
setMenuItem.setText("设置");
setMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U,
Event.CTRL_MASK, true));
setMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("设置");
}
});
}
return setMenuItem;
}
private JMenuItem getprintMenuItem() {
if (printMenuItem == null) {
printMenuItem = new JMenuItem();
printMenuItem.setText("打印");
printMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P,
Event.CTRL_MASK, true));
printMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("打印文件");
}
});
}
return printMenuItem;
}
private JMenuItem getremoveMenuItem() {
if (removeMenuItem == null) {
removeMenuItem = new JMenuItem();
removeMenuItem.setText("替换");
removeMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,
Event.CTRL_MASK, true));
removeMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("替换文件");
}
});
}
return removeMenuItem;
}
private JMenuItem getallMenuItem() {
if (allMenuItem == null) {
allMenuItem = new JMenuItem();
allMenuItem.setText("全选");
allMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,
Event.CTRL_MASK, true));
allMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jTextArea.selectAll();
System.out.println("全选文件");
}
});
}
retu