IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

AWT/Swing Java Discussion :

Redimensionner ma frame


Sujet :

AWT/Swing Java

  1. #1
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2016
    Messages
    95
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Octobre 2016
    Messages : 95
    Points : 56
    Points
    56
    Par défaut Redimensionner ma frame
    Bonjour!

    Bon voilà, j'ai énormément besoin de vous! En effet, j'essaye depuis des mois, ce n'est pas un mensonge à créer une interface graphique qui puisse être redimensionnée dynamiquement. Le problème est que je n'y arrive pas. Je ne comprend pas pourquoi, j'ai essayé tous les Layout possible toujours le même problème.

    Savez vous pourquoi j'y arrive pas ? Esct-ce un problème de Layout ? Si oui, lequel dois-je utiliser ?


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
     
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.GridLayout;
    import java.awt.SystemColor;
     
    import javax.swing.DefaultComboBoxModel;
    import javax.swing.DefaultListModel;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JList;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JSeparator;
    import javax.swing.JSplitPane;
    import javax.swing.JTable;
    import javax.swing.JTextArea;
    import javax.swing.JTextPane;
    import javax.swing.JTree;
    import javax.swing.ListSelectionModel;
    import javax.swing.UIManager;
    import javax.swing.UnsupportedLookAndFeelException;
    import javax.swing.border.EmptyBorder;
    import javax.swing.border.LineBorder;
     
    import net.miginfocom.swing.MigLayout;
    import javax.swing.GroupLayout;
    import javax.swing.GroupLayout.Alignment;
    import java.awt.Insets;
    import java.awt.BorderLayout;
    import javax.swing.BoxLayout;
     
     
    public class myFrame extends JFrame {
     
    	/**
             * Paramètres
             */
    	//Classe
    	private static final long serialVersionUID = 1L;					
     
     
    	//Composantes de l'IHM
    	private JPanel contentPane;	
    	private JTree tree;
    	private DefaultListModel<String> dlmLimSameLvl;
    	private DefaultListModel<String> dlmLimAllLvl;
    	private DefaultListModel<String> dlmApp;
    	private JList<String> list_Applicability;
    	private JList<String> list_LimSameLvl;
    	private JList<String> list_LimAllLvl;
    	private JButton Ope[];
    	private JTextArea EqArea;
    	private DefaultListModel<Object> ModelList;  
    	private JTable table;
     
     
    	 public myFrame() {
     
    setResizable(false);
     
    		setBackground(SystemColor.menu);
    		setTitle("Eq Diversity Generator");    	
    		setAlwaysOnTop(true);
    		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		setBounds(100, 100, 802, 608);
     
    		JMenuBar menuBar = new JMenuBar();
    		setJMenuBar(menuBar);
     
    		JMenuItem mntmMenu = new JMenuItem("Menu");
    		menuBar.add(mntmMenu);
    		contentPane = new JPanel();
    		contentPane.setBackground(new Color(248, 248, 255));
    		contentPane.setBorder(new EmptyBorder(0, 0, 0, 0));
    		setContentPane(contentPane);
    		GridBagConstraints gbc_tabbedPane = new GridBagConstraints();
    		gbc_tabbedPane.fill = GridBagConstraints.VERTICAL;
    		gbc_tabbedPane.gridx = 0;
    		gbc_tabbedPane.gridy = 0;
     
         	dlmApp = new DefaultListModel<String>();
         	dlmLimSameLvl = new DefaultListModel<String>();     	
         	dlmLimAllLvl = new DefaultListModel<String>();     	
     
         	ModelList = new DefaultListModel<>();
     
         	//Main Pannel
    		JPanel mainPanel = new JPanel();
    		mainPanel.setFont(new Font("Tahoma", Font.BOLD, 11));
    		mainPanel.setBorder(new LineBorder(new Color(0, 0, 0), 0));
    		mainPanel.setBackground(Color.WHITE);
         	mainPanel.setLayout(null);
     
         	JPanel workPanel = new JPanel();
         	workPanel.setBounds(0, 0, 796, 546);
         	workPanel.setBackground(new Color(248, 248, 255));
         	mainPanel.add(workPanel);
     
         	JSplitPane splitPane = new JSplitPane();
     
         	JPanel treePanel = new JPanel();
         	splitPane.setLeftComponent(treePanel);
         	treePanel.setBackground(new Color(248, 248, 255));
         	treePanel.setBorder(new LineBorder(SystemColor.menu, 1, true));
         	treePanel.setLayout(new MigLayout("", "[194px,grow]", "[19.00px,fill][grow]"));
     
         	JPanel panel = new JPanel();
         	treePanel.add(panel, "cell 0 0,grow");
         	panel.setLayout(new GridLayout(1, 0, 0, 0));
     
         	//CHOIX PLATEFORME	
         	JLabel lblPlatforms = new JLabel(" Platforms ");
         	panel.add(lblPlatforms);
         	lblPlatforms.setFont(new Font("Tahoma", Font.BOLD, 12));
         	lblPlatforms.setForeground(Color.BLACK);
     
         	JComboBox<String> choicePltfrm = new JComboBox<String>();
         	panel.add(choicePltfrm);
         	choicePltfrm.setBackground(new Color(255, 255, 255));
         	choicePltfrm.setToolTipText("");
         	choicePltfrm.setModel(new DefaultComboBoxModel<String>(new String[]{}));
         	choicePltfrm.addItem("");
         	choicePltfrm.addItem("DicoVariant");
         	choicePltfrm.addItem("Autre");
         	workPanel.setLayout(new BoxLayout(workPanel, BoxLayout.X_AXIS));
     
         	JScrollPane scrollPane = new JScrollPane();
         	treePanel.add(scrollPane, "cell 0 1,grow");
     
         	JTree tree_1 = new JTree();
         	scrollPane.setViewportView(tree_1);
         	tree_1.setBorder(new LineBorder(new Color(0, 0, 0)));
         	tree_1.setBackground(Color.WHITE);
     
    		JPanel EditPanel = new JPanel();
    		EditPanel.setBorder(new LineBorder(new Color(0, 0, 0), 0, true));
    		splitPane.setRightComponent(EditPanel);
    		EditPanel.setBackground(new Color(248, 248, 255));
    		EditPanel.setLayout(new MigLayout("", "[grow,fill]", "[][-5.00][][-5.00][270.00][grow]"));
     
    				JPanel varNamePanel = new JPanel();
    				EditPanel.add(varNamePanel, "cell 0 0,growx");
    				varNamePanel.setLayout(new MigLayout("", "[50px][480px,grow,fill]", "[20px,grow]"));
     
    				JLabel lblVariante = new JLabel("Variante : ");
    				varNamePanel.add(lblVariante, "cell 0 0,alignx left,aligny center");
     
    				JList list = new JList();
    				list.setBorder(new LineBorder(new Color(0, 0, 0)));
    				varNamePanel.add(list, "cell 1 0,grow");
     
    				JSeparator separator = new JSeparator();			
    				EditPanel.add(separator, "cell 0 1");
    				separator.setBackground(Color.BLACK);
    				separator.setForeground(Color.BLACK);
     
    				JPanel applicabilityPanel = new JPanel();
    				EditPanel.add(applicabilityPanel, "cell 0 2");
    				applicabilityPanel.setLayout(new MigLayout("", "[grow]", "[8.00][29.00,fill][24.00,fill][46.00,grow][17.00][58.00]"));
    				JLabel lblApplicability = new JLabel("Applicability");
    				applicabilityPanel.add(lblApplicability, "cell 0 0,aligny bottom");
     
    				JLabel lblVaraianteLimAllLvl = new JLabel("Varaiante limitation(s) for all level");
    				applicabilityPanel.add(lblVaraianteLimAllLvl, "cell 0 4");
    				list_Applicability = new JList<String>(dlmApp);
    				list_Applicability.setBorder(new LineBorder(new Color(0, 0, 0)));
    				applicabilityPanel.add(list_Applicability, "cell 0 1,growx,aligny center");
    				list_Applicability.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    				list_Applicability.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    				list_Applicability.setVisibleRowCount(1);
    				JLabel lblLimitation = new JLabel("Variante limitation(s) in same level");	
    				applicabilityPanel.add(lblLimitation, "cell 0 2,alignx left,aligny bottom");
     
    				JScrollPane scrollPane_3 = new JScrollPane();
    				applicabilityPanel.add(scrollPane_3, "cell 0 3,grow");
    				list_LimSameLvl = new JList<String>(dlmLimSameLvl);
    				list_LimSameLvl.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    				list_LimSameLvl.setVisibleRowCount(1);
    				scrollPane_3.setViewportView(list_LimSameLvl);
    				list_LimSameLvl.setBorder(new LineBorder(new Color(0, 0, 0)));
     
    				JScrollPane scrollPane_4 = new JScrollPane();
    				applicabilityPanel.add(scrollPane_4, "cell 0 5,grow");
    				list_LimAllLvl = new JList<String>(dlmLimAllLvl);
    				list_LimAllLvl.setBorder(new LineBorder(new Color(0, 0, 0)));
    				scrollPane_4.setViewportView(list_LimAllLvl);
     
    				JSeparator separator_1 = new JSeparator();
    				EditPanel.add(separator_1, "cell 0 3");
    				separator_1.setForeground(Color.BLACK);
    				separator_1.setBackground(Color.BLACK);
     
    				//PANEL CHAMPS D'EQUATION
    				JPanel equationPanel = new JPanel();
    				EditPanel.add(equationPanel, "cell 0 4");
    				equationPanel.setLayout(new MigLayout("", "[527.00px,grow][169.00px,grow,fill]", "[15px][225.00px]"));
     
    	   //Label Equation
    				JLabel lblEquation = new JLabel("Equation :");
    				equationPanel.add(lblEquation, "cell 0 0,alignx left,aligny bottom");
    				lblEquation.setFont(new Font("Tahoma", Font.PLAIN, 11));
    				lblEquation.setForeground(Color.BLACK);
     
    				//AFFICHAGE DE L'EQUATION	
    				EqArea = new JTextArea();
    				equationPanel.add(EqArea, "cell 0 1,grow");
    				EqArea.setBorder(new LineBorder(new Color(0, 0, 0)));
    				EqArea.setEnabled(true);					
    				EqArea.setEditable(true);
    				EqArea.setLineWrap(true);
     
    				//PANEL DES BOUTONS REPRESENTANT NOS OPERATEUR 
    				JPanel btnPanel = new JPanel();
    				btnPanel.setForeground(Color.ORANGE);
    				btnPanel.setBackground(SystemColor.menu);
    				equationPanel.add(btnPanel, "cell 1 1,alignx center,aligny center");
    				btnPanel.setLayout(new MigLayout("", "[31.00px][-46.00px]", "[grow][][][][][3.00px][]"));
     
    				JSplitPane splitPane_1 = new JSplitPane();
    				btnPanel.add(splitPane_1, "cell 0 0,grow");
     
    				JButton btnVG = new JButton("(");
    				splitPane_1.setLeftComponent(btnVG);
     
    				JButton btnVD = new JButton(")");
    				splitPane_1.setRightComponent(btnVD);
     
    				JButton btnAND = new JButton("AND");
    				btnAND.setForeground(Color.BLACK);
    				btnPanel.add(btnAND, "cell 0 1,grow");
     
    				JButton btnOR = new JButton("OR");
    				btnPanel.add(btnOR, "cell 0 2,grow");
     
    				JButton button = new JButton("OR");
    				btnPanel.add(button, "cell 0 3,grow");
     
    				JButton btnNOT = new JButton("!");
    				btnPanel.add(btnNOT, "cell 0 4,grow");
     
    				//REST
    				JButton btnReset = new JButton("Reset");		
    				btnPanel.add(btnReset, "cell 0 6,grow");
    				btnReset.setFont(new Font("Tahoma", Font.BOLD, 11));
    				btnReset.setForeground(SystemColor.controlText);
    				btnReset.setBackground(SystemColor.controlDkShadow);
     
    				JLabel lblMsgError = new JLabel("");
    				EditPanel.add(lblMsgError, "cell 0 5");
    				workPanel.add(splitPane);
    		GroupLayout gl_contentPane = new GroupLayout(contentPane);
    		gl_contentPane.setHorizontalGroup(
    			gl_contentPane.createParallelGroup(Alignment.LEADING)
    				.addGroup(gl_contentPane.createSequentialGroup()
    					.addComponent(mainPanel, GroupLayout.PREFERRED_SIZE, 784, GroupLayout.PREFERRED_SIZE)
    					.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    		);
    		gl_contentPane.setVerticalGroup(
    			gl_contentPane.createParallelGroup(Alignment.LEADING)
    				.addGroup(gl_contentPane.createSequentialGroup()
    					.addComponent(mainPanel, GroupLayout.PREFERRED_SIZE, 546, GroupLayout.PREFERRED_SIZE)
    					.addContainerGap(28, Short.MAX_VALUE))
    		);
    		contentPane.setLayout(gl_contentPane);
     
    		//GESTION DES EVENEMENT POUR CHAQUE  BOUTON
    		Ope = new JButton[]{btnOR, btnAND, btnNOT, btnVG, btnVD, btnReset}; 
     
    	    //Ameliore l'IHM
            try {
    			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    		} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) {
    			//TODO Auto-generated catch block
    			e1.printStackTrace();
    		}
     
    	}
    }

    Merci d'avance

  2. #2
    Membre habitué Avatar de Pecose
    Homme Profil pro
    Batiment
    Inscrit en
    Février 2013
    Messages
    310
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Batiment
    Secteur : Bâtiment

    Informations forums :
    Inscription : Février 2013
    Messages : 310
    Points : 194
    Points
    194
    Par défaut
    Bonjour,
    Tu veux redimensionner ta fenêtre mais t'as mis ça:
    Après il suffi de tiré sur les coins de la fenêtre, non?
    Bon courage en tout cas.
    Des jours c'est facile, des jours c'est pas facile, mais c'est jamais le même jour.

  3. #3
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2016
    Messages
    95
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Octobre 2016
    Messages : 95
    Points : 56
    Points
    56
    Par défaut
    Citation Envoyé par Pecose Voir le message
    Bonjour,
    Tu veux redimensionner ta fenêtre mais t'as mis ça:
    Après il suffi de tiré sur les coins de la fenêtre, non?
    Bon courage en tout cas.


    Certes, j'ai mis ça en attendant car lorsque j'autorise le redimensionnement, les composants au sein de ma frame ne se redimensionnent pas dynamiquement.
    Mais j'ai retravaillé ma FRAME. J'utilise maintenant un BoxLayout.

Discussions similaires

  1. IWebBrowser redimensionnement des frames
    Par rayda dans le forum Windows
    Réponses: 0
    Dernier message: 02/01/2008, 18h59
  2. Redimensionnement de frame
    Par Sytchev3 dans le forum Balisage (X)HTML et validation W3C
    Réponses: 1
    Dernier message: 01/11/2007, 11h59
  3. Redimensionner les frames d'un film
    Par fcgabaldo dans le forum MATLAB
    Réponses: 5
    Dernier message: 17/07/2007, 16h11
  4. Redimensionner une frame automatiquement
    Par thomas9501 dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 15/01/2007, 16h36
  5. Redimensionner une Frame et son contenu ?!?
    Par talkhor dans le forum AWT/Swing
    Réponses: 4
    Dernier message: 26/01/2006, 12h28

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo