Search in sources :

Example 1 with LinkButton

use of com.sk89q.mclauncher.util.LinkButton in project SKMCLauncher by SKCraft.

the class OptionsDialog method buildAboutPanel.

/**
 * Build the about panel.
 *
 * @return panel
 */
private JPanel buildAboutPanel() {
    JPanel panel = new JPanel();
    panel.setOpaque(false);
    panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    JLabel label;
    label = new JLabel("SK's Minecraft Launcher");
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel.add(label);
    label = new JLabel("Version " + Launcher.VERSION);
    label.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel.add(label);
    LinkButton btn = new LinkButton("https://github.com/sk89q/skmclauncher");
    btn.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel.add(btn);
    panel.add(Box.createVerticalStrut(20));
    final JTextArea text = new JTextArea() {

        private static final long serialVersionUID = -1743545646109139950L;

        @Override
        public Dimension getPreferredSize() {
            return new Dimension(300, super.getPreferredSize().height);
        }
    };
    text.setEditable(false);
    text.setWrapStyleWord(true);
    text.setLineWrap(true);
    text.setFont(label.getFont());
    DefaultCaret caret = (DefaultCaret) text.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    JScrollPane scroll = new JScrollPane(text);
    scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll.setAlignmentX(Component.LEFT_ALIGNMENT);
    scroll.setPreferredSize(new Dimension(text.getPreferredSize().width, 200));
    panel.add(scroll);
    panel.add(Box.createVerticalGlue());
    btn.addActionListener(ActionListeners.openURL(this, "https://github.com/sk89q/skmclauncher"));
    // Fetch notices
    new Thread(new Runnable() {

        @Override
        public void run() {
            final String notices = Launcher.getNotices();
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    text.setText(notices);
                }
            });
        }
    }).start();
    return panel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) JTextArea(javax.swing.JTextArea) DefaultCaret(javax.swing.text.DefaultCaret) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) LinkButton(com.sk89q.mclauncher.util.LinkButton)

Example 2 with LinkButton

use of com.sk89q.mclauncher.util.LinkButton in project SKMCLauncher by SKCraft.

the class InstallFromURLDialog method buildUI.

/**
 * Build the UI.
 */
private void buildUI() {
    JPanel container = new JPanel();
    container.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12));
    container.setLayout(new BorderLayout(3, 3));
    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    GridBagConstraints fieldConstraints = new GridBagConstraints();
    fieldConstraints.fill = GridBagConstraints.HORIZONTAL;
    fieldConstraints.weightx = 1.0;
    fieldConstraints.gridwidth = GridBagConstraints.REMAINDER;
    fieldConstraints.insets = new Insets(2, 1, 2, 1);
    GridBagConstraints labelConstraints = (GridBagConstraints) fieldConstraints.clone();
    labelConstraints.weightx = 0.0;
    labelConstraints.gridwidth = 1;
    labelConstraints.insets = new Insets(1, 1, 1, 10);
    GridBagConstraints fullFieldConstraints = (GridBagConstraints) fieldConstraints.clone();
    fullFieldConstraints.insets = new Insets(5, 2, 1, 2);
    JLabel urlLabel = new JLabel("URL to Install:");
    panel.add(urlLabel, labelConstraints);
    urlText = new JTextField(getURLFromClipboard());
    urlText.selectAll();
    urlText.setPreferredSize(new Dimension(300, (int) urlText.getPreferredSize().getHeight()));
    panel.add(urlText, fullFieldConstraints);
    container.add(panel, BorderLayout.CENTER);
    JLabel infoLabel = new JLabel("<html>Copy and paste the URL that you have been given in order to install the mod pack.");
    container.add(infoLabel, BorderLayout.NORTH);
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setBorder(BorderFactory.createEmptyBorder(16, 0, 0, 0));
    buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.LINE_AXIS));
    LinkButton createButton = new LinkButton("Build your own package...");
    JButton okBtn = new JButton("Install");
    JButton cancelBtn = new JButton("Cancel");
    cancelBtn.setPreferredSize(new Dimension(70, (int) cancelBtn.getPreferredSize().getHeight()));
    okBtn.setPreferredSize(cancelBtn.getPreferredSize());
    buttonsPanel.add(createButton);
    buttonsPanel.add(Box.createHorizontalGlue());
    buttonsPanel.add(okBtn);
    buttonsPanel.add(Box.createHorizontalStrut(6));
    buttonsPanel.add(cancelBtn);
    container.add(buttonsPanel, BorderLayout.SOUTH);
    createButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            openBuilder();
        }
    });
    okBtn.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            String text = urlText.getText();
            if (!text.isEmpty()) {
                startInstall(text);
            }
        // Need error dialog
        }
    });
    cancelBtn.addActionListener(ActionListeners.dipose(this));
    urlText.requestFocus();
    add(container, BorderLayout.CENTER);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) LinkButton(com.sk89q.mclauncher.util.LinkButton) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener)

Example 3 with LinkButton

use of com.sk89q.mclauncher.util.LinkButton 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);
        }
    });
}
Also used : JPanel(javax.swing.JPanel) MouseEvent(java.awt.event.MouseEvent) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) KeyAdapter(java.awt.event.KeyAdapter) JLabel(javax.swing.JLabel) LinkButton(com.sk89q.mclauncher.util.LinkButton) JCheckBox(javax.swing.JCheckBox) KeyEvent(java.awt.event.KeyEvent) PopupMouseAdapter(com.sk89q.mclauncher.util.PopupMouseAdapter) ActionListener(java.awt.event.ActionListener) JPasswordField(javax.swing.JPasswordField)

Example 4 with LinkButton

use of com.sk89q.mclauncher.util.LinkButton in project SKMCLauncher by SKCraft.

the class UpdateBuilderGUI method addComponents.

private void addComponents() {
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    panel.setLayout(new GridBagLayout());
    GridBagConstraints fieldConstraints = new GridBagConstraints();
    fieldConstraints.fill = GridBagConstraints.HORIZONTAL;
    fieldConstraints.weightx = 1.0;
    fieldConstraints.gridwidth = GridBagConstraints.REMAINDER;
    fieldConstraints.insets = new Insets(2, 1, 2, 1);
    GridBagConstraints labelConstraints = (GridBagConstraints) fieldConstraints.clone();
    labelConstraints.weightx = 0.0;
    labelConstraints.gridwidth = 1;
    labelConstraints.insets = new Insets(1, 1, 1, 10);
    GridBagConstraints fullFieldConstraints = (GridBagConstraints) fieldConstraints.clone();
    fullFieldConstraints.insets = new Insets(5, 2, 1, 2);
    final JLabel buildConfigLabel = new JLabel("Build configuration:");
    panel.add(buildConfigLabel, labelConstraints);
    configField = new FileField("Select builder configuration", "Builder configuration");
    buildConfigLabel.setLabelFor(configField);
    panel.add(configField, fieldConstraints);
    configField.setVisible(false);
    buildConfigLabel.setVisible(false);
    final JButton useConfigBtn = new JButton("Use Builder Configuration");
    final JPanel useConfigPanel = new JPanel();
    useConfigPanel.add(new JLabel("Have a configuration file? "));
    useConfigPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
    useConfigPanel.add(useConfigBtn);
    useConfigBtn.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            buildConfigLabel.setVisible(true);
            configField.setVisible(true);
            useConfigPanel.setVisible(false);
        }
    });
    panel.add(useConfigPanel, fullFieldConstraints);
    panel.add(Box.createVerticalStrut(3), fullFieldConstraints);
    JLabel label;
    label = new JLabel("Package ID:");
    panel.add(label, labelConstraints);
    idText = new JTextField();
    idText.setText("my-mod-pack");
    label.setLabelFor(idText);
    panel.add(idText, fieldConstraints);
    label = new JLabel("Package name:");
    panel.add(label, labelConstraints);
    nameText = new JTextField();
    nameText.setText("My Mod Pack");
    label.setLabelFor(nameText);
    panel.add(nameText, fieldConstraints);
    label = new JLabel("Version:");
    panel.add(label, labelConstraints);
    versionText = new JTextField();
    versionText.setText(new Date().toString());
    label.setLabelFor(versionText);
    panel.add(versionText, fieldConstraints);
    label = new JLabel("Source directory:");
    panel.add(label, labelConstraints);
    sourceField = new DirectoryField();
    label.setLabelFor(sourceField);
    panel.add(sourceField, fieldConstraints);
    panel.add(Box.createGlue(), labelConstraints);
    includeLibsCheck = new JCheckBox("Add Mojang's LWJGL into package");
    includeLibsCheck.setBorder(null);
    includeLibsCheck.setSelected(true);
    panel.add(includeLibsCheck, fieldConstraints);
    panel.add(Box.createGlue(), labelConstraints);
    zipConfigsCheck = new JCheckBox("Put files from config/ into one .zip");
    zipConfigsCheck.setBorder(null);
    zipConfigsCheck.setSelected(true);
    panel.add(zipConfigsCheck, fieldConstraints);
    label = new JLabel("Output directory:");
    panel.add(label, labelConstraints);
    outputField = new DirectoryField();
    label.setLabelFor(outputField);
    panel.add(outputField, fieldConstraints);
    panel.add(Box.createGlue(), labelConstraints);
    cleanCheck = new JCheckBox("Delete everything in the output directory first");
    cleanCheck.setBorder(null);
    cleanCheck.setSelected(true);
    panel.add(cleanCheck, fieldConstraints);
    label = new JLabel("Package filename:");
    panel.add(label, labelConstraints);
    packageText = new JTextField();
    packageText.setText("package.xml");
    label.setLabelFor(packageText);
    panel.add(packageText, fieldConstraints);
    label = new JLabel("Update filename:");
    panel.add(label, labelConstraints);
    updateText = new JTextField();
    updateText.setText("update.xml");
    label.setLabelFor(updateText);
    panel.add(updateText, fieldConstraints);
    add(panel, BorderLayout.NORTH);
    add(messageLog, BorderLayout.CENTER);
    Box buttonsPanel = Box.createHorizontalBox();
    buttonsPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    LinkButton helpButton = new LinkButton("Help! What do I do?");
    buildButton = new JButton("Build Package...");
    JButton closeButton = new JButton("Close");
    buttonsPanel.add(helpButton);
    buttonsPanel.add(Box.createHorizontalGlue());
    buttonsPanel.add(buildButton);
    buttonsPanel.add(Box.createHorizontalStrut(6));
    buttonsPanel.add(closeButton);
    add(buttonsPanel, BorderLayout.SOUTH);
    helpButton.addActionListener(ActionListeners.openURL(this, "https://github.com/sk89q/skmclauncher/blob/master/README.md"));
    buildButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            build();
        }
    });
    closeButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            close();
        }
    });
    SwingHelper.focusLater(idText);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) FileField(com.sk89q.mclauncher.util.FileField) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) JTextField(javax.swing.JTextField) Date(java.util.Date) LinkButton(com.sk89q.mclauncher.util.LinkButton) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) DirectoryField(com.sk89q.mclauncher.util.DirectoryField)

Aggregations

LinkButton (com.sk89q.mclauncher.util.LinkButton)4 JLabel (javax.swing.JLabel)4 JPanel (javax.swing.JPanel)4 GridBagLayout (java.awt.GridBagLayout)3 ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 BoxLayout (javax.swing.BoxLayout)3 Dimension (java.awt.Dimension)2 GridBagConstraints (java.awt.GridBagConstraints)2 Insets (java.awt.Insets)2 JButton (javax.swing.JButton)2 JCheckBox (javax.swing.JCheckBox)2 JTextField (javax.swing.JTextField)2 DirectoryField (com.sk89q.mclauncher.util.DirectoryField)1 FileField (com.sk89q.mclauncher.util.FileField)1 PopupMouseAdapter (com.sk89q.mclauncher.util.PopupMouseAdapter)1 BorderLayout (java.awt.BorderLayout)1 FlowLayout (java.awt.FlowLayout)1 KeyAdapter (java.awt.event.KeyAdapter)1 KeyEvent (java.awt.event.KeyEvent)1