📄 gmoptiondialog.java
字号:
package siuying.gm.app.gmailer4j.ui;
import java.awt.*;
import javax.swing.*;
import com.Ostermiller.util.Browser;
import com.jgoodies.forms.builder.PanelBuilder;
import com.jgoodies.forms.factories.ButtonBarFactory;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
/**
* <p>Title: G4j</p>
* <p>Description: Gmail API Library for Java</p>
* <p>Copyright: GPL</p>
* <p>Company: siuying.net</p>
* @author siuying
* @version 0.3.7
*/
public class GMOptionDialog extends JDialog {
/* publicly accessable components */
public JTabbedPane tabbedPane = new JTabbedPane();
public JPanel panelGeneral = new JPanel();
public JPanel panelAccount = new JPanel();
public JPanel panelConnection = new JPanel();
public JPanel panelBrowser = new JPanel();
public LAFPanel panelLAF = null;
public JButton btnCancel = new JButton();
public JButton btnOK = new JButton();
public JLabel lblUser = new JLabel();
public JTextField txtUser = new JTextField();
public JLabel lblPassword = new JLabel();
public JPasswordField txtPassword = new JPasswordField();
public JCheckBox chkUseProxy = new JCheckBox();
public JTextField txtPort = new JTextField();
public JLabel lblPort = new JLabel();
public JLabel lblAddress = new JLabel();
public JTextField txtServer = new JTextField();
public JCheckBox chkAutoLogon = new JCheckBox();
public JCheckBox chkAutoMin = new JCheckBox();
public JCheckBox chkCheckMail = new JCheckBox();
public JSpinner spiMinutes = new JSpinner(new SpinnerNumberModel(1,1,1000,1));
public JLabel lblMinutes = new JLabel();
public GMOptionDialog(Frame frame, String title, boolean modal) {
super(frame, title, modal);
try {
panelLAF = new LAFPanel(frame);
jbInit();
validate();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
public GMOptionDialog() {
this(null, "", false);
}
private void jbInit() throws Exception {
//0.Initialize UI components
chkCheckMail.setActionCommand("Check Every");
chkAutoMin.setActionCommand("Start Min");
chkAutoLogon.setActionCommand("Auto Login");
btnCancel.setActionCommand("Option Cancel");
btnCancel.setText("Cancel");
btnOK.setActionCommand("Option OK");
btnOK.setText("OK");
lblUser.setText("User Name: ");
txtUser.setText("Username");
lblPassword.setText("Password: ");
chkUseProxy.setActionCommand("Use HTTP proxy");
txtPassword.setText("");
chkUseProxy.setText("Use HTTP proxy");
txtPort.setText("");
lblPort.setText("Port: ");
lblAddress.setText("Address");
txtServer.setText("");
chkAutoLogon.setText("Auto login after startup");
chkAutoMin.setText("Start minimized");
chkCheckMail.setText("Check gmail every ");
lblMinutes.setText("minutes");
//1. Setup the main panel (tabs, buttons, etc)
JPanel panelButtons = ButtonBarFactory.buildOKCancelBar(btnOK, btnCancel);
FormLayout mainLayout = new FormLayout(
"5dlu,pref,5dlu",
"5dlu,pref,5dlu,pref,5dlu"
);
CellConstraints cc = new CellConstraints();
this.getContentPane().setLayout(mainLayout);
this.getContentPane().add(tabbedPane, cc.xy(2,2));
this.getContentPane().add(panelButtons, cc.xy(2,4));
//2.Setup the 'General' tab
FormLayout generalLayout = new FormLayout(
"10dlu,pref,pref",
"10dlu,pref,5dlu,pref,5dlu,pref,120dlu"//last added to make dialog taller
);
generalLayout.setRowGroups(new int[][]{{2,4,6}});
panelGeneral.setLayout(generalLayout);
panelGeneral.add(chkAutoLogon, cc.xy(2,2));
panelGeneral.add(chkAutoMin, cc.xy(2, 4));
JPanel pCheckMail = new JPanel();
pCheckMail.setLayout(new FlowLayout(FlowLayout.LEFT));
pCheckMail.add(spiMinutes);
pCheckMail.add(lblMinutes);
panelGeneral.add(chkCheckMail, cc.xy(2,6));
panelGeneral.add(pCheckMail, cc.xy(3,6));
tabbedPane.add(panelGeneral, "General");
//3.Setup the 'Acccount' tab
FormLayout accountLayout = new FormLayout(
"right:max(50dlu;p), 5dlu, 30dlu:grow",
"p,5dlu,p,5dlu,p"
);
PanelBuilder accountBuilder = new PanelBuilder(accountLayout);
accountBuilder.setDefaultDialogBorder();
accountBuilder.addLabel("User Name:", cc.xy(1,3));
accountBuilder.add(txtUser, cc.xy(3,3));
accountBuilder.addLabel("Password", cc.xy(1,5));
accountBuilder.add(txtPassword, cc.xy(3,5));
accountBuilder.addSeparator("GMail Logon", cc.xyw(1,1,3));
panelAccount = accountBuilder.getPanel();
tabbedPane.add(panelAccount, "Account");
//4.Setup the 'LaF' tab
tabbedPane.add(panelLAF, "Look and Feel");
//5.Setup the 'Connection'
FormLayout connectionLayout = new FormLayout(
"right:max(50dlu;p),5dlu,40dlu,5dlu,p,5dlu,25dlu,40dlu:grow",
"pref,5dlu,pref,5dlu,pref"
);
PanelBuilder connectionBuilder = new PanelBuilder(connectionLayout);
connectionBuilder.setDefaultDialogBorder();
connectionBuilder.addSeparator("Proxy settings", cc.xyw(1,1,8));
connectionBuilder.add(chkUseProxy, cc.xy(1,3));
connectionBuilder.add(lblAddress, cc.xy(1,5));
connectionBuilder.add(txtServer, cc.xy(3, 5));
connectionBuilder.add(lblPort, cc.xy(5,5));
connectionBuilder.add(txtPort, cc.xy(7,5));
panelConnection = connectionBuilder.getPanel();
tabbedPane.add(panelConnection, "Connection");
panelBrowser = Browser.getDialogPanel(this);
Browser.initPanel();
tabbedPane.add(panelBrowser, "Browser");
this.pack();
this.setResizable(false);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -