diff --git a/src/main/java/com/sk89q/mclauncher/OptionsDialog.java b/src/main/java/com/sk89q/mclauncher/OptionsDialog.java index 9e81f67..3466462 100644 --- a/src/main/java/com/sk89q/mclauncher/OptionsDialog.java +++ b/src/main/java/com/sk89q/mclauncher/OptionsDialog.java @@ -21,7 +21,6 @@ import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; @@ -48,6 +47,7 @@ import com.sk89q.mclauncher.config.ConfigurationList; import com.sk89q.mclauncher.config.LauncherOptions; import com.sk89q.mclauncher.util.ActionListeners; +import com.sk89q.mclauncher.util.ButtonsPanel; import com.sk89q.mclauncher.util.LinkButton; import com.sk89q.mclauncher.util.SwingHelper; @@ -140,17 +140,22 @@ private void buildUI() { tabs.addTab("Environment", wrap(new EnvironmentOptionsPanel(options.getSettings(), false))); tabs.addTab("Configurations", buildConfigurationsPanel()); - tabs.addTab("About", buildAboutPanel()); container.add(tabs, BorderLayout.CENTER); - JPanel buttonsPanel = new JPanel(); - buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5)); - JButton okButton = new JButton("OK"); - JButton cancelButton = new JButton("Cancel"); + ButtonsPanel buttons = new ButtonsPanel(8, 0, 6, 0); + buttons.button("About...", new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JOptionPane.showMessageDialog( + self, buildAboutPanel(), "About the Launcher", JOptionPane.PLAIN_MESSAGE); + } + }); + buttons.gap(); + JButton okButton = buttons.addButton("OK"); + buttons.spacer(); + JButton cancelButton = buttons.addButton("Cancel"); SwingHelper.equalWidth(okButton, cancelButton); - buttonsPanel.add(okButton); - buttonsPanel.add(cancelButton); - container.add(buttonsPanel, BorderLayout.SOUTH); + container.add(buttons, BorderLayout.SOUTH); okButton.addActionListener(new ActionListener() { @Override @@ -306,13 +311,20 @@ private JPanel buildAboutPanel() { label.setAlignmentX(Component.LEFT_ALIGNMENT); panel.add(label); - LinkButton btn = new LinkButton("http://www.sk89q.com"); + 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(); + 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); @@ -328,7 +340,8 @@ private JPanel buildAboutPanel() { panel.add(Box.createVerticalGlue()); - btn.addActionListener(ActionListeners.openURL(this, "http://www.sk89q.com")); + btn.addActionListener(ActionListeners.openURL( + this, "https://github.com/sk89q/skmclauncher")); // Fetch notices new Thread(new Runnable() { diff --git a/src/main/java/com/sk89q/mclauncher/util/ButtonsPanel.java b/src/main/java/com/sk89q/mclauncher/util/ButtonsPanel.java new file mode 100644 index 0000000..7b85f1f --- /dev/null +++ b/src/main/java/com/sk89q/mclauncher/util/ButtonsPanel.java @@ -0,0 +1,60 @@ +/* + * SK's Minecraft Launcher + * Copyright (C) 2010, 2011 Albert Pham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +package com.sk89q.mclauncher.util; + +import java.awt.event.ActionListener; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JPanel; + +public class ButtonsPanel extends JPanel { + + private static final long serialVersionUID = 8289993126126654728L; + + public ButtonsPanel(int top, int left, int bottom, int right) { + setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); + setBorder(BorderFactory.createEmptyBorder(top, left, bottom, right)); + } + + public ButtonsPanel gap() { + add(Box.createHorizontalGlue()); + return this; + } + + public ButtonsPanel spacer() { + add(Box.createHorizontalStrut(6)); + return this; + } + + public ButtonsPanel button(String title, ActionListener listener) { + JButton button = addButton(title); + button.addActionListener(listener); + return this; + } + + public JButton addButton(String title) { + JButton button = new JButton(title); + add(button); + return button; + } + +}