📄 r_character.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class R_Character{
/**
* <p>Title: 字符识别程序</p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: 04医学应用2班</p>
*
* @author 幸柯
* @version 1.0
*/
JTextArea area1 = new JTextArea();
JTextArea area2 = new JTextArea();
JFrame frame = null;
public R_Character() {
}
public JFrame contentFrame(){
frame=new JFrame("字符识别程序");
frame.setBounds(150,150,400,480);
frame.setResizable(false);
JMenuBar menuBar=new JMenuBar();
frame.setJMenuBar(menuBar);
JMenu menu;
JMenuItem menuItem;
menu=new JMenu("文件");
menuBar.add(menu);
menuItem=new JMenuItem("打开");
menu.add(menuItem);
menuItem.addActionListener(new Open_actionListener(area1));
menuItem=new JMenuItem("保存");
menu.add(menuItem);
menuItem.addActionListener(new Save_actionListener(area1));
menuItem=new JMenuItem("取消");
menu.add(menuItem);
menuItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
//事件处理函数放于此
}
});
menu.addSeparator();
menuItem=new JMenuItem("退出");
menu.add(menuItem);
menuItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
System.exit(0);
}
});
menu = new JMenu("说明");
menuItem = new JMenuItem("说明");
menu.add(menuItem);
menuBar.add(menu);
menuItem.addActionListener(new Shuoming_actionListener(frame));
menu=new JMenu("关于");
menuBar.add(menu);
menuItem=new JMenuItem("关于");
menu.add(menuItem);
///menuItem=new JMenuItem("About");
//menu.add(menuItem);
menuItem.addActionListener(new About_actionListener(frame));
JPanel contentPane=new JPanel();
JPanel panel1=new JPanel();
JPanel panel2=new JPanel();
JPanel panel3=new JPanel();
JLabel label1=new JLabel("输 入");
JLabel label2=new JLabel("输 出");
//final JTextArea area1=new JTextArea();
area1.setLineWrap(true);
//final JTextArea area2=new JTextArea();
area2.setLineWrap(true);
JScrollPane scrollPane1=new JScrollPane(area1,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JScrollPane scrollPane2=new JScrollPane(area2,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane1.setPreferredSize(new Dimension(300,300));
scrollPane2.setPreferredSize(new Dimension(300,300));
panel1.setLayout(new BoxLayout(panel1,BoxLayout.PAGE_AXIS));
panel1.add(label1);
panel1.add(scrollPane1);
panel2.setLayout(new BoxLayout(panel2,BoxLayout.PAGE_AXIS));
JButton button;
button=new JButton("执行>>");
button.addActionListener(new Exe_actionListener(area1,area2));
panel2.add(button);
button=new JButton("清空 #");
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
area1.setText("");
area2.setText("");
}
});
panel2.add(button);
panel3.setLayout(new BoxLayout(panel3,BoxLayout.PAGE_AXIS));
panel3.add(label2);
panel3.add(scrollPane2);
contentPane.add(panel1,BorderLayout.EAST);
contentPane.add(panel2,BorderLayout.CENTER);
contentPane.add(panel3,BorderLayout.WEST);
frame.getContentPane().add(contentPane,BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
frame.validate();
return frame;
}
public static void main(String[] args) {
/*try{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}catch(Exception e){e.printStackTrace();}*/
R_Character Frame=new R_Character();
Frame.contentFrame();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -