入口类Entry.java
public class Entry {
public static void main(String[] args) {
MyFrame myFrame=new MyFrame();
}
}
窗口类MyFrame.java
public class MyFrame extends JFrame{
Filter mf;
public MyFrame() {
// TODO Auto-generated constructor stub
init();//初始化
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
MyPanel pdown=new MyPanel();
pdown.setMedianR(1);
this.add(pdown);
}
private void init() {
// TODO Auto-generated method stub
this.setTitle("中值滤波器");
this.setSize(1000,1000);
this.setVisible(true);
}
}
面板类MyPanel.java
public class MyPanel extends Panel{
private static final ImageObserver myFrame = null;
Filter mf;
private boolean flag_load=false;
private int r=1;
public void setMedianR(int r) {
this.r = r;
}
Button load,median,k_mean,save,quit;//装载,中值,保存,退出
JTextField rText;
MyPanel(){
this.setBackground(Color.lightGray);
load=new Button("装载图像");
median=new Button("中值滤波");
k_mean=new Button("K-均值");
save=new Button("保存");
quit=new Button("退出");
//添加按钮
this.add(load);
this.add(median);
this.add(k_mean);
this.add(save);
this.add(quit);
//按钮的动作程序 装载图像
load.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
try {
jLoad_ActionPerformed(e);
} catch (IOException e1) {
e1.printStackTrace();
}
}
});
//按钮的动作程序 中值滤波
median.