java记事本还有“字号”和“字体”还没有完成,求完成
ActionListeneraction=newActionListener(){publicvoidactionPerformed(ActionEvente){Stri...
ActionListener action=new ActionListener(){
public void actionPerformed(ActionEvent e){
String name = e.getActionCommand();
JMenuItem MI=(JMenuItem)e.getSource();
if("新建".equals(name)){
content.setText("");
file=null;
}else if("打开".equals(name)){
if(file !=null)openfile.setSelectedFile(file);
int returnVal=openfile.showOpenDialog(Jab.this);
if(returnVal==JFileChooser.APPROVE_OPTION){
file=openfile.getSelectedFile();
unfold();
}
}else if("保存".equals(name)){
if(file!=null) openfile.setSelectedFile(file);
int returnVal=openfile.showSaveDialog(Jab.this);
if(returnVal==JFileChooser.APPROVE_OPTION){
file=openfile.getSelectedFile();
saving();
}
}else if("退出".equals(name)){
Jab f=new Jab();
int s=JOptionPane.showConfirmDialog(f,"退出?","退出",JOptionPane.YES_NO_OPTION);
if(s==JOptionPane.YES_OPTION)
System.exit(0);
}else if("剪切".equals(name)){
content.cut();
}else if("复制".equals(name)){
content.copy();
}else if("粘贴".equals(name)){
content.paste();
}else if("颜色".equals(name)){
color=JColorChooser.showDialog(Jab.this,"",color);
content.setForeground(color);
}
else if("字号".equals(name)){
}
else if("字型".equals(name)){
}
else if("关于".equals(name)){
about.setSize(300,150);
about.show();
}
}
}; 展开
public void actionPerformed(ActionEvent e){
String name = e.getActionCommand();
JMenuItem MI=(JMenuItem)e.getSource();
if("新建".equals(name)){
content.setText("");
file=null;
}else if("打开".equals(name)){
if(file !=null)openfile.setSelectedFile(file);
int returnVal=openfile.showOpenDialog(Jab.this);
if(returnVal==JFileChooser.APPROVE_OPTION){
file=openfile.getSelectedFile();
unfold();
}
}else if("保存".equals(name)){
if(file!=null) openfile.setSelectedFile(file);
int returnVal=openfile.showSaveDialog(Jab.this);
if(returnVal==JFileChooser.APPROVE_OPTION){
file=openfile.getSelectedFile();
saving();
}
}else if("退出".equals(name)){
Jab f=new Jab();
int s=JOptionPane.showConfirmDialog(f,"退出?","退出",JOptionPane.YES_NO_OPTION);
if(s==JOptionPane.YES_OPTION)
System.exit(0);
}else if("剪切".equals(name)){
content.cut();
}else if("复制".equals(name)){
content.copy();
}else if("粘贴".equals(name)){
content.paste();
}else if("颜色".equals(name)){
color=JColorChooser.showDialog(Jab.this,"",color);
content.setForeground(color);
}
else if("字号".equals(name)){
}
else if("字型".equals(name)){
}
else if("关于".equals(name)){
about.setSize(300,150);
about.show();
}
}
}; 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询