📄 state.java
字号:
/**
* Email: taorundong@126.com
*
* @author taorundong
* @version 1.00 07/02/07
*/
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.net.URL;
public class State extends JFrame implements ActionListener{
private
JButton sure = null;
JPanel button = null;
JLabel label = null;
JTextArea text = null;
JPanel slip = null;
String s = null;
URL url = null;
State(String title){
super(title);
button = new JPanel();
sure = new JButton("OK");
label = new JLabel();
text = new JTextArea();
slip = new JPanel(new GridLayout(1,2));
setScreenSize();
setVisible(true);
showSlip();
showButton();
try{
Thread.sleep(2000);
}
catch(Exception e){
e.printStackTrace();
}
}
public void showSlip(){
try{
url = this.getClass().getResource("picture\\2.jpg");
}
catch(Exception e){
e.printStackTrace();
}
label.setIcon(new ImageIcon(this.getToolkit().getImage(url)));
text.setAlignmentY(JTextArea.CENTER_ALIGNMENT);
text.setLineWrap(true);
text.setText("\n\n"+"网络出现问题:您可能还未上网或服务器更新中");
text.setBackground(Color.getHSBColor(100,100,100));
text.setEditable(false);
slip.add(label);
slip.add(text);
slip.validate();
Container con = this.getContentPane();
con.add(slip,"Center");
con.validate();
}
public void showButton(){
FlowLayout flow = new FlowLayout();
flow.setAlignment(FlowLayout.CENTER);
button.setLayout(flow);
button.add(sure);
Container con = this.getContentPane();
con.add(button,"South");
sure.addActionListener(this);
con.validate();
}
public void setString(String temp){
s = temp;
}
public String returnString(){
return s;
}
public void setScreenSize(){
Dimension screen = this.getToolkit().getScreenSize();
this.setBounds((screen.width/2-150),(screen.height/2-100),300,200);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setIconImage(this.getToolkit().getImage("picture\\11.gif"));
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==sure){
this.dispose();
System.exit(0);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -