cycojesus Mèo Lười | Je me remet doucement au Java
Code :
- import javax.swing.*;
- import java.awt.GridLayout;
- import java.awt.Dimension;
- public class GUI {
- private LevelSet levelSet;
- /* Constructors */
- public GUI( LevelSet lvlst ) {
- this.levelSet = lvlst;
- }
- /* Swing stuff */
- private JFrame rootFrame;
- private JPanel rootPanel;
- private JPanel topPanel1;
- private JPanel topPanel2;
- private JPanel drawingPanel;
- private JSlider levelsSlider;
- private JLabel giftsLeftLabel;
- private JLabel movesLabel;
- private JButton restartButton;
- private JButton quitButton;
- private JComboBox levelsetsCombo;
- private JComboBox themesCombo;
- public void createGUI( ) {
- JFrame.setDefaultLookAndFeelDecorated(true);
- levelsSlider = new JSlider( 1, levelSet.getNbLevels( ) );
- giftsLeftLabel = new JLabel( "0 gifts left" );
- restartButton = new JButton( "restart" );
- quitButton = new JButton( "quit" );
- levelsetsCombo = new JComboBox( );
- movesLabel = new JLabel( "0 moves so far" );
- themesCombo = new JComboBox( );
- topPanel1 = new JPanel( );
- topPanel1.setMinimumSize( new Dimension( 320, 15 ) );
- topPanel1.setMaximumSize( new Dimension( 320, 15 ) );
- topPanel1.setPreferredSize( new Dimension( 320, 15 ) );
- topPanel1.setLayout( new GridLayout( 1, 4 ) );
- topPanel1.add( levelsSlider );
- topPanel1.add( giftsLeftLabel );
- topPanel1.add( restartButton );
- topPanel1.add( quitButton );
- topPanel2 = new JPanel( );
- topPanel2.setLayout( new GridLayout( 1, 3 ) );
- topPanel2.add( levelsetsCombo );
- topPanel2.add( movesLabel );
- topPanel2.add( themesCombo );
- drawingPanel = new JPanel( );
- rootPanel = new JPanel( );
- rootPanel.setLayout( new GridLayout( 3, 1 ) );
- rootPanel.add( topPanel1 );
- rootPanel.add( topPanel2 );
- rootPanel.add( drawingPanel );
- rootFrame = new JFrame( "JNGStar" );
- rootFrame.setSize(320,210);
- rootFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- rootFrame.setContentPane( rootPanel );
- rootFrame.setVisible(true);
- }
- }
|
Sauriez-vous pourquoi topPanel1 n'a pas la taille que j'essaye de lui donner (320, 15) ?
Message édité par cycojesus le 22-10-2004 à 20:26:17 ---------------
Chết rồi ! ✍ ⌥⌘ http://github.com/gwenhael-le-moine/slackbuilds/
|