use of com.sk89q.mclauncher.util.PopupMouseAdapter in project SKMCLauncher by SKCraft.
the class LaunchOptions method addComponents.
private void addComponents() {
setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
GridBagLayout layout = new GridBagLayout();
setLayout(layout);
final JLabel jarLabel = new JLabel("Active JAR:", SwingConstants.LEFT);
JLabel userLabel = new JLabel("Username:", SwingConstants.LEFT);
JLabel passLabel = new JLabel("Password:", SwingConstants.LEFT);
jarCombo = new JComboBox();
userText = new JComboBox();
userText.setModel(options.getIdentities());
userText.setEditable(true);
passText = new JPasswordField(20);
jarLabel.setLabelFor(jarCombo);
userLabel.setLabelFor(userText);
passLabel.setLabelFor(passText);
layout.setConstraints(jarCombo, fieldC);
layout.setConstraints(userText, fieldC);
layout.setConstraints(passText, fieldC);
rememberPass = new JCheckBox("Remember my password");
rememberPass.setBorder(null);
autoConnectCheck = new JCheckBox("Auto-connect");
autoConnectCheck.setBorder(null);
forceUpdateCheck = new JCheckBox("Force a game update");
forceUpdateCheck.setBorder(null);
changeComponentsCheck = new JCheckBox("Re-select install options (if any)");
changeComponentsCheck.setBorder(null);
playOfflineCheck = new JCheckBox("Play in offline mode");
playOfflineCheck.setBorder(null);
showConsoleCheck = new JCheckBox("Show messages and errors");
showConsoleCheck.setBorder(null);
expandBtn = new LinkButton("More options...");
final JPanel expandContainer = new JPanel();
expandContainer.setLayout(new BoxLayout(expandContainer, BoxLayout.X_AXIS));
expandContainer.setBorder(null);
expandContainer.add(expandBtn);
expandContainer.add(Box.createHorizontalGlue());
add(jarLabel, labelC);
add(jarCombo, fieldC);
add(userLabel, labelC);
add(userText, fieldC);
add(passLabel, labelC);
add(passText, fieldC);
add(rememberPass, checkboxC);
add(autoConnectCheck, checkboxC);
add(forceUpdateCheck, checkboxC);
add(changeComponentsCheck, checkboxC);
add(playOfflineCheck, checkboxC);
add(showConsoleCheck, checkboxC);
add(expandContainer, checkboxC);
autoConnectCheck.setVisible(false);
jarLabel.setVisible(false);
jarCombo.setVisible(false);
forceUpdateCheck.setVisible(false);
changeComponentsCheck.setVisible(false);
showConsoleCheck.setVisible(false);
playOfflineCheck.setVisible(false);
userText.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
loadSavedPassword();
}
});
loadSavedPassword();
userText.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
frame.launch();
}
}
});
userText.getEditor().getEditorComponent().addMouseListener(new PopupMouseAdapter() {
@Override
protected void showPopup(MouseEvent e) {
popupIdentityMenu(e.getComponent(), e.getX(), e.getY());
}
});
passText.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
frame.launch();
}
}
});
playOfflineCheck.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean selected = ((JCheckBox) e.getSource()).isSelected();
userText.setEnabled(!selected);
passText.setEnabled(!selected);
rememberPass.setEnabled(!selected);
}
});
expandBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
expandContainer.setVisible(false);
jarLabel.setVisible(true);
jarCombo.setVisible(true);
forceUpdateCheck.setVisible(true);
changeComponentsCheck.setVisible(true);
showConsoleCheck.setVisible(true);
playOfflineCheck.setVisible(true);
// registerAccount.setVisible(true);
}
});
}
Aggregations