Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
936 connectés 

  FORUM HardWare.fr
  Programmation
  Java

  [Swing] JPanel.set*Size(...) ??

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[Swing] JPanel.set*Size(...) ??

n°880338
cycojesus
Mèo Lười
Posté le 22-10-2004 à 20:25:27  profilanswer
 

Je me remet doucement au Java
 

Code :
  1. import javax.swing.*;
  2. import java.awt.GridLayout;
  3. import java.awt.Dimension;
  4. public class GUI {
  5.     private LevelSet levelSet;
  6.     /* Constructors */
  7.     public GUI( LevelSet lvlst ) {
  8. this.levelSet = lvlst;
  9.     }
  10.     /* Swing stuff */
  11.     private JFrame rootFrame;
  12.     private JPanel rootPanel;
  13.     private JPanel topPanel1;
  14.     private JPanel topPanel2;
  15.     private JPanel drawingPanel;
  16.     private JSlider levelsSlider;
  17.     private JLabel giftsLeftLabel;
  18.     private JLabel movesLabel;
  19.     private JButton restartButton;
  20.     private JButton quitButton;
  21.     private JComboBox levelsetsCombo;
  22.     private JComboBox themesCombo;
  23.     public void createGUI(  ) {
  24. JFrame.setDefaultLookAndFeelDecorated(true);
  25. levelsSlider = new JSlider( 1, levelSet.getNbLevels(  ) );
  26. giftsLeftLabel = new JLabel( "0 gifts left" );
  27. restartButton = new JButton( "restart" );
  28. quitButton = new JButton( "quit" );
  29. levelsetsCombo = new JComboBox(  );
  30. movesLabel = new JLabel( "0 moves so far" );
  31. themesCombo = new JComboBox(  );
  32. topPanel1 = new JPanel(  );
  33.         topPanel1.setMinimumSize( new Dimension( 320, 15 ) );
  34. topPanel1.setMaximumSize( new Dimension( 320, 15 ) );
  35. topPanel1.setPreferredSize( new Dimension( 320, 15 ) );
  36.         topPanel1.setLayout( new GridLayout( 1, 4 ) );
  37. topPanel1.add( levelsSlider );
  38. topPanel1.add( giftsLeftLabel );
  39. topPanel1.add( restartButton );
  40. topPanel1.add( quitButton );
  41. topPanel2 = new JPanel(  );
  42. topPanel2.setLayout( new GridLayout( 1, 3 ) );
  43. topPanel2.add( levelsetsCombo );
  44. topPanel2.add( movesLabel );
  45. topPanel2.add( themesCombo );
  46. drawingPanel = new JPanel(  );
  47. rootPanel = new JPanel(  );
  48. rootPanel.setLayout( new GridLayout( 3, 1 ) );
  49. rootPanel.add( topPanel1 );
  50. rootPanel.add( topPanel2 );
  51. rootPanel.add( drawingPanel );
  52. rootFrame = new JFrame( "JNGStar" );
  53. rootFrame.setSize(320,210);
  54. rootFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  55. rootFrame.setContentPane( rootPanel );
  56. rootFrame.setVisible(true);
  57.     }
  58. }


 
Sauriez-vous pourquoi topPanel1 n'a pas la taille que j'essaye de lui donner (320, 15) ?
 
http://cycojesus.free.fr/files/gkrellShoot_10-22-04_202150.jpg


Message édité par cycojesus le 22-10-2004 à 20:26:17

---------------
Chết rồi ! ✍ ⌥⌘ http://github.com/gwenhael-le-moine/slackbuilds/
mood
Publicité
Posté le 22-10-2004 à 20:25:27  profilanswer
 

n°880371
meumeul
Stay Heavy
Posté le 22-10-2004 à 21:19:45  profilanswer
 

parce que c du gridlayout, ca resize pas je crois

n°880835
cycojesus
Mèo Lười
Posté le 23-10-2004 à 16:14:37  profilanswer
 

:??: Quelqu'un aurait-il une idée de comment je pourrais faire ?


---------------
Chết rồi ! ✍ ⌥⌘ http://github.com/gwenhael-le-moine/slackbuilds/
n°880852
nraynaud
lol
Posté le 23-10-2004 à 16:50:45  profilanswer
 

tu veux faire quoi ? utilise un layoutManager au lieu de pixels. http://java.sun.com/docs/books/tut [...] index.html


---------------
trainoo.com, c'est fini
n°880859
cycojesus
Mèo Lười
Posté le 23-10-2004 à 17:08:27  profilanswer
 

nraynaud a écrit :

tu veux faire quoi ? utilise un layoutManager au lieu de pixels. http://java.sun.com/docs/books/tut [...] index.html

Mon but est de reproduire cet agencement :http://cycojesus.free.fr/faire/coder/jouer/ng-star/images/ngstar_fltk.png
la fenêtre fait (320, 210) et chacune des 2 barres en haut de la fenêtre fait 15 de hauteur


---------------
Chết rồi ! ✍ ⌥⌘ http://github.com/gwenhael-le-moine/slackbuilds/
n°880876
nraynaud
lol
Posté le 23-10-2004 à 17:40:40  profilanswer
 

[:kiki]
bon, allez, fais-la ta bouse, la fonction que tu cherches s'appelle setBounds().


---------------
trainoo.com, c'est fini
n°880890
cycojesus
Mèo Lười
Posté le 23-10-2004 à 18:05:26  profilanswer
 

nraynaud a écrit :

[:kiki]
bon, allez, fais-la ta bouse, la fonction que tu cherches s'appelle setBounds().

ça rends aimable le Java dis-donc  :pfff:  
Merci tout de même :o  
 
Néanmoins je pense être plus proche de ce que je veux avec un GridBagLayout


Message édité par cycojesus le 23-10-2004 à 18:21:25

---------------
Chết rồi ! ✍ ⌥⌘ http://github.com/gwenhael-le-moine/slackbuilds/

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Java

  [Swing] JPanel.set*Size(...) ??

 

Sujets relatifs
[SWT/swing] editeur pythonswing : pb de scrolling sur une JTable
[awt/swing][résolu] listener sur ALT ou CTRL uniquement[Java][Swing] Layout avec component centré non maximisé
[swing] cherche un composant arbre avec des noeuds graphiques[swing] - creation d'element
[swing] modifier un jpanel apres un evenement...Swing, afficher une image en fond de jpanel (code inside)
[Swing][jpanel]Afficher une image dans un jpanelCanvas3D dans un Swing JPanel
Plus de sujets relatifs à : [Swing] JPanel.set*Size(...) ??


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR