package jrummikub.view.impl; import java.awt.Color; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; import java.awt.Insets; import javax.swing.BoxLayout; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.border.MatteBorder; import com.sun.org.apache.bcel.internal.generic.DMUL; class SidePanel extends JPanel { RuleInfoPanel ruleInfoPanel; PlayerListPanel playerListPanel; JScrollPane playerListScrollPane; public SidePanel() { setLayout(new GridBagLayout()); setBorder(new MatteBorder(0, 0, 0, 1, Color.BLACK)); GridBagConstraints c = new GridBagConstraints(); ruleInfoPanel = new RuleInfoPanel(); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.fill = GridBagConstraints.BOTH; add(ruleInfoPanel, c); playerListPanel = new PlayerListPanel(); c.gridx = 0; c.gridy = 1; c.weighty = 1; c.weightx = 1; c.fill = GridBagConstraints.BOTH; playerListScrollPane = new JScrollPane(playerListPanel); playerListScrollPane.setViewportBorder(null); add(playerListScrollPane, c); } class RuleInfoPanel extends JPanel { JLabel dummy; public RuleInfoPanel() { setLayout(new GridLayout(1, 1)); setBorder(new MatteBorder(0, 0, 1, 0, Color.GRAY)); dummy = new JLabel( "
All work and no play
makes Jack a dull boy"); dummy.setHorizontalAlignment(JLabel.CENTER); add(dummy); // setPreferredSize(new Dimension(1, 50)); } } class PlayerListItem extends JPanel { JLabel playerName; public PlayerListItem() { setLayout(new GridBagLayout()); setBorder(new MatteBorder(1, 0, 0, 0, Color.GRAY)); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(5, 5, 5, 5); playerName = new JLabel("Horst
> 9000 Steine"); add(playerName, c); } } class PlayerListPanel extends JPanel { JPanel startSpacer; public PlayerListPanel() { setBackground(Color.RED); setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); startSpacer = new JPanel(); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; add(startSpacer, c); c.weighty = 0; c.fill = GridBagConstraints.HORIZONTAL; for (int i = 1; i <= 16; i++) { c.gridx = 0; c.gridy = i; add(new PlayerListItem(), c); } } } }