stable state of statusPanel

This commit is contained in:
Akarshit Wal
2015-06-25 12:25:10 +05:30
parent ad748a64fd
commit 54591ff7da
3 changed files with 32 additions and 22 deletions
@@ -50,7 +50,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
private ContributionPanel selectedPanel;
// protected JPanel statusPlaceholder;
private StatusPanel status;
// private StatusPanel status;
private ContributionFilter filter;
// private ContributionListing contribListing;
private ContributionListing contribListing = ContributionListing.getInstance();
@@ -81,7 +81,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
// statusPlaceholder = new JPanel();
// statusPlaceholder.setVisible(false);
status = new StatusPanel();
// status = new StatusPanel(null);
}
@@ -97,7 +97,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
add(entry.getValue(), c);
}
/*
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
@@ -105,7 +105,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
c.gridx = 0;
c.gridy = row++;
c.anchor = GridBagConstraints.NORTH;
add(status, c);
add(status, c);*/
}
@@ -287,10 +287,10 @@ public class ContributionTab {
pane.add(Box.createHorizontalStrut(10), BorderLayout.WEST);
pane.add(Box.createHorizontalStrut(10), BorderLayout.EAST);
status = new StatusPanel();
status = new StatusPanel(450);
// status.setBorder(new EmptyBorder(7, 7, 7, 7));
JPanel statusRestartPane = new JPanel();
/*JPanel statusRestartPane = new JPanel();
statusRestartPane.setLayout(new BorderLayout());
statusRestartPane.setBorder(new EmptyBorder(7, 7, 7, 7));
@@ -302,9 +302,9 @@ public class ContributionTab {
// Adding both of these to EAST shouldn't pose too much of a problem,
// since they can never get added together.
statusRestartPane.add(restartButton, BorderLayout.EAST);
statusRestartPane.add(retryConnectingButton, BorderLayout.EAST);
statusRestartPane.add(retryConnectingButton, BorderLayout.EAST);*/
pane.add(statusRestartPane, BorderLayout.SOUTH);
pane.add(status, BorderLayout.SOUTH);
// status = new StatusPanel();
+24 -14
View File
@@ -28,11 +28,14 @@ import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.LayoutStyle;
import javax.swing.SwingConstants;
class StatusPanel extends JPanel {
final int BUTTON_WIDTH = 20;
JLabel label;
JButton installButton;
JProgressBar installProgressBar;
@@ -40,7 +43,9 @@ class StatusPanel extends JPanel {
JButton upadteButton;
JButton removeButton;
public StatusPanel() {
public StatusPanel(int width) {
final int BUTTON_WIDTH = 20;
label = new JLabel("");
installButton = new JButton("Install");
@@ -48,7 +53,9 @@ class StatusPanel extends JPanel {
upadteLabel = new JLabel("Update to Infinite 1.1");
upadteButton = new JButton("Update");
removeButton = new JButton("Remove");
int labelWidth = width != 0 ? width * 2 / 3 : GroupLayout.PREFERRED_SIZE;
this.setSize(450, 200);
GroupLayout layout = new GroupLayout(this);
this.setLayout(layout);
@@ -57,29 +64,32 @@ class StatusPanel extends JPanel {
layout.setHorizontalGroup(layout
.createSequentialGroup()
.addComponent(label)
.addGroup(layout.createParallelGroup()
.addComponent(installButton, GroupLayout.Alignment.CENTER)
.addComponent(installProgressBar, GroupLayout.Alignment.CENTER)
.addComponent(upadteLabel, GroupLayout.Alignment.CENTER)
.addComponent(upadteButton, GroupLayout.Alignment.CENTER)
.addComponent(removeButton, GroupLayout.Alignment.CENTER)));
.addComponent(label, labelWidth, labelWidth, labelWidth)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,
GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
.addGroup(layout
.createParallelGroup(GroupLayout.Alignment.CENTER)
.addComponent(installButton, BUTTON_WIDTH, BUTTON_WIDTH,
BUTTON_WIDTH).addComponent(installProgressBar)
.addComponent(upadteLabel).addComponent(upadteButton)
.addComponent(removeButton)));
layout.setVerticalGroup(layout
.createParallelGroup()
.addComponent(label)
.addGroup(layout.createSequentialGroup()
.addGroup(layout
.createSequentialGroup()
.addComponent(installButton)
.addGroup(layout.createParallelGroup()
.addComponent(installProgressBar)
.addComponent(upadteLabel))
.addComponent(upadteButton).addComponent(removeButton)));
layout.linkSize(SwingConstants.HORIZONTAL, installButton,
installProgressBar, upadteLabel, upadteButton, removeButton);
layout
.linkSize(SwingConstants.HORIZONTAL, installButton, installProgressBar,
upadteLabel, upadteButton, removeButton);
installProgressBar.setVisible(false);
}
void setMessage(String message) {