谁能帮我做一个java的小程序 不是很复杂的那种 类似调色板那种

要求:有一定的实际应用意义,有一定的功能要求。最好能写下结构分析,设计总结。马上要交了 求大侠相助

我这里有一个程序,是读文件和用调色板设置背景色的程序,你看看如何。
import java.awt.*;

import javax.swing.*;
import javax.swing.colorchooser.ColorSelectionModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import java.io.*;
import java.awt.event.*;
public class Test11 extends JFrame{
//添加一个颜色对话框窗口
JFrame color=new JFrame();
JDialog color_diglog=new JDialog(color,"颜色",true);
Container contentpane=this.getContentPane();
JTextArea text=new JTextArea();//文本域
JFileChooser filechooser=new JFileChooser();//文件选择器
JColorChooser colorchooser=new JColorChooser();//颜色选择器
ColorSelectionModel model=colorchooser.getSelectionModel();//用以获取颜色模型
//创建菜单栏
JMenuBar menubar=new JMenuBar();
JMenu F_menu=new JMenu("文件(F)"),
C_menu=new JMenu("颜色(C)");
JMenuItem FC=new JMenuItem("打开(文件选择器)"),
CC=new JMenuItem("颜色(颜色选择器)");
public Test11(){
super("简单文本编辑器");//调用父类(JFrame)的构造方法
contentpane.setLayout(new BorderLayout());
text.setLineWrap(true);
F_menu.add(FC);
C_menu.add(CC);
menubar.add(F_menu);
menubar.add(C_menu);
contentpane.add(menubar,"North");
contentpane.add(text);

color_diglog.add(colorchooser);
color_diglog.setSize(300, 400);
fileshow();//事件监听器类
}
public void fileshow(){
//文件查看器
FC.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
int result=filechooser.showOpenDialog(null);
File file=filechooser.getSelectedFile();
if(file!=null&&result==JFileChooser.APPROVE_OPTION){
try {//将读出的文件赋给text,text用read方法读出
FileReader fr=new FileReader(file.getPath());
text.read(fr,null);
fr.close();
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e2) {
e2.printStackTrace();
}
}

}
});
//颜色查看器
CC.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
color_diglog.setLocationRelativeTo(Test11.this);//在color_dialog中显示颜色选择器
model.addChangeListener(new ChangeListener(){
public void stateChanged(ChangeEvent e){
text.setBackground(colorchooser.getColor());//将文本域的背景色改变为获取的颜色
}
});
color_diglog.setVisible(true);
}
});
}
public static void main(String[] args) {
JFrame f=new Test11();
f.setBounds(300,300,300,300);
f.setVisible(true);
f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
f.setDefaultLookAndFeelDecorated(true);
f.addWindowListener(new WindowAdapter(){
public void windowClosed(WindowEvent e){
System.exit(0);
}
});
}

}追问

那个TEST11那有问题哈 不过谢谢你啦,能QQ上帮一下吗 我的是451042440

温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-10-23
开玩笑的吧,这还不复杂,你不是本专业的吧
相似回答