Revampled MainFrame layout to improve appearance/usability when the number of tiles is very large or small.

Fixed instantiation where a new MouseListener was used to each tile - now only one is used for all Tiles.
Fixed issue where the MouseListener was being added to each tile twice.
This commit is contained in:
Woody Folsom
2012-04-14 12:02:17 -04:00
parent 9619f9a96d
commit 74b8eb4622
7 changed files with 154 additions and 222 deletions

View File

@@ -1,9 +1,7 @@
package view;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.FlowLayout;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
@@ -73,69 +71,10 @@ public class TileSelectionPanel extends JPanel {
}
private void initLayout() {
GridBagLayout layout = new GridBagLayout();
GridBagConstraints con;
JLabel spacer1 = new JLabel();
JLabel spacer2 = new JLabel();
con = new GridBagConstraints();
con.gridheight = 1;
con.gridwidth = 1;
con.gridx = 0;
con.gridy = 0;
con.weightx = 1;
layout.setConstraints(spacer1, con);
con = new GridBagConstraints();
con.gridheight = 1;
con.gridwidth = 1;
con.gridx = 1;
con.gridy = 0;
con.insets = new Insets(5, 5, 5, 5);
con.weightx = 0;
layout.setConstraints(blue, con);
con = new GridBagConstraints();
con.gridheight = 1;
con.gridwidth = 1;
con.gridx = 2;
con.gridy = 0;
con.insets = new Insets(5, 5, 5, 5);
con.weightx = 0;
layout.setConstraints(green, con);
con = new GridBagConstraints();
con.gridheight = 1;
con.gridwidth = 1;
con.gridx = 3;
con.gridy = 0;
con.insets = new Insets(5, 5, 5, 5);
con.weightx = 0;
layout.setConstraints(red, con);
con = new GridBagConstraints();
con.gridheight = 1;
con.gridwidth = 1;
con.gridx = 4;
con.gridy = 0;
con.insets = new Insets(5, 5, 5, 5);
con.weightx = 0;
layout.setConstraints(yellow, con);
con = new GridBagConstraints();
con.gridheight = 1;
con.gridwidth = 1;
con.gridx = 5;
con.gridy = 0;
con.weightx = 1;
layout.setConstraints(spacer2, con);
setLayout(layout);
add(spacer1);
setLayout(new FlowLayout());
add(blue);
add(green);
add(red);
add(yellow);
add(spacer2);
}
}