📄 alert.java
字号:
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.BorderFactory;
import java.awt.Color;
import javax.swing.JLabel;
import java.awt.GridLayout;
import java.awt.FlowLayout;
import javax.swing.BoxLayout;
import java.awt.GridBagLayout;
import javax.swing.JButton;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.SwingConstants;
import java.awt.event.*;
public class Alert extends JFrame implements ActionListener{
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JPanel jPanel = null;
private JButton jb_retry = null;
private JButton jb_cancel = null;
private JPanel jPanel1 = null;
private JLabel jLabel = null;
private boolean bretry=false;
/**
* This is the default constructor
*/
public Alert() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(282, 139);
this.setContentPane(getJContentPane());
this.setTitle("JFrame");
this.setUndecorated(true);
Function.setCenter(this);
this.setAlwaysOnTop(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==jb_retry)
{
bretry=true;
}
else if(e.getSource()==jb_cancel)
{
bretry=false;
}
}
public boolean needRetry()
{
return bretry;
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.setBorder(BorderFactory.createLineBorder(Color.gray, 1));
jContentPane.add(getJPanel(), BorderLayout.SOUTH);
jContentPane.add(getJPanel1(), BorderLayout.CENTER);
}
return jContentPane;
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
gridBagConstraints1.insets = new Insets(5, 0, 5, 5);
gridBagConstraints1.fill = GridBagConstraints.NONE;
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.insets = new Insets(5, 5, 5, 0);
gridBagConstraints.gridy = 0;
jPanel = new JPanel();
jPanel.setLayout(new GridBagLayout());
jPanel.add(getJb_retry(), gridBagConstraints1);
jPanel.add(getJb_cancel(), gridBagConstraints);
}
return jPanel;
}
/**
* This method initializes jb_retry
*
* @return javax.swing.JButton
*/
private JButton getJb_retry() {
if (jb_retry == null) {
jb_retry = new JButton();
jb_retry.setText("重试");
}
return jb_retry;
}
/**
* This method initializes jb_cancel
*
* @return javax.swing.JButton
*/
private JButton getJb_cancel() {
if (jb_cancel == null) {
jb_cancel = new JButton();
jb_cancel.setText("取消");
}
return jb_cancel;
}
/**
* This method initializes jPanel1
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel1() {
if (jPanel1 == null) {
jLabel = new JLabel();
jLabel.setText("发送失败,是否重试?");
jLabel.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel.setHorizontalAlignment(SwingConstants.CENTER);
jPanel1 = new JPanel();
jPanel1.setLayout(new BorderLayout());
jPanel1.add(jLabel, BorderLayout.CENTER);
}
return jPanel1;
}
} // @jve:decl-index=0:visual-constraint="10,10"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -