📄 sale.java
字号:
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
class sale implements ActionListener
{
static JFrame f1=null;
public sale(JFrame f){
f1=new JFrame("SALE!!!!!");
Container contentPane=f1.getContentPane();
JPanel buttonPanel=new JPanel();
JLabel pLabel = new JLabel("");
ImageIcon picture = new ImageIcon("2.jpg");
pLabel.setIcon(picture);
//buttonPanel.setLayout(new GridLayout(10,30,30,77));
buttonPanel.setBorder(BorderFactory.createLineBorder(Color.blue,2));
buttonPanel.setLayout(new GridLayout(6,2));
JButton b00=new JButton("softwareSaleDiscount");
b00.addActionListener(this);
buttonPanel.add(b00);
JButton b01=new JButton("softwareSaleDate");
b01.addActionListener(this);
buttonPanel.add(b01);
JButton b10=new JButton("laptopSaleDiscount");
b10.addActionListener(this);
buttonPanel.add(b10);
JButton b11=new JButton("laptopSaleDate");
b11.addActionListener(this);
buttonPanel.add(b11);
JButton b20=new JButton("desktopSaleDiscount");
b20.addActionListener(this);
buttonPanel.add(b20);
JButton b21=new JButton("desktopSaleDate");
b21.addActionListener(this);
buttonPanel.add(b21);
JButton b30=new JButton("hometheaterSaleDiscount");
b30.addActionListener(this);
buttonPanel.add(b30);
JButton b31=new JButton("hometheaterSaleDate");
b31.addActionListener(this);
buttonPanel.add(b31);
JButton b40=new JButton("carstereoSaleDiscount");
b40.addActionListener(this);
buttonPanel.add(b40);
JButton b41=new JButton("carstereoSaleDate");
b41.addActionListener(this);
buttonPanel.add(b41);
JButton b5=new JButton("Quit");
b5.addActionListener(this);
buttonPanel.add(b5);
contentPane.add(pLabel,BorderLayout.SOUTH);
contentPane.add(buttonPanel,BorderLayout.NORTH);
f1.pack();
f1.setVisible(true);
f1.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e){
String cmd=e.getActionCommand();
if(cmd.equals("softwareSaleDiscount")){
software A=new software();
A.setSaleDiscount();
}
else if(cmd.equals("laptopSaleDiscount")){
laptop A=new laptop();
A.setSaleDiscount();
}
else if(cmd.equals("desktopSaleDiscount")){
desktop A=new desktop();
A.setSaleDiscount();
}
else if(cmd.equals("hometheaterSaleDiscount")){
hometheater A=new hometheater();
A.setSaleDiscount();
}
else if(cmd.equals("carstereoSaleDiscount")){
carstereo A=new carstereo();
A.setSaleDiscount();
}
if(cmd.equals("softwareSaleDate")){
software A=new software();
A.setSaleDate();
}
else if(cmd.equals("laptopSaleDate")){
laptop A=new laptop();
A.setSaleDate();
}
else if(cmd.equals("desktopSaleSaleDate")){
desktop A=new desktop();
A.setSaleDate();
}
else if(cmd.equals("hometheaterSaleDate")){
hometheater A=new hometheater();
A.setSaleDate();
}
else if(cmd.equals("carstereoSaleDate")){
carstereo A=new carstereo();
A.setSaleDate();
}
else if(cmd.equals("Quit")){
System.exit(0);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -