电子商务java平台代码 java 电商( 五 )


if(num2==JFileChooser.APPROVE_OPTION){
f2=jfc2.getSelectedFile();
this.setTitle(f2.getName());
try{
FileWriter fw = new FileWriter(f2);
BufferedWriter bw = new BufferedWriter(fw);
bw.write(jta.getText());
bw.close();
fw.close();
}catch(IOException e2){
e2.printStackTrace();
}
}
}
if(e.getSource()==jmi4){
int a = JOptionPane.showConfirmDialog(this,"文件已被改变,是否要保存?","提示",JOptionPane.YES_NO_CANCEL_OPTION);
if(a==1){
this.dispose();
}else if(a==0){
File f2 = null;
JFileChooser jfc2 = new JFileChooser();
int num2 = jfc2.showSaveDialog(this);
if(num2==JFileChooser.APPROVE_OPTION){
f2=jfc2.getSelectedFile();
this.setTitle(f2.getName());
try{
FileWriter fw = new FileWriter(f2);
BufferedWriter bw = new BufferedWriter(fw);
bw.write(jta.getText());
bw.close();
fw.close();
}catch(IOException e2){
e2.printStackTrace();
}
this.dispose();
}
}
}
if(e.getSource()==jmi12){
Calendar c1 =Calendar.getInstance();
int y = c1.get(Calendar.YEAR);
int m = c1.get(Calendar.MONTH);
int d = c1.get(Calendar.DATE);
int h = c1.get(Calendar.HOUR);
int m1 = c1.get(Calendar.MINUTE);
int m2 = m+1;
jta.setText(y+"年"+m2+"月"+d+"日"+h+":"+m1);
}
if(e.getSource()==jmi11){
Color ccc = JColorChooser.showDialog(this,"color",Color.BLACK);
jta.setSelectedTextColor(ccc);
jta.setBackground(ccc);
}
if(e.getSource()==jmi10){
jta.replaceRange("",jta.getSelectionStart(),jta.getSelectionEnd());
}
}
public void itemStateChanged(ItemEvent e2){
if(e2.getItemSelectable()==jcbmi){
jta.setLineWrap(true);
}else
jta.setLineWrap(false);
}
public static void main(String[] args){
new NoteBook();
}
public void windowOpened(WindowEvent arg0) {
}
public void windowClosing(WindowEvent arg0) {
int a = JOptionPane.showConfirmDialog(this,"文件已被改变,是否要保存?","提示",JOptionPane.YES_NO_CANCEL_OPTION);
if(a==1){
this.dispose();
}else if(a==0){
File f2 = null;
JFileChooser jfc2 = new JFileChooser();
int num2 = jfc2.showSaveDialog(this);
if(num2==JFileChooser.APPROVE_OPTION){
f2=jfc2.getSelectedFile();
this.setTitle(f2.getName());
try{
FileWriter fw = new FileWriter(f2);
BufferedWriter bw = new BufferedWriter(fw);
bw.write(jta.getText());
bw.close();
fw.close();
}catch(IOException e2){
e2.printStackTrace();
}
}
if(a==2){
////????/????????????????????????????????????????????????????????????????//
}
}
}
public void windowClosed(WindowEvent arg0) {
}
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseClicked(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
}
帮我看一下,我的java代码 。为什么运行结果不对!如图:请详解,为什么其他组件没有显示?看注释:

推荐阅读