Vi allego lo screen di quello che ho combinato
http://imageshack.us/f/132/schermatadel20130106183.png/
e anche il codice che ho scritto
codice:
private Opzioni(JFrame mainWindow) {
this.mainWindow = mainWindow;
setName(Names.NOME_FRAME);
setTitle(Names.NOME_FRAME);
setSize(Names.WINDOWS_WHITH, Names.WINDOWS_HEIGH);
labelSfondo = new JLabel();
labelSfondo.setIcon(new ImageIcon(Names.PATH_SFONDO));
labelSfondo.setLayout(new BorderLayout());
labelSfondo.add(createSouthPanel(), BorderLayout.SOUTH);
labelSfondo.add(createEastPanel(), BorderLayout.EAST);
add(labelSfondo);
setLocationRelativeTo(null);
setResizable(false);
}
private JPanel createSouthPanel() {
JPanel panel = new JPanel(new BorderLayout());
okButton = new JButton();
okButton.setIcon(new ImageIcon(Names.PATH_BUTTON_CONFERMA));
okButton.setPressedIcon(new ImageIcon(Names.PATH_BUTTON_CONFERMA));
okButton.setContentAreaFilled(false);
okButton.setBorder(null);
okButton.setToolTipText(Names.TOOLTIP_OKBUTTON_SELECTOR);
okButton.addActionListener(this);
JPanel paneltemp3 = new JPanel();
paneltemp3.setOpaque(false);
paneltemp3.add(okButton);
panel.add(paneltemp3, BorderLayout.SOUTH);
panel.setOpaque(false);
return panel;
}
private JPanel createEastPanel() {
JPanel panel = new JPanel(new GridLayout(3, 2));
JLabel labelLivello = new JLabel(new ImageIcon(Names.PATH_LABEL_LIVELLO));
livello1 = new JButton();
livello1.setIcon(new ImageIcon(Names.PATH_BUTTON_LIVELLOVUOTO));
livello1.setToolTipText(Names.TOOLTIP_LIVELLO1);
livello1.setContentAreaFilled(false);
livello1.setBorder(null);
livello1.addActionListener(this);
livello2 = new JButton();
livello2.setIcon(new ImageIcon(Names.PATH_BUTTON_LIVELLOVUOTO));
livello2.setToolTipText(Names.TOOLTIP_LIVELLO2);
livello2.setContentAreaFilled(false);
livello2.setBorder(null);
livello2.addActionListener(this);
livello3 = new JButton();
livello3.setIcon(new ImageIcon(Names.PATH_BUTTON_LIVELLOVUOTO));
livello3.setToolTipText(Names.TOOLTIP_LIVELLO3);
livello3.setContentAreaFilled(false);
livello3.setBorder(null);
livello3.addActionListener(this);
livello4 = new JButton();
livello4.setIcon(new ImageIcon(Names.PATH_BUTTON_LIVELLOVUOTO));
livello4.setToolTipText(Names.TOOLTIP_LIVELLO4);
livello4.setContentAreaFilled(false);
livello4.setBorder(null);
livello4.addActionListener(this);
livello5 = new JButton();
livello5.setIcon(new ImageIcon(Names.PATH_BUTTON_LIVELLOVUOTO));
livello5.setToolTipText(Names.TOOLTIP_LIVELLO5);
livello5.setContentAreaFilled(false);
livello5.setBorder(null);
livello5.addActionListener(this);
JPanel tmppanel1 = new JPanel();
tmppanel1.setOpaque(false);
tmppanel1.add(livello1);
tmppanel1.add(livello2);
tmppanel1.add(livello3);
tmppanel1.add(livello4);
tmppanel1.add(livello5);
JLabel labelPlayer1 = new JLabel(new ImageIcon(Names.PATH_LABEL_NOMEPLAYER1));
textFieldPlayer1 = new JTextField(nomePlayer1, 20);
JPanel tmppanel2 = new JPanel();
tmppanel2.setOpaque(false);
tmppanel2.add(textFieldPlayer1);
JLabel labelPlayer2 = new JLabel(new ImageIcon(Names.PATH_LABEL_NOMEPLAYER2));
textFieldPlayer2 = new JTextField(nomePlayer2, 20);
JPanel tmppanel3 = new JPanel();
tmppanel3.add(textFieldPlayer2);
tmppanel3.setOpaque(false);
panel.add(labelLivello);
panel.add(tmppanel1);
panel.add(labelPlayer1);
panel.add(tmppanel2);
panel.add(labelPlayer2);
panel.add(tmppanel3);
panel.setOpaque(false);
return panel;
}
vorrei che tutto sia allineato
i pallini vicino la scritta livello, e così via...
però il laoyutmanager gridlayout si auto dimensiona
come posso risolvere?
vorrei far venire tutto centrato a destra