Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Moved about information into a button + dialog to free up space from …
…a tab.
  • Loading branch information
sk89q committed Jun 11, 2013
1 parent d11168c commit db6856b
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 12 deletions.
37 changes: 25 additions & 12 deletions src/main/java/com/sk89q/mclauncher/OptionsDialog.java
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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() {
Expand Down
60 changes: 60 additions & 0 deletions src/main/java/com/sk89q/mclauncher/util/ButtonsPanel.java
@@ -0,0 +1,60 @@
/*
* SK's Minecraft Launcher
* Copyright (C) 2010, 2011 Albert Pham <http://www.sk89q.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/

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;
}

}

0 comments on commit db6856b

Please sign in to comment.