level 1
万途唯安
楼主
源代码:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
public class Around extends JFrame implements ActionListener{//继承JFrame,实现接口ActionListener
JPanel unit= new JPanel();
JButton key1 = new JButton("添加书籍");
JButton key2 = new JButton("删除书籍");
JButton key3 = new JButton("开始阅读");
JButton keyon = new JButton(new ImageIcon("src\\image\\2.jpg"));
JButton keyclose = new JButton(new ImageIcon("src\\image\\1.jpg"));
void around(){
key1.setHorizontalTextPosition(SwingConstants.CENTER);
key1.setVerticalTextPosition(SwingConstants.BOTTOM);
this.setTitle("弈飞雨TXT阅读管理器");//设置标题
this.setSize(800,600);//设置大小
//this.setFont(Font.BOLD,24);//设置字体
//this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置关闭
this.setLocationRelativeTo(null);//使框架处于屏幕中央
this.setUndecorated(true);//关闭窗体外边框
//this.getContentPane().setLayout(new FlowLayout());//设置流式布局
unit.setLayout(null);//关闭流式布局
key1.setSize(175, 80);
key2.setSize(175, 80);
key3.setSize(175, 80);
keyon.setSize(25, 25);
keyclose.setSize(25, 25);
key1.setLocation(100,400);
key2.setLocation(500,400);
key3.setLocation(300,200);
keyon.setLocation(750, 0);
keyclose.setLocation(775, 0);
key1.addActionListener(this);//为按钮对象注册监听器
keyclose.addActionListener(this);//为close对象注册监听器
keyon.addActionListener(this);//为on对象注册监听器
String art[] = {"是","否","确定"};
JComboBox xia = new JComboBox(art);
xia.setLocation(0, 0);
xia.setLightWeightPopupEnabled(false);
unit.add(xia);
unit.add(key1);
unit.add(key2);
unit.add(key3);
unit.add(keyon);
unit.add(keyclose);
this.add(unit);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
if(key1 == e.getSource()){new Filemain().Fileuser();}//按钮事件:添加
if(keyclose == e.getSource()){System.exit(0);}//按钮事件:关闭
if(keyon == e.getSource()){this.setState(Around.ICONIFIED);}//设置事件:最小化
}
}
由于是多个类,所以单独这个代码无法被执行,运行结果:

如果插入正确应该在左上角有下拉选框,各位大神,求救啊啊啊啊啊啊啊啊!!!
2014年12月10日 10点12分
1
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
public class Around extends JFrame implements ActionListener{//继承JFrame,实现接口ActionListener
JPanel unit= new JPanel();
JButton key1 = new JButton("添加书籍");
JButton key2 = new JButton("删除书籍");
JButton key3 = new JButton("开始阅读");
JButton keyon = new JButton(new ImageIcon("src\\image\\2.jpg"));
JButton keyclose = new JButton(new ImageIcon("src\\image\\1.jpg"));
void around(){
key1.setHorizontalTextPosition(SwingConstants.CENTER);
key1.setVerticalTextPosition(SwingConstants.BOTTOM);
this.setTitle("弈飞雨TXT阅读管理器");//设置标题
this.setSize(800,600);//设置大小
//this.setFont(Font.BOLD,24);//设置字体
//this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置关闭
this.setLocationRelativeTo(null);//使框架处于屏幕中央
this.setUndecorated(true);//关闭窗体外边框
//this.getContentPane().setLayout(new FlowLayout());//设置流式布局
unit.setLayout(null);//关闭流式布局
key1.setSize(175, 80);
key2.setSize(175, 80);
key3.setSize(175, 80);
keyon.setSize(25, 25);
keyclose.setSize(25, 25);
key1.setLocation(100,400);
key2.setLocation(500,400);
key3.setLocation(300,200);
keyon.setLocation(750, 0);
keyclose.setLocation(775, 0);
key1.addActionListener(this);//为按钮对象注册监听器
keyclose.addActionListener(this);//为close对象注册监听器
keyon.addActionListener(this);//为on对象注册监听器
String art[] = {"是","否","确定"};
JComboBox xia = new JComboBox(art);
xia.setLocation(0, 0);
xia.setLightWeightPopupEnabled(false);
unit.add(xia);
unit.add(key1);
unit.add(key2);
unit.add(key3);
unit.add(keyon);
unit.add(keyclose);
this.add(unit);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
if(key1 == e.getSource()){new Filemain().Fileuser();}//按钮事件:添加
if(keyclose == e.getSource()){System.exit(0);}//按钮事件:关闭
if(keyon == e.getSource()){this.setState(Around.ICONIFIED);}//设置事件:最小化
}
}
由于是多个类,所以单独这个代码无法被执行,运行结果:

如果插入正确应该在左上角有下拉选框,各位大神,求救啊啊啊啊啊啊啊啊!!!