一个关于event.getActionCommand 的问题。

phoenixv 2001-12-30 03:03:42
下面的一段程序中,if ("comboBoxChanged".equals(event.getActionCommand())) 中的comBoBoxChanged 是什么啊?为什么API中查不到?是一个事件吗?在什么地方能查到呢?如果是一个事件的话,就是说event.getActionCommand()返回的是一个string是吗?返回的是固定的string吗?预定义的?什么地方能找到关于这个的详细说明?谢谢。

// Create and the widgets to select and display the phases of the moon.
private void addWidgets() {
// Get the images and put them into an array of ImageIcon.
for (int i = 0; i < NUM_IMAGES; i++) {
String imageName = "images/image" + i + ".jpg";
System.out.println("getting image: " + imageName);
URL iconURL = ClassLoader.getSystemResource(imageName);

ImageIcon icon = new ImageIcon(iconURL);
images[i] = icon;
}

// Create label for displaying moon phase images and put a border around it.
phaseIconLabel = new JLabel();
phaseIconLabel.setHorizontalAlignment(JLabel.CENTER);
phaseIconLabel.setVerticalAlignment(JLabel.CENTER);
phaseIconLabel.setVerticalTextPosition(JLabel.CENTER);
phaseIconLabel.setHorizontalTextPosition(JLabel.CENTER);
phaseIconLabel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createLoweredBevelBorder(),
BorderFactory.createEmptyBorder(5,5,5,5)));

phaseIconLabel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(0,0,10,0),
phaseIconLabel.getBorder()));

// Create combo box with lunar phase choices.
String[] phases = { "New", "Waxing Crescent", "First Quarter",
"Waxing Gibbous", "Full", "Waning Gibbous",
"Third Quarter", "Waning Crescent" };
phaseChoices = new JComboBox(phases);
phaseChoices.setSelectedIndex(START_INDEX);

// Display the first image.
phaseIconLabel.setIcon(images[START_INDEX]);
phaseIconLabel.setText("");

// Add border around the select panel.
selectPanel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder("Select Phase"),
BorderFactory.createEmptyBorder(5,5,5,5)));

// Add border around the display panel.
displayPanel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder("Display Phase"),
BorderFactory.createEmptyBorder(5,5,5,5)));

// Add moon phases combo box to select panel and image label to displayPanel.
selectPanel.add(phaseChoices);
displayPanel.add(phaseIconLabel);

// Listen to events from combo box.
phaseChoices.addActionListener(this); // 问题在这里
}

// Implementation of ActionListener interface.
public void actionPerformed(ActionEvent event) {
if ("comboBoxChanged".equals(event.getActionCommand())) { //问题在这里
// update the icon to display the new phase
phaseIconLabel.setIcon(images[phaseChoices.getSelectedIndex()]);
}
}
...全文
1046 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
phoenixv 2001-12-31
  • 打赏
  • 举报
回复
你是说让button被点击的时候返回一个string"comboBoxChanged"吗?
yhc0125 2001-12-30
  • 打赏
  • 举报
回复
"comboBoxChanged"是动作命令,是与组件相关的文本。通过setActionCommand(String)方法设置。功能与getSource()相似。"comboBoxChanged".equals(event.getActionCommand()这句是说如果产生动作的组件的动作命令是comboBoxChanged,则执行下面操作。多用于多个组件引发相同事件。
package com; import java.awt.BorderLayout; import java.awt.Button; import java.awt.Container; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.WindowConstants; public class Caculator extends JFrame implements ActionListener,KeyListener{ /** * */ private static final long serialVersionUID = 5204982079673572494L; private JTextField tf=new JTextField(); private float x=0; private float y=0; private int code=0; private boolean enable; private boolean first; private String str=""; public Caculator(){ Container ct=this.getContentPane(); this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); tf.setHorizontalAlignment(JTextField.RIGHT); //tf.setText("0"); enable=true; first=true; ct.add(tf,BorderLayout.NORTH); JPanel panel=new JPanel(); panel.setLayout(new GridLayout(4,4)); this.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ if(JOptionPane.YES_OPTION==JOptionPane.showConfirmDialog(Caculator.this,"确定要关闭程序吗?","提示",JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE)){ e.getWindow().setVisible(false); e.getWindow().dispose(); System.exit(0); } } }); Button btn=null; btn=new Button("1"); panel.add(btn); btn.addActionListener(this); btn.addKeyListener(this); btn=new Button("2"); panel.add(btn); btn.addActionListener(this); btn.addKeyListener(this); btn=new Button("3"); panel.add(btn); btn.addActionListener(this); btn.addKeyListener(this); btn=new Button("+"); panel.add(btn); btn.addActionListener(this); btn.addKeyListener(this); btn=new Button("4"); panel.add(btn); btn.addActionListener(this); btn.addKeyListener(this); btn=new Button("5"); panel.add(btn); btn.addActionListener(this); btn.addKeyListener(this); btn=new Button("6"); panel.add(btn); btn.addActionListener(this); btn.addKeyListener(this); btn=new Button("-"); panel.add(btn); btn.addActionListener(this); btn.addKeyListener(this); btn=new Button("7"); panel.add(btn); btn.addActionListener(this); btn.addKeyListener(this); btn=new Button("8"); panel.add(btn); btn.addActionListener(this); btn.addKeyListener(this); btn=new Button("9"); panel.add(btn); btn.addActionListener(this); btn.addKeyListener(this); btn=new Button("*"); panel.add(btn); btn.addActionListener(this); btn.addKeyListener(this); btn=new Button("0"); panel.add(btn); btn.addActionListener(this); btn.addKeyListener(this); btn=new Button("."); panel.add(btn); btn.addActionListener(this); btn.addKeyListener(this); btn=new Button("/"); panel.add(btn); btn.addActionListener(this); btn.addKeyListener(this); btn=new Button("="); panel.add(btn); btn.addActionListener(this); btn.addKeyListener(this); this.add(panel,BorderLayout.CENTER); } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Caculator mainframe=new Caculator(); mainframe.setTitle("testing Caculator"); mainframe.setSize(400,400); mainframe.setVisible(true); } public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if(e.getActionCommand()=="+"){ x= Float.parseFloat(tf.getText()); code=0; this.tf.setText(""); } if(e.getActionCommand()=="-"){ x= Float.parseFloat(tf.getText()); code=1; this.tf.setText(""); } if(e.getActionCommand()=="*"){ x= Float.parseFloat(tf.getText()); code=2; this.tf.setText(""); } if(e.getActionCommand()=="/"){ x= Float.parseFloat(tf.getText()); code=3; this.tf.setText(""); } if(e.getActionCommand()!="+"&&e.getActionCommand()!="-"&&e.getActionCommand()!="*"&&e.getActionCommand()!="/"&&e.getActionCommand()!="="){ if(enable){ if(first){ System.out.println("haha"); tf.setText(e.getActionCommand()); first=false; } else { tf.setText(tf.getText()+e.getActionCommand()); } } else { tf.setText(e.getActionCommand()); enable=true; } } if(e.getActionCommand()=="="){ switch(code){ case 0: y=x+Float.parseFloat(this.tf.getText()); tf.setText(Float.toString(y)); enable=false; break; case 1: y=x-Float.parseFloat(this.tf.getText()); tf.setText(Float.toString(y)); enable=false; break; case 2: y=x*Float.parseFloat(this.tf.getText()); tf.setText(Float.toString(y)); enable=false; break; case 3: y=x/Float.parseFloat(this.tf.getText()); tf.setText(Float.toString(y)); enable=false; break; } } } public void keyPressed(KeyEvent e) { // TODO Auto-generated method stub if(e.getKeyChar()=='+'){ x= Float.parseFloat(tf.getText()); code=0; this.tf.setText(""); } if(e.getKeyChar()=='-'){ x= Float.parseFloat(tf.getText()); code=1; this.tf.setText(""); } if(e.getKeyChar()=='*'){ x= Float.parseFloat(tf.getText()); code=2; this.tf.setText(""); } if(e.getKeyChar()=='/'){ x= Float.parseFloat(tf.getText()); code=3; this.tf.setText(""); } if(e.getKeyChar()=='1'||e.getKeyChar()=='2'||e.getKeyChar()=='3'||e.getKeyChar()=='0' ||e.getKeyChar()=='4'||e.getKeyChar()=='5'||e.getKeyChar()=='6'||e.getKeyChar()=='.' ||e.getKeyChar()=='7'||e.getKeyChar()=='8'||e.getKeyChar()=='9'){ System.out.println("hai"); if(enable){ if(first){ System.out.println("hehe"); str=Character.toString(e.getKeyChar()); tf.setText(str); first=false; } else { str=Character.toString(e.getKeyChar()); tf.setText(tf.getText()+str); } } else { str=Character.toString(e.getKeyChar()); tf.setText(str); enable=true; } } if(e.getKeyCode()==KeyEvent.VK_ENTER){ switch(code){ case 0: y=x+Float.parseFloat(this.tf.getText()); tf.setText(Float.toString(y)); enable=false; break; case 1: y=x-Float.parseFloat(this.tf.getText()); tf.setText(Float.toString(y)); enable=false; break; case 2: y=x*Float.parseFloat(this.tf.getText()); tf.setText(Float.toString(y)); enable=false; break; case 3: y=x/Float.parseFloat(this.tf.getText()); tf.setText(Float.toString(y)); enable=false; break; } } } public void keyReleased(KeyEvent arg0) { // TODO Auto-generated method stub } public void keyTyped(KeyEvent arg0) { // TODO Auto-generated method stub } }
一个java编译的最简单的计算器 import java.awt.*; import java.awt.event.*; import javax.swing.*; public class jisuan extends JFrame implements ActionListener{ /** * */ private static final long serialVersionUID = 5823423246304135749L; JPanel cp=new JPanel(); JPanel cp1=new JPanel(); Double nu1,nu2; ImageIcon ii=new ImageIcon("images/2_marcblue.jpg"); JPanel cp2=new JPanel(); JLabel jl=new JLabel(); String[] Jlabel = {"7","8","9","/","4","5","6","*","1","2","3","-","0",".","=","+"};//声明标签数组label1存放按钮上的标签 JButton[] b; JButton h=new JButton("c"); //private JButton buttonWithTitle=new JButton("Button with Title",new ImageIcon("src/anwendung/tree.jpg")); private JButton c=new JButton("后退",ii); JButton pf=new JButton("x^y"); int j=0,n=0,a=0,g=0; //Button[] b=new Button[10]; //JTextArea jt=new JTextArea(1,34); JTextField jt=new JTextField("0",30); //JLabel jt=new JLabel(); String st,st1,st2; Boolean t=true; public jisuan(){ setTitle("计算器"); setSize(220,220); //this.setbackgroundImage = new ImageIcon("images/6.21.bmp"); cp=(JPanel)this.getContentPane(); //this.setExtendedState(HIDE_ON_CLOSE); this.setUndecorated(false); this.setResizable(false);//窗口固定不变。 //cp.setEnabled(false); this.addWindowListener(new WindowAdapter(){//给窗口f添加窗口事件监听器 public void windowClosing(WindowEvent eve){ System.exit(0); } }); cp.setLayout(new BorderLayout()); cp.add(jt,BorderLayout.NORTH); cp.add(cp1,BorderLayout.CENTER); //cp.add(cp2,BorderLayout.SOUTH); //cp1.setLayout(new GridLayout(3,4)); cp1.setLayout(null); //cp.add(jt); jt.setHorizontalAlignment(JTextField.RIGHT);//右边显示。 jt.setFont(new Font("Serif",Font.BOLD|Font.ITALIC,15));//设置字体的大小和显示方式; jt.setBackground(Color.white);//背景白色 jt.setEditable(false); //jt.setEnabled(true); b = new JButton[Jlabel.length]; for(int i=0;iActionListener( this);//使每个按钮添加动作事件监听器 cp1.add(b[i]); //分别将按钮添加到面板p1上 } h.setSize(45,25); h.setLocation(10,130); h.addActionListener(this); cp1.add(h); // c.setSize(70,25); // c.setLocation(135, 130); // c.setIcon(ii); c.setBounds(135,130,70,25 ); c.setFont(new Font("a",Font.BOLD,10));//设置字体的大小和显示方式; c.addActionListener(this); cp1.add(c); pf.setSize(70,25); pf.setLocation(60, 130); pf.addActionListener(this); cp1.add(pf); //cp.add(new Button("2").addActionListener(new ActionListener(){})); } @Override public void actionPerformed(ActionEvent e) { if("0,1,2,3,4,5,6,7,8,9".indexOf(e.getActionCommand())!=-1){ if(j==0||g==1){//判断是否第一次输入或者运算符后输入; if("0".equals(e.getActionCommand())) jt.setText("0"); else {jt.setText(e.getActionCommand());j=1;} g=0; } else{ st = jt.getText(); jt.setText(st+e.getActionCommand());} } else if("c".equals(e.getActionCommand())){ jt.setText("0"); j=0;a=0;n=0;g=0; } else if("后退".equals(e.getActionCommand())){ st=jt.getText(); /*String r=new String(30); for(int i=0;iActionCommand())){ System.out.println(n); if(n==0&&g==0){ st = jt.getText(); jt.setText(st+e.getActionCommand()); n=1;j=1; } else{ jt.setText("0"); j=0;a=0;n=0;g=0; } } else if("+,-,*,/".indexOf(e.getActionCommand())!=-1){ if(j==1&&"0.".equals(jt.getText())!=true){ if(a==0){//判断是否第一次输入运算符; nu1=Double.parseDouble(jt.getText()); j=0; st=st1=e.getActionCommand(); a=1; } else { nu2=Double.parseDouble(jt.getText()); if(st1.equals("+")){ nu1=nu1+nu2; jt.setText(String.valueOf(nu1)); } else if(st1.equals("-")){ nu1=nu1-nu2; jt.setText(String.valueOf(nu1)); } else if(st1.equals("*")){ nu1=nu1*nu2; jt.setText(String.valueOf(nu1)); } else if(st1.equals("/")){ nu1=nu1/nu2; jt.setText(String.valueOf(nu1)); } else if(st1.equals("x^y")){ Double num=nu1; int nu=Integer.parseInt(String.valueOf(nu2)); while(nu>1){ nu1=nu1*num;nu--;} jt.setText(String.valueOf(nu1)); } j=0; st1=e.getActionCommand(); } } else{ st1=e.getActionCommand(); jt.setText("0"); j=0;a=0;n=0;g=0; } t=false; } else if("=".equals(e.getActionCommand())){ if("=".equals(String.valueOf(st.charAt(st.length()-1)))) a=1; else nu2=Double.parseDouble(jt.getText()); System.out.println(nu2); if(a==1){ //nu2=Double.parseDouble(st); if(st1.equals("+")){ nu1=nu1+nu2; jt.setText(String.valueOf(nu1)); } else if(st1.equals("-")){ nu1=nu1-nu2; jt.setText(String.valueOf(nu1)); } else if(st1.equals("*")){ nu1=nu1*nu2; jt.setText(String.valueOf(nu1)); } else if(st1.equals("/")){ nu1=nu1/nu2; jt.setText(String.valueOf(nu1)); } else if(st1.equals("x^y")){ Double num=nu1; for(;nu2>1;nu2--) nu1=nu1*num; jt.setText(String.valueOf(nu1)); } } a=0;g=1;t=true;st=e.getActionCommand(); } else if("x^y".equals(e.getActionCommand())){ if(t=true){ nu1=Double.parseDouble(jt.getText()); j=0; st1=e.getActionCommand(); a=1; } } } }
import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; import javax.swing.*; public class NotePad { public static void main(String[] args){ myfr fr=new myfr("猪猪java记事本"); fr.setLocation(100,100); fr.setSize(750,650); } } ///////////////////////////myfr主窗体类////////////////////////////////////// class myfr extends JFrame implements ActionListener{ String str,strnext,path,fname; //部分变量的声明 JPanel mainpane; JFileChooser choose = new JFileChooser(); //文件对话框 Dialog find,replace; //find为查找对话框,replace对话框 JTextField findtxt,repltxt; //find为查找对话框的输入文本区,replace对话框的输入文本区 Font newfont; JButton findenter,replb; //find为查找对话框,replace对话框的确定按钮 JLabel state=new JLabel(" 猪猪java记事本------"); //状态栏 JTextArea txt1; //主输入文本区 File newfiles; JPopupMenu popm; //弹出菜单声明 JMenu m1,m2,m3,m4,m5,m6; //各菜单项 JMenuItem m61,m62,m26,m271,m34,m51,m52,m53,m54,p_copy,p_cut,p_paste,p_del; int startp,endp,nexttemp,newstartp,newendp; //查找替换时所用的临时变量 JToolBar toolbar = new JToolBar(); //工具条 JButton newf=new JButton(new ImageIcon("9.jpg")); //图标在PIC下 JButton open=new JButton(new ImageIcon("2.jpg")); JButton save=new JButton(new ImageIcon("3.jpg")); JButton copy=new JButton(new ImageIcon("6.jpg")); JButton cut=new JButton(new ImageIcon("7.jpg")); JButton pp=new JButton(new ImageIcon("8.jpg")); JButton del=new JButton(new ImageIcon("pic/del.gif")); JButton findc=new JButton(new ImageIcon("9.jpg")); JButton color=new JButton(new ImageIcon("10.jpg")); JButton help=new JButton(new ImageIcon("pic/help.gif")); JButton exit=new JButton(new ImageIcon("pic/exit.gif")); myfr(String sss){ /////构造函数开始 super(sss); JMenuBar mb=new JMenuBar(); fname=null; //初始文件名为空 findenter=new JButton("确定"); findenter.addActionListener(this); //声明对话框中上确定按钮,并注册事件 replb=new JButton("确定"); replb.addActionListener(this); mainpane=(JPanel)this.getContentPane(); mainpane.setLayout(new BorderLayout()); txt1=new JTextArea("",13,61); txt1.addMouseListener(new handlemouse(this));//注册鼠标右击事件 txt1.setFont(new Font("宋体",Font.PLAIN,18)); mainpane.add(txt1, BorderLayout.CENTER); mainpane.add("North",toolbar); mainpane.add("South",state); JScrollPane sll = new JScrollPane(); //创建滚动条 mainpane.add("Center", sll); ; sll.getViewport().add(txt1); //将滚动条装入文本区 //文本栏中的浮动条 popm=new JPopupMenu(); ////POPMeun 开始 p_copy=new JMenuItem("复制 "); p_copy.addActionListener(this); KeyStroke keycopyp=KeyStroke.getKeyStroke(KeyEvent.VK_C,Event.CTRL_MASK); p_copy.setAccelerator(keycopyp); p_cut=new JMenuItem("剪切 "); p_cut.addActionListener(this); KeyStroke keycutp=KeyStroke.getKeyStroke(KeyEvent.VK_X,Event.CTRL_MASK); p_cut.setAccelerator(keycutp); p_paste=new JMenuItem("粘贴 "); p_paste.addActionListener(this); KeyStroke keypp=KeyStroke.getKeyStroke(KeyEvent.VK_V,Event.CTRL_MASK); p_paste.setAccelerator(keypp); p_del=new JMenuItem("删除 "); p_del.addActionListener(this); KeyStroke keydelp=KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0); p_del.setAccelerator(keydelp); popm.add(p_copy); popm.add(p_cut); popm.add(p_paste); popm.add(p_del); txt1.add(popm); ////POPMenu 结束 m1=new JMenu("文件(F)"); m1.setMnemonic('F'); //定义快捷方式 JMenuItem m10=new JMenuItem("新建 "); m10.addActionListener(this); //注册事件监听器 KeyStroke keynew=KeyStroke.getKeyStroke(KeyEvent.VK_N,Event.CTRL_MASK); //定义快捷键 m10.setAccelerator(keynew); JMenuItem m11=new JMenuItem("打开 "); m11.addActionListener(this); KeyStroke keyopen=KeyStroke.getKeyStroke(KeyEvent.VK_O,Event.CTRL_MASK); m11.setAccelerator(keyopen); JMenuItem m12=new JMenuItem("保存 "); m12.addActionListener(this); KeyStroke keysave=KeyStroke.getKeyStroke(KeyEvent.VK_S,Event.CTRL_MASK); m12.setAccelerator(keysave); JMenuItem m13=new JMenuItem("另保存为 "); m13.addActionListener(this); JMenuItem m14=new JMenuItem("退出 "); m14.addActionListener(this); KeyStroke keyexit=KeyStroke.getKeyStroke(KeyEvent.VK_F4,Event.ALT_MASK); m14.setAccelerator(keyexit); //////////////////////////////////////////// m2=new JMenu("编辑(E)"); m2.setMnemonic('E'); JMenuItem m21=new JMenuItem("复制 "); m21.addActionListener(this); KeyStroke keycopy=KeyStroke.getKeyStroke(KeyEvent.VK_C,Event.CTRL_MASK); m21.setAccelerator(keycopy); JMenuItem m22=new JMenuItem("剪切 "); m22.addActionListener(this); KeyStroke keycut=KeyStroke.getKeyStroke(KeyEvent.VK_X,Event.CTRL_MASK); m22.setAccelerator(keycut); JMenuItem m23=new JMenuItem("粘贴 "); m23.addActionListener(this); KeyStroke keyp=KeyStroke.getKeyStroke(KeyEvent.VK_V,Event.CTRL_MASK); m23.setAccelerator(keyp); JMenuItem m24=new JMenuItem("删除 "); m24.addActionListener(this); KeyStroke keydel=KeyStroke.getKeyStroke(KeyEvent.VK_DELETE,0); m24.setAccelerator(keydel); JMenuItem m25=new JMenuItem("查找 "); m25.addActionListener(this); KeyStroke keyfind=KeyStroke.getKeyStroke(KeyEvent.VK_F,Event.CTRL_MASK); m25.setAccelerator(keyfind); m26=new JMenuItem("查找下一个 "); m26.addActionListener(this); KeyStroke keyfn=KeyStroke.getKeyStroke(KeyEvent.VK_F3,0); m26.setAccelerator(keyfn); m26.setEnabled(false); JMenuItem m27=new JMenuItem("替换 "); m27.addActionListener(this); KeyStroke keyrepl=KeyStroke.getKeyStroke(KeyEvent.VK_H,Event.CTRL_MASK); m27.setAccelerator(keyrepl); m271=new JMenuItem("替换下一个"); m271.setEnabled(false); m271.addActionListener(this); KeyStroke keyrepn=KeyStroke.getKeyStroke(KeyEvent.VK_F6,0); m271.setAccelerator(keyrepn); JMenuItem m28=new JMenuItem("全选 "); m28.addActionListener(this); KeyStroke keyall=KeyStroke.getKeyStroke(KeyEvent.VK_A,Event.CTRL_MASK); m28.setAccelerator(keyall); JMenuItem m29=new JMenuItem("日期/时间 "); m29.addActionListener(this); m3=new JMenu("格式(O)"); m3.setMnemonic('O'); JMenu m31=new JMenu("字体样式 "); JMenuItem m311=new JMenuItem("正常 "); m311.addActionListener(this); JMenuItem m312=new JMenuItem("粗体 "); m312.addActionListener(this); JMenuItem m313=new JMenuItem("斜体 "); m313.addActionListener(this); JMenu m32=new JMenu("字体大小 "); JMenuItem m321=new JMenuItem("最大 "); m321.addActionListener(this); JMenuItem m322=new JMenuItem("较大 "); m322.addActionListener(this); JMenuItem m323=new JMenuItem("适中 "); m323.addActionListener(this); JMenuItem m324=new JMenuItem("较小 "); m324.addActionListener(this); JMenuItem m325=new JMenuItem("最小 "); m325.addActionListener(this); JMenuItem m33=new JMenuItem("字体颜色 "); m33.addActionListener(this); m34=new JMenuItem("自动换行 "); m34.addActionListener(this); m5=new JMenu("视图风格(V)"); m5.setMnemonic('V'); //m51=new JMenuItem("系统风格 "); //m51.addActionListener(this); m52=new JMenuItem("MOTIF风格 "); m52.addActionListener(this); m53=new JMenuItem("默认风格 "); m53.addActionListener(this); m54=new JMenuItem("状态栏 "); m54.addActionListener(this); m6=new JMenu("帮助(H)"); m6.setMnemonic('H'); m61=new JMenuItem("帮助主题 "); m61.addActionListener(this); m62=new JMenuItem("关于 "); m62.addActionListener(this); //添加各项 m1.add(m10); m1.add(m11); m1.add(m12); m1.add(m13); m1.addSeparator(); m1.add(m14); m2.add(m21); m2.add(m22); m2.add(m23); m2.add(m24); m2.addSeparator(); m2.add(m25); m2.add(m26); m2.add(m27); m2.add(m271); m2.addSeparator(); m2.add(m28); m2.add(m29); m3.add(m31); m31.add(m311); m31.add(m312); m31.add(m313); m3.add(m32); m32.add(m321); m32.add(m322); m32.add(m323); m32.add(m324); m32.add(m325); m3.add(m33); m3.addSeparator(); m3.add(m34); //m5.add(m51); m5.add(m52); m5.add(m53); m5.addSeparator(); m5.add(m54); m6.add(m61); m6.addSeparator(); m6.add(m62); mb.add(m1); mb.add(m2); mb.add(m3); mb.add(m5); mb.add(m6); this.setJMenuBar(mb); //设置菜单栏 toolbar.add(newf); //工具栏各按钮 newf.setToolTipText("新建"); newf.addActionListener(this); //toolbar.add(open); //open.setToolTipText("打开"); //open.addActionListener(this); //toolbar.add(save); //save.setToolTipText("保存"); //save.addActionListener(this); //toolbar.addSeparator(); toolbar.add(copy); copy.setToolTipText("复制"); copy.addActionListener(this); toolbar.add(cut); cut.setToolTipText("剪切"); cut.addActionListener(this); toolbar.add(pp); pp.setToolTipText("粘贴"); pp.addActionListener(this); //toolbar.add(del); //del.setToolTipText("删除"); //del.addActionListener(this); toolbar.addSeparator(); //toolbar.add(findc); //findc.setToolTipText("查找"); //findc.addActionListener(this); toolbar.add(color); color.setToolTipText("字体颜色"); color.addActionListener(this); toolbar.addSeparator(); //toolbar.add(help); //help.setToolTipText("帮助主题"); //help.addActionListener(this); //toolbar.add(exit); //exit.setToolTipText("退出"); //exit.addActionListener(this); setVisible(true); pack(); show(); this.addWindowListener(new xxx(this)); }///构造函数结束/// ////////////////事件处理///////////////////////////////////// public void actionPerformed(ActionEvent p){ if(p.getActionCommand()=="新建 "||p.getSource()==newf){ //响应菜单及工具栏事件 fname=null; //置文件名为空,便于判断文件是否保存过 txt1.setText(""); state.setText(" 猪猪java记事本------"); } if(p.getActionCommand()=="打开 "||p.getSource()==open){ try { if(this.choose.APPROVE_OPTION==this.choose.showOpenDialog(this)){ path=this.choose.getSelectedFile().getPath(); fname=this.choose.getSelectedFile().getName(); File file=new File(path); int flength=(int)file.length(); FileReader fReader=new FileReader(file); char[] data=new char[flength]; fReader.read(data,0,flength); txt1.setText(new String(data)); state.setText(" 猪猪java记事本------"+path+" 共"+flength+"字节");//状态栏统计文件字节数 txt1.setCaretPosition(0); } }catch(IOException e){} } if(p.getActionCommand()=="保存 "||p.getSource()==save){ if(fname==null){ othersave(); } //如果文件名为空,说明文件未被创建,弹出另存为对话框 try { File savefile=new File(path); savefile.createNewFile(); FileWriter fw=new FileWriter(savefile); fw.write(txt1.getText()); fw.close(); }catch(IOException e){} } if(p.getActionCommand()=="另保存为 "){ othersave(); } if(p.getActionCommand()=="退出 "||p.getSource()==exit){ exit(); } //////////////////编辑//////////////////// if(p.getActionCommand()=="复制 "||p.getSource()==copy) { txt1.copy(); } if(p.getActionCommand()=="剪切 "||p.getSource()==cut) { txt1.cut(); } if(p.getActionCommand()=="粘贴 "||p.getSource()==pp) { txt1.paste(); } if(p.getActionCommand()=="删除 "||p.getSource()==del){ txt1.replaceSelection(""); } /////////////////////////////////////////////////////// if(p.getActionCommand()=="全选 "){ txt1.selectAll(); } if(p.getActionCommand()=="日期/时间 "){ //用DATE类插入当前日期/时间,编译时会出现说明 int inpoint=txt1.getCaretPosition(); Date dt=new Date(); String strdate=dt.toLocaleString(); txt1.insert(strdate,inpoint);} //格式// //////////字体样式//////////////// if(p.getActionCommand()=="正常 "){ newfont=txt1.getFont(); //得到当前应用字体,获得字体大小,创建相应样式 int size=newfont.getSize(); txt1.setFont(new Font("宋体",Font.PLAIN,size)); } if(p.getActionCommand()=="粗体 "){ newfont=txt1.getFont(); int size=newfont.getSize(); txt1.setFont(new Font("宋体",Font.BOLD,size)); } if(p.getActionCommand()=="斜体 "){ newfont=txt1.getFont(); int size=newfont.getSize(); txt1.setFont(new Font("宋体",Font.ITALIC,size)); } ////////////字体大小///////////////// if(p.getActionCommand()=="最大 "){ newfont=txt1.getFont(); ////得到当前应用字体,获得字体样式,创建相应字体的大小 int sty=newfont.getStyle() ; txt1.setFont(new Font("宋体",sty,35)); } if(p.getActionCommand()=="较大 "){ newfont=txt1.getFont(); int sty=newfont.getStyle() ; txt1.setFont(new Font("宋体",sty,30)); } if(p.getActionCommand()=="适中 "){ newfont=txt1.getFont(); int sty=newfont.getStyle() ; txt1.setFont(new Font("宋体",sty,18)); } if(p.getActionCommand()=="较小 "){ newfont=txt1.getFont(); int sty=newfont.getStyle() ; txt1.setFont(new Font("宋体",sty,16)); } if(p.getActionCommand()=="最小 "){ newfont=txt1.getFont(); int sty=newfont.getStyle() ; txt1.setFont(new Font("宋体",sty,14)); } if(p.getActionCommand()=="字体颜色 "||p.getSource()==color){ //字体颜色 JColorChooser jColor=new JColorChooser(); //调用颜色面板,设置前景就可更改字体颜色 Color fcolor=txt1.getForeground(); txt1.setForeground( jColor.showDialog(txt1,"选择字体颜色",fcolor)); } if(p.getActionCommand()=="自动换行 "){ txt1.setLineWrap(true); m34.setEnabled(false);} //if(p.getActionCommand()=="系统风格 ") //不稳定,在不同编译平台下表现不一致 // { } if(p.getActionCommand()=="MOTIF风格 "){ this.dispose(); myfr ww=new myfr("我的javaX记事本"); try { //MOTIF界面 UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); SwingUtilities.updateComponentTreeUI(ww); }catch ( Exception e ) {} } if(p.getActionCommand()=="默认风格 "){ this.dispose(); myfr ww=new myfr("猪猪java记事本"); try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); SwingUtilities.updateComponentTreeUI(ww); }catch ( Exception e ) {} } if(p.getActionCommand()=="状态栏 ") //状态栏的隐藏和显视 {state.setVisible( !(state.isVisible()) );} /////////////////////帮助/////////////////////////////////////////// if(p.getActionCommand()=="帮助主题 "||p.getSource()==help){ myhelp help=new myhelp(); help.setSize(200,240);} if(p.getActionCommand()=="关于 "){ JLabel prompt=new JLabel("欢迎使用我的JAVAX记事本",JLabel.CENTER); JOptionPane.showMessageDialog(null,prompt,"关于我的JAVAX记事本",JOptionPane.INFORMATION_MESSAGE); } } public void othersave() {//另存为方法 if(choose.APPROVE_OPTION==choose.showSaveDialog(this)){ path=choose.getSelectedFile().getPath(); newfiles=new File(path); state.setText(" 猪猪java记事本------"+path); fname=choose.getSelectedFile().getName();; try { newfiles=new File(path); newfiles.createNewFile(); FileWriter fw=new FileWriter(newfiles); fw.write(txt1.getText()); fw.close(); }catch(IOException e){} } } public void notfindmethod(){ //提示查找不到的方法notfindmethod if(!txt1.getSelectedText().equals(findtxt.getText())) { txt1.setCaretPosition(0); //光标返回文件头部 JOptionPane.showMessageDialog(null,"查找不到对应的字符!","查找错误",JOptionPane.ERROR_MESSAGE); m26.setEnabled(false); } } public void exit(){ int value; String[] qq={"返回", "退出"}; value=JOptionPane.showOptionDialog(null, "你确定退出吗?请注意保存文件!", "退出程序?", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE,null, qq, qq[0]); if(value==JOptionPane.YES_OPTION) return; else if(value==JOptionPane.NO_OPTION) { System.exit(0); } } }//主窗口类结束// class xxx extends WindowAdapter{ //关闭窗口XXX类//////////// myfr fx; xxx(myfr fxx) {fx=fxx;} public void windowClosing(WindowEvent e){ JOptionPane.showMessageDialog(null,"欢迎使用本软件!","退出",JOptionPane.INFORMATION_MESSAGE); fx.dispose(); System.exit(0); } } class xxxhelp extends WindowAdapter{ //关闭帮助主题窗口类XXXhelp myhelp fx; xxxhelp(myhelp fxx){ fx=fxx;} public void windowClosing(WindowEvent e){ fx.dispose(); } } class myhelp extends JFrame{ //帮助主题类///////////////// TextArea helparea; myhelp() { super("我的帮助主题"); helparea=new TextArea("",45,25,TextArea.SCROLLBARS_NONE);//创建没有滚动条的帮助窗口 helparea.setText(" "); helparea.append("我的JAVAX记事本是一个用来创建简单的文档的基本的文本编辑器.可用于打开查看TXT文档。"); helparea.append("要编辑文字,请先选定它,然后单击相应菜单上的相关命令。"); helparea.append("鼠标悬停在工具栏上会出现相关提示。本软件在SDK 1.40下编写,"); helparea.append("最好在1.4环境下运行,否则会出现一些小问题,但不影响正常使用……"); setResizable(false); getContentPane().add(helparea); show();pack(); helparea.setFont(new Font("宋体",Font.PLAIN,14)); helparea.setEnabled(false); addWindowListener(new xxxhelp(this)); } } class handlemouse extends MouseAdapter //处理右键弹出菜单类 { myfr fx; handlemouse(myfr fxx){ fx=fxx; } public void mouseReleased(MouseEvent n){ if(n.isPopupTrigger()) fx.popm.show((Component)n.getSource(),n.getX(),n.getY()); } }
图书馆图书管理系统 主窗口: import java.awt.*; import java.awt.event.*; import javax.swing.*; import myClass.swing.*; public class MainWindow extends JFrame implements ActionListener { JPanel panel1;//panel2; Container c; JMenuBar MenuB; JMenu SystemMenu,BookMGRMenu,BorrowBookMenu,ReturnBookMenu, InfoBrowseMenu,UserMGRMenu; JMenuItem UserLoginMenuItem,UserAddMenuItem,UserModifyMenuItem, UserDeleteMenuItem,ExitMenuItem,BookAddMenuItem,BookModifyMenuItem,BookDeleteMenuItem, BorrowBookMenuItem,BorrowInfoMenuItem,ReturnBookMenuItem,ReturnInfoMenuItem, BookListMenuItem,BorrowBookListMenuItem,UserListMenuItem; JLabel titleLabel,AuthorLabel,DateLabel; public MainWindow() { super("图书馆管理系统"); //--系统管理菜单-- MenuB=new JMenuBar(); SystemMenu=new JMenu("系统管理"); UserMGRMenu=new JMenu("用户管理"); UserLoginMenuItem=new JMenuItem("用户登录"); UserAddMenuItem=new JMenuItem("添加用户"); UserModifyMenuItem=new JMenuItem("修改用户"); UserDeleteMenuItem=new JMenuItem("删除用户"); ExitMenuItem=new JMenuItem("退出"); SystemMenu.add(UserLoginMenuItem); UserMGRMenu.add(UserAddMenuItem); UserMGRMenu.add(UserModifyMenuItem); UserMGRMenu.add(UserDeleteMenuItem); SystemMenu.add(UserMGRMenu); SystemMenu.add(ExitMenuItem); UserLoginMenuItem.addActionListener(this); UserAddMenuItem.addActionListener(this); UserModifyMenuItem.addActionListener(this); UserDeleteMenuItem.addActionListener(this); ExitMenuItem.addActionListener(this); MenuB.add(SystemMenu); //---书籍管理菜单-- BookMGRMenu=new JMenu("书籍管理"); BookAddMenuItem=new JMenuItem("添加书籍"); BookModifyMenuItem=new JMenuItem("修改书籍"); BookDeleteMenuItem=new JMenuItem("删除书籍"); BookMGRMenu.add(BookAddMenuItem); BookMGRMenu.add(BookModifyMenuItem); BookMGRMenu.add(BookDeleteMenuItem); BookAddMenuItem.addActionListener(this); BookModifyMenuItem.addActionListener(this); BookDeleteMenuItem.addActionListener(this); MenuB.add(BookMGRMenu); //--借书管理菜单-- BorrowBookMenu=new JMenu("借书管理"); BorrowBookMenuItem=new JMenuItem("书籍出借"); BorrowInfoMenuItem=new JMenuItem("出借信息修改"); BorrowBookMenu.add(BorrowBookMenuItem); BorrowBookMenu.add(BorrowInfoMenuItem); BorrowBookMenuItem.addActionListener(this); BorrowInfoMenuItem.addActionListener(this); MenuB.add(BorrowBookMenu); //--还书管理菜单-- ReturnBookMenu=new JMenu("还书管理"); ReturnBookMenuItem=new JMenuItem("书籍还入"); ReturnInfoMenuItem=new JMenuItem("书籍还入信息修改"); ReturnBookMenu.add(ReturnBookMenuItem); ReturnBookMenu.add(ReturnInfoMenuItem); ReturnBookMenuItem.addActionListener(this); ReturnInfoMenuItem.addActionListener(this); MenuB.add(ReturnBookMenu); //--信息一览菜单-- InfoBrowseMenu=new JMenu("信息一览"); BookListMenuItem=new JMenuItem("书籍列表"); BorrowBookListMenuItem=new JMenuItem("借阅情况表"); UserListMenuItem=new JMenuItem("用户列表"); InfoBrowseMenu.add(BookListMenuItem); InfoBrowseMenu.add(BorrowBookListMenuItem); InfoBrowseMenu.add(UserListMenuItem); BookListMenuItem.addActionListener(this); BorrowBookListMenuItem.addActionListener(this); UserListMenuItem.addActionListener(this); MenuB.add(InfoBrowseMenu); //---------------------------------- setJMenuBar(MenuB); //titleLabel=new JLabel("欢迎使用图书管理系统",JLabel.CENTER); //titleLabel.setFont(new Font("TimesRoman",Font.BOLD,24)); //AuthorLabel=new JLabel("作者:麦密辉",JLabel.RIGHT); //DateLabel=new JLabel("完成时间:04-11-04",JLabel.RIGHT); titleLabel=new JLabel(new ImageIcon(".\\pic.jpg")); c=getContentPane(); c.setLayout(new BorderLayout()); panel1=new JPanel(); panel1.setLayout(new BorderLayout()); //panel2=new JPanel(); //panel2.setLayout(new BorderLayout()); panel1.add(titleLabel,BorderLayout.CENTER); //panel2.add(AuthorLabel,BorderLayout.NORTH); //panel2.add(DateLabel,BorderLayout.SOUTH); c.add(panel1,BorderLayout.CENTER); //c.add(panel2,BorderLayout.SOUTH); setBounds(100,50,400,300); show(); //--设置初始功能:-- UserMGRMenu.setEnabled(false); BookMGRMenu.setEnabled(false); BorrowBookMenu.setEnabled(false); ReturnBookMenu.setEnabled(false); InfoBrowseMenu.setEnabled(false); } //--设置每个菜单点击后出现的窗口和窗口显示的位置-- public void actionPerformed(ActionEvent e) { if(e.getActionCommand()=="用户登录") { UserLogin UserLoginFrame=new UserLogin(this); Dimension FrameSize=UserLoginFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); UserLoginFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); UserLoginFrame.pack(); UserLoginFrame.show(); } else if(e.getActionCommand()=="添加用户") { UserAdd UserAddFrame=new UserAdd(); Dimension FrameSize=UserAddFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); UserAddFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); UserAddFrame.pack(); UserAddFrame.show(); } else if(e.getActionCommand()=="修改用户") { UserModify UserModifyFrame=new UserModify(); Dimension FrameSize=UserModifyFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); UserModifyFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); UserModifyFrame.pack(); UserModifyFrame.show(); } else if(e.getActionCommand()=="删除用户") { UserDelete UserDeleteFrame=new UserDelete(); Dimension FrameSize=UserDeleteFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); UserDeleteFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); UserDeleteFrame.pack(); UserDeleteFrame.show(); } else if(e.getActionCommand()=="添加书籍") { BookAdd BookAddFrame=new BookAdd(); Dimension FrameSize=BookAddFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); BookAddFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); BookAddFrame.pack(); BookAddFrame.show(); } else if(e.getActionCommand()=="修改书籍") { BookModify BookModifyFrame=new BookModify(); Dimension FrameSize=BookModifyFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); BookModifyFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); BookModifyFrame.pack(); BookModifyFrame.show(); } else if(e.getActionCommand()=="删除书籍") { BookDelete BookDeleteFrame=new BookDelete(); Dimension FrameSize=BookDeleteFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); BookDeleteFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); BookDeleteFrame.pack(); BookDeleteFrame.show(); } else if(e.getActionCommand()=="书籍出借") { BorrowBook BorrowBookFrame=new BorrowBook(); Dimension FrameSize=BorrowBookFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); BorrowBookFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); BorrowBookFrame.pack(); BorrowBookFrame.show(); } else if(e.getActionCommand()=="出借信息修改") { BorrowInfo BorrowInfoFrame=new BorrowInfo(); Dimension FrameSize=BorrowInfoFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); BorrowInfoFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); BorrowInfoFrame.pack(); BorrowInfoFrame.show(); } else if(e.getActionCommand()=="书籍还入") { ReturnBook ReturnBookFrame=new ReturnBook(); Dimension FrameSize=ReturnBookFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); ReturnBookFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); ReturnBookFrame.pack(); ReturnBookFrame.show(); } else if(e.getActionCommand()=="书籍还入信息修改") { ReturnInfo ReturnInfoFrame=new ReturnInfo(); Dimension FrameSize=ReturnInfoFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); ReturnInfoFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); ReturnInfoFrame.pack(); ReturnInfoFrame.show(); } else if(e.getActionCommand()=="书籍列表") { BookList BookListFrame=new BookList(); Dimension FrameSize=BookListFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); BookListFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); BookListFrame.pack(); BookListFrame.show(); } else if(e.getActionCommand()=="借阅情况表") { BorrowBookList BorrowBookListFrame=new BorrowBookList(); Dimension FrameSize=BorrowBookListFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); BorrowBookListFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); BorrowBookListFrame.pack(); BorrowBookListFrame.show(); } else if(e.getActionCommand()=="用户列表") { UserList UserListFrame=new UserList(); Dimension FrameSize=UserListFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); UserListFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); UserListFrame.pack(); UserListFrame.show(); } else if(e.getActionCommand()=="退出") { this.dispose(); System.exit(0); } } //--设置登录用户的权限-- public void setEnable(String powerType) { if(powerType.trim().equals("系统管理员")) { UserMGRMenu.setEnabled(true); BookMGRMenu.setEnabled(true); BorrowBookMenu.setEnabled(true); ReturnBookMenu.setEnabled(true); InfoBrowseMenu.setEnabled(true); UserListMenuItem.setEnabled(true); } else if(powerType.trim().equals("书籍管理员")) { UserMGRMenu.setEnabled(false); BookMGRMenu.setEnabled(true); BorrowBookMenu.setEnabled(false); ReturnBookMenu.setEnabled(false); InfoBrowseMenu.setEnabled(true); UserListMenuItem.setEnabled(false); } else if(powerType.trim().equals("借阅管理员")) { UserMGRMenu.setEnabled(false); BookMGRMenu.setEnabled(false); BorrowBookMenu.setEnabled(true); ReturnBookMenu.setEnabled(true); InfoBrowseMenu.setEnabled(true); UserListMenuItem.setEnabled(false); } else if(powerType.trim().equals("else")) { UserMGRMenu.setEnabled(false); BookMGRMenu.setEnabled(false); BorrowBookMenu.setEnabled(false); ReturnBookMenu.setEnabled(false); InfoBrowseMenu.setEnabled(false); } } public static void main(String args[]) { MainWindow mainFrame=new MainWindow(); mainFrame.addWindowListener(new MyWindowListener()); } }

62,629

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧