Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #17426

Re: Layout Doesn't Work

From "clusardi2k" <clusardi2k@1:261/38.remove-qhs-this>
Subject Re: Layout Doesn't Work
Message-ID <5022AB86.56376.calajapr@time.synchro.net> (permalink)
Newsgroups comp.lang.java.programmer
References <5022AB85.56374.calajapr@time.synchro.net>
Date 2012-08-08 19:04 +0000
Organization tds.net

Show all headers | View raw


  To: clusardi2k
From: clusardi2k@aol.com

On Wednesday, August 8, 2012 12:24:39 PM UTC-4, (unknown) wrote:
> I'll report back in a few minutes!

It gave me confusing results. It was like the project ran too fast to ever 
display the label. I thought this was nonsense, so I created the below project.

The big question now becomes how do I (using the below project) get jLabel1 to 
be visible while the project is executing in the for loops?

Information about 3 of my button clicks:

Start run jLabel1 is visible :-)

(1st button press)
jLabel1 disappears at end of method and never comes back up!

(2nd button press)
jLabel1 never is seen

(3rd button press)
jLabel1 never is seen

//Code:

package hide_show_label_with_icon;

import java.util.logging.Level;
import java.util.logging.Logger;

public class Hide_Show_Label_with_Icon extends javax.swing.JFrame {

    public Hide_Show_Label_with_Icon() {
        initComponents();
    }

    @SuppressWarnings("unchecked")
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton1.setText("jButton1");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel1.setText("jLabel1");

        javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
            .addGroup(layout.createSequentialGroup()
                .addGap(46, 46, 46)
                .addComponent(jButton1)
                .addGap(60, 60, 60)
                .addComponent(jLabel1)
                .addContainerGap(233, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
            .addGroup(layout.createSequentialGroup()
                .addGap(270, 270, 270)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Al
ignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jLabel1))
                .addContainerGap(36, Short.MAX_VALUE))
        );

        pack();
    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        System.out.println("jLabel1.isVisible is " + jLabel1.isVisible());

        jLabel1.setVisible(true);

        for (int i = 0;i < 100000; i++)
            for (int i2 = 0;i2 < 100000; i2++);
                for (int i3 = 0;i3 < 100000; i3++);

        System.out.println("jLabel1.isVisible is " + jLabel1.isVisible());
        jLabel1.setVisible(false);
        System.out.println("Done");
        System.out.println();

    }


    public static void main(String args[]) {

        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Hide_Show_Label_with_Icon().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration
}

--- BBBS/Li6 v4.10 Dada-1
 * Origin: Prism bbs (1:261/38)
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

jLabel setVisible(true) Doesn't Work "clusardi2k" <clusardi2k@1:261/38.remove-qhs-this> - 2012-08-08 19:04 +0000
  Re: jLabel setVisible(true) Doesn't Work "markspace" <markspace@1:261/38.remove-qhs-this> - 2012-08-08 19:04 +0000
    Re: jLabel setVisible(true) Doesn't Work "clusardi2k" <clusardi2k@1:261/38.remove-qhs-this> - 2012-08-08 19:04 +0000
      Re: jLabel setVisible(true) Doesn't Work "Jeff Higgins" <jeff.higgins@1:261/38.remove-qhs-this> - 2012-08-08 19:04 +0000
        Layout Doesn't Work (was: jLabel setVisible(true) Doesn't Work) "Jeff Higgins" <jeff.higgins@1:261/38.remove-qhs-this> - 2012-08-08 19:04 +0000
          Re: Layout Doesn't Work (was: jLabel setVisible(true) Doesn't Work) "clusardi2k" <clusardi2k@1:261/38.remove-qhs-this> - 2012-08-08 19:04 +0000
            Re: Layout Doesn't Work "markspace" <markspace@1:261/38.remove-qhs-this> - 2012-08-08 19:04 +0000
              Re: Layout Doesn't Work "clusardi2k" <clusardi2k@1:261/38.remove-qhs-this> - 2012-08-08 19:04 +0000
                Re: Layout Doesn't Work "clusardi2k" <clusardi2k@1:261/38.remove-qhs-this> - 2012-08-08 19:04 +0000
                Re: Layout Doesn't Work "markspace" <markspace@1:261/38.remove-qhs-this> - 2012-08-08 19:04 +0000
                Re: Layout Doesn't Work "Jeff Higgins" <jeff.higgins@1:261/38.remove-r72-this> - 2012-08-08 20:06 +0000
                Re: Layout Doesn't Work "clusardi2k" <clusardi2k@1:261/38.remove-r72-this> - 2012-08-08 20:06 +0000
                Re: Layout Doesn't Work "markspace" <markspace@1:261/38.remove-k2r-this> - 2012-08-09 18:44 +0000
                Re: Layout Doesn't Work "Jeff Higgins" <jeff.higgins@1:261/38.remove-t9h-this> - 2012-08-10 18:39 +0000
                Re: Layout Doesn't Work "Jeff Higgins" <jeff.higgins@1:261/38.remove-t9h-this> - 2012-08-10 18:39 +0000
                Re: Layout Doesn't Work "Jeff Higgins" <jeff.higgins@1:261/38.remove-6gh-this> - 2012-08-10 19:41 +0000
            Re: Layout Doesn't Work "Jeff Higgins" <jeff.higgins@1:261/38.remove-qhs-this> - 2012-08-08 19:04 +0000
              Re: Layout Doesn't Work "Jeff Higgins" <jeff.higgins@1:261/38.remove-r72-this> - 2012-08-08 20:06 +0000
  Re: jLabel setVisible(true) Doesn't Work "John B. Matthews" <john.b..matthews@1:261/38.remove-qhs-this> - 2012-08-08 19:04 +0000
  Re: jLabel setVisible(true) Doesn't Work "Roedy Green" <roedy.green@1:261/38.remove-k2r-this> - 2012-08-09 18:44 +0000

csiph-web