/*
- 文 件 名: EasyView.java
- 描 述: <描述>
- 修改时间: 2017年8月11日
*/
package view.main;
import java.awt.EventQueue;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import java.awt.BorderLayout;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import javax.swing.text.BadLocationException;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import java.awt.Font;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import javax.swing.JTextPane;
import javax.swing.KeyStroke;
public class EasyView
{
private JFrame frmEasyview;
private JTextPane textPane;
private static final String KEYWORD_PUBLIC="public"; //文本中的关键字,会显示为红色
/**
* Launch the application.
*/
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
try
{
EasyView window = new EasyView();
window.frmEasyview.setVisible(true);
}
catch (Exception e)
{
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public EasyView()
{
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize()
{
frmEasyview = new JFrame();
frmEasyview.getContentPane().setBackground(Color.WHITE);
frmEasyview.setForeground(Color.BLACK);
frmEasyview.setTitle("EasyView");
frmEasyview.setBounds(100, 100, 673, 492);
frmEasyview.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmEasyview.getContentPane().setLayout(new BorderLayout());
JMenuBar menuBar = new JMenuBar();
frmEasyview.getContentPane().add(menuBar,BorderLayout.NORTH);
//打开菜单
JMenu mnNewMenu = new JMenu("\u6587\u4EF6");
mnNewMenu.setFont(new Font("微软雅黑", Font.PLAIN, 12));
mnNewMenu.setHorizontalAlignment(SwingConstants.CENTER);
menuBar.add(mnNewMenu);
MyMenuItemsListener mmil=new MyMenuItemsListener();
JMenuItem mntmo = new JMenuItem("\u6253\u5F00(O)");
mntmo.setFont(new Font("微软雅黑", Font.PLAIN, 12));
//设置不同的actioncommand来监听不同的action
mntmo.setActionCommand("open");
//设置快捷键
mntmo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,ActionEvent.CTRL_MASK));
//设置助记键
mntmo.setMnemonic(KeyEvent.VK_O);
mntmo.addActionListener( mmil );
mnNewMenu.add(mntmo);
JMenuItem mntms = new JMenuItem("\u4FDD\u5B58(S)");
mntms.setFont(new Font("微软雅黑", Font.PLAIN, 12));
mntms.addActionListener( mmil );
//设置不同的actioncommand来监听不同的action
mntms.setActionCommand("save");
//设置快捷键
mntms.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,ActionEvent.CTRL_MASK));
//设置助记键
mntms.setMnemonic(KeyEvent.VK_S);
mnNewMenu.add(mntms);
共同学习,写下你的评论
评论加载中...
作者其他优质文章