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 :

Disparition de composants


Sujet :

AWT/Swing Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2004
    Messages : 3
    Par défaut Disparition de composants
    Bonjour à tous.

    J'ai un problème quand à l'affichage de mon application. Je m'explique: lorsque je met mon application en arrière-plan et que je la reprend au premier plan, tous les boutons sauf celui qui a le focus disparaissent. Le seul moyen de les revoir est de cliquer (à l'aveuglette) dessus ou redimensionner la fenêtre.



    Note: cela arrive que lorsqu'un graphique est affiché dans le panel du bas. (je réecris la méthode paintComponent() du panel).

    Quelqu'un aurait-il une idée pour me dépanner?

    Je vous remercie d'avance, si vous avez besoin du code il n'y a qu'à demander.

  2. #2
    Membre Expert
    Avatar de Gueritarish
    Homme Profil pro
    Développeur Java
    Inscrit en
    Mai 2007
    Messages
    1 800
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2007
    Messages : 1 800
    Par défaut
    Disparition de Composants : Fais appel à Gérard Majax


    Sinon, plus sérieusement, tu devrais poster un peu de code
    Genre : ta méthode paintComponent(), utilisation de ton appli qui a des bouton disparaissant (super mot )

  3. #3
    Futur Membre du Club
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    3
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Mai 2004
    Messages : 3
    Par défaut
    la méthode Paint Component de mon panel:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    public void paintComponent(Graphics g) {
    		super.paintComponent(g);
     
                     ...
     
    		}
    	}
    la construction de ma frame:

    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
    public class MemoThermMain extends JFrame {
            private JPanel mainPanel = null;
    	private JPanel buttonsPanel = null;
    	private JPanel currentValuesPanel = null;
    	private JPanel optionsPanel = null;
    	private JPanel northPanel = null;
    	private GraphicPanel graphicPanel = null;
    	private JButton butAffichGraph;
    	private JButton butVidMem;
    	private JButton butReglHeure;
    	private JButton butRafraichir;
    	private TitledBorder titBordCurrentValues;
    	private JTextField txtHeureCourante;
    	private JTextField txtTemperatureCourante;
    	private ButtonGroup bgOptions;
    	private JRadioButton rbPointParPoint;
    	private JRadioButton rbSegments;
     
    mainPanel = new JPanel(new BorderLayout());
    		northPanel = new JPanel(new BorderLayout());
    		buttonsPanel = new JPanel(new GridBagLayout());
    		currentValuesPanel = new JPanel(new GridBagLayout());
    		optionsPanel = new JPanel(new GridLayout(2, 1));
    		bgOptions = new ButtonGroup();
    		rbPointParPoint = new JRadioButton("Point par point");
    		rbSegments = new JRadioButton("Segments");
    		titBordCurrentValues = new TitledBorder("Heure et température courante");
    		butAffichGraph = new JButton();
    		butVidMem = new JButton();
    		butReglHeure = new JButton();
    		butRafraichir = new JButton();
    		readValues = new ArrayList();
    		bgOptions.add(rbPointParPoint);
    		bgOptions.add(rbSegments);
    		this.setSize(new Dimension(820, 500));
    		this.setTitle("MemoTherm");
    		this.addWindowListener(new WindowAdapter()
    				{
    			public void windowClosing (WindowEvent e)
    			{
    				closeApplication();
    			}
    				});
    		initMenu();
     
    		//initialisation des objets
    		txtHeureCourante = new JTextField("--:--:--");
    		txtHeureCourante.setColumns(8);
    		txtTemperatureCourante = new JTextField("- °C");
    		txtTemperatureCourante.setColumns(8);
    		txtHeureCourante.setEditable(false);
    		txtTemperatureCourante.setEditable(false);
    		butAffichGraph.setText("Afficher le graphique");
    		butVidMem.setText("Vider la mémoire");
    		butReglHeure.setText("Mettre à l'heure");
    		butRafraichir.setText("Rafraîchir");
    		currentValuesPanel.setBorder(titBordCurrentValues);
    		optionsPanel.add(rbPointParPoint);
    		optionsPanel.add(rbSegments);
    		rbPointParPoint.setSelected(true);
     
    		//placement des objets dans les différents panels
    		currentValuesPanel.add(txtHeureCourante, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
    				GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
    				new Insets(0, 10, 0, 5), 0, 0));
     
    		currentValuesPanel.add(txtTemperatureCourante, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
    				GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
    				new Insets(0, 10, 0, 5), 0, 0));
     
    		currentValuesPanel.add(butRafraichir, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
    				GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
    				new Insets(0, 10, 0, 5), 0, 0));
     
    		buttonsPanel.add(butAffichGraph, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
    				GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
    				new Insets(22, 10, 0, 5), 0, 0));
     
    		buttonsPanel.add(butVidMem, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
    				GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
    				new Insets(22, 5, 0, 5), 0, 0));
     
    		buttonsPanel.add(butReglHeure, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
    				GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
    				new Insets(22, 5, 0, 5), 0, 0));		
     
    		buttonsPanel.add(currentValuesPanel, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0,
    				GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
    				new Insets(5, 5, 5, 5), 0, 0));
     
    		buttonsPanel.add(optionsPanel, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0,
    				GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
    				new Insets(5, 5, 0, 5), 0, 0));
     
    		buttonsPanel.add(Box.createGlue(), new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0,
    				GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
    				new Insets(0, 0, 0, 0), 0, 0));
     
    		//initialisation des boutons
    		initButtons();
     
    		//initialisation du graphicPanel
    		initGraphicPanel();
     
    		northPanel.add(buttonsPanel, BorderLayout.WEST);
    		mainPanel.add(northPanel, BorderLayout.NORTH);
    		mainPanel.add(graphicPanel, BorderLayout.CENTER);
    		this.getContentPane().add(mainPanel);
    	}
    private void initGraphicPanel()
    	{
    		//initilisation de graphicPanel
    		graphicPanel = new GraphicPanel();		
    		graphicPanel.setBackground(Color.WHITE);
    	}
     
    	private void initMenu()
    	{		
    		//initialisation du menu
    		JMenuBar menuBar = new JMenuBar();
    		JMenu jMenuFile = new JMenu();
    		JMenuItem jMenuFileSave = new JMenuItem();
    		JMenuItem jMenuFileOpen = new JMenuItem();
    		JMenuItem jMenuFileExit = new JMenuItem();
     
    		jMenuFile.setText("Fichier");
    		jMenuFileSave.setText("Sauver...");
    		jMenuFileOpen.setText("Ouvrir...");
    		jMenuFileExit.setText("Quitter");
    		jMenuFileSave.addActionListener(new ActionListener()
    				{
    			public void actionPerformed(ActionEvent e)
    			{
    				saveGraphic();
    			}
    				});
    		jMenuFileOpen.addActionListener(new ActionListener()
    				{
    			public void actionPerformed(ActionEvent e)
    			{
    				openGraphic();
    			}
    				});
    		jMenuFileExit.addActionListener(new ActionListener()
    				{
    			public void actionPerformed(ActionEvent e)
    			{
    				closeApplication();
    			}
    				});
    		jMenuFile.add(jMenuFileSave);
    		jMenuFile.add(jMenuFileOpen);
    		jMenuFile.add(jMenuFileExit);
    		menuBar.add(jMenuFile);
    		this.setJMenuBar(menuBar);
    	}

Discussions similaires

  1. Problème disparition composants
    Par kinola dans le forum Visual Studio
    Réponses: 4
    Dernier message: 16/10/2007, 14h42
  2. JVCL : disparition de composant
    Par vanquish dans le forum Composants VCL
    Réponses: 2
    Dernier message: 20/06/2006, 17h08
  3. Redéfinir l'événement OnExit de mon composant TEditFloat
    Par Seb des Monts dans le forum C++Builder
    Réponses: 5
    Dernier message: 18/06/2002, 16h10
  4. Installer ses composants
    Par Geronimo dans le forum C++Builder
    Réponses: 14
    Dernier message: 18/06/2002, 14h51
  5. Re-dimensionnement automatique de composants
    Par ludo_7 dans le forum C++Builder
    Réponses: 10
    Dernier message: 16/05/2002, 16h35

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