?? main_frame.java
字號:
package user_interface;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JToggleButton;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Point2D;
import javax.swing.*;
import java.util.*;
public class Main_Frame extends JFrame{
private JFrame parentWin;
public Main_Frame() {
super("Welcome to ASRS");
setSize(Constant.frameWidth, Constant.frameHeight);
//set the background
((JPanel)this.getContentPane()).setOpaque(false);
ImageIcon img = new ImageIcon("BG.jpg");
JLabel background = new JLabel(img);
this.getLayeredPane().add(background, new Integer(Integer.MIN_VALUE));
background.setBounds(0, 0, img.getIconWidth(),img.getIconHeight());
setVisible(true);
addButton();
repaint();
}
public void paint(Graphics g) {
super.paint(g);
//g.setColor(Color.gray);
}
public void addButton() {
final JLabel label = new JLabel();
JToggleButton jb=new JToggleButton();
jb.setText("Inventory Check");
jb.setBounds(new Rectangle(Constant.frameWidth/2-Constant.boxWidth/2, Constant.frameHeight/2-Constant.boxHeight/2, Constant.boxWidth,
Constant.boxHeight));
jb.setToolTipText("Check inventory in selected way.");
parentWin=this;
this.getContentPane().add(jb);
this.getContentPane().add(label);
jb.setVisible(true);
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event){
InvCheck invcheck=new InvCheck();
}}
);
JToggleButton jbb=new JToggleButton();
jbb.setText("Inventory I/O");
jbb.setBounds(new Rectangle(Constant.frameWidth/2-Constant.boxWidth/2, Constant.frameHeight/2+Constant.buttonClearance+Constant.boxHeight/2, Constant.boxWidth,
Constant.boxHeight));
jbb.setToolTipText("Deposit or retrieve freight from inventory.");
this.getContentPane().add(jbb);
this.getContentPane().add(label);
jbb.setVisible(true);
jbb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event){
String information=JOptionPane.showInputDialog("To see next brance!Y/N?");
label.setText(information);
}}
);
// Button Back
JToggleButton jbbb=new JToggleButton();
jbbb.setText("Quit");
jbbb.setBounds(new Rectangle(Constant.frameWidth/2-Constant.boxWidth/2, Constant.frameHeight/2+Constant.boxHeight/2*3+2*Constant.buttonClearance, Constant.boxWidth,
Constant.boxHeight));
jbbb.setToolTipText("Back.");
this.getContentPane().add(jbbb);
jbbb.setVisible(true);
jbbb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event){
parentWin.dispose();
}}
);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Main_Frame trytry=new Main_Frame();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -