HOW TO SHOW JLABEL IN JDIALOG  WHILE MAIN CLASS IS SLEEPING? (CODE EDITED)

I have done a code below and it is working but the only problem is when the main program start to sleep by use Thread.sleep(10000) for 10 secs and it will prompt out a JDialog contain JLabel inside it with message "Please wait.... program is sleeping.". And when the thread ends the JDialog will auto disappear and it back to the main program.
I am using TimerTask to run the JDialog while the main class is sleeping.
The problem is:
When the JDialog appear, it doesn't show the component so I only be able to view the JDialog window without contain any component. I already use container to add the component into JDialog but it still doesn't show. I only be able to see the JDialog window contain empty component when the main window is sleeping.
How to make the components also appear in the JDialog when the main program is sleeping?
Below is the code pls have a try:
public class testThread extends JFrame
public static void main(String args[])
new testThread();
public testThread()
* other code not related is here
// WHEN USER PRESS startThreadBtn it will make the application sleep for 15 secs and pop out JDialog window contain JLabel msg wrote "Please wait... program is sleeping"
JButton startThreadBtn = new JButton("Start Thread");
startThreadBtn.addActionListener
( new ActionListener()
public void actionPerformed(ActionEvent e)
try{
doTask a = new doTask();
java.util.Timer thisTimer = new java.util.Timer();
thisTimer.schedule(a, 0); // when this code executed, will pop out a JDialog containing JLabel message --> refer to class doTask
Thread.sleep(10000);
a.terminate()
thisTimer.cancel();
catch(InterruptedException ie)
ie.printStackTrace();
public class doTask extends TimerTask
JDialog infoDialog;
public void run()
infoDialog = new JDialog(true);
infoDialog.setTitle("Please Wait!!!");
Container c = infoDialog.getContentPane();
c.setLayout(new BorderLayout());
JLabel infoLbl = new JLabel("Please Wait... Program is sleeping!!!", JLabel.CENTER);
c.add(infoLbl, BorderLayout.CENTER);
infoDialog.setVisible(true);
public void terminate()
infoDialog.setVisible(false);
infoDialog.dispose();
Why I can not show the JLabel inside the JDialog? The JDialog window is opened but it contain empty component.
PLEASE HELP ME .... THIS IS VERY URGENT

I have the complete code and it is working. I can posted it here but it will be longer thats the reason why i shortened the code in here and displaying the important information.
The problem is the JDialog only will display the JLabel after the thread woke up. Thats mean it is too late for me to display the information. I need the JLabel containing the information to be displayed when the thread is sleeping....
Below is the complete code:
you can have a try to recompile it and u will understand what i mean. It is working and the only problem is JLabel component did not displayed in the JDialog.
Just copy the whole code into the txt file and save as testThread.java and recompile it. Inside the code has one inner class extends TimerTask call "doTask"
THE CODE START BELOW:
import java.util.*;
import java.lang.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class testThread extends JFrame
public static java.util.Timer thisTimer;
public static doTask a;
public static testThread tT;
public Container cMain;
public Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
public JButton exitBtn;
public JButton startThreadBtn;
/** Creates a new instance of testThread */
public static void main(String args[])
new testThread();
public testThread()
//System.out.println("Start to call JDialog");
tT = this;
int realW = (int)screenSize.getWidth();
int realH = (int)screenSize.getHeight();
int mainW = 500;
int mainH = 300;
exitBtn = new JButton("EXIT");
exitBtn.setBounds((int)((500-100)/2), (int)((300-50)/5), 100, 50);
exitBtn.addActionListener
new ActionListener()
public void actionPerformed(ActionEvent e)
System.exit(0);
startThreadBtn = new JButton("Start Thread");
startThreadBtn.setBounds((int)((500-200)/2), (int)((300-50)/5*4), 200, 50);
startThreadBtn.addActionListener
new ActionListener()
public void actionPerformed(ActionEvent e)
try
System.out.println("Start to call JDialog");
a = new doTask();
thisTimer = new java.util.Timer();
thisTimer.schedule(a, 0);
System.out.println("Thread start to sleep first 10 secs");
Thread.sleep(10000);
System.out.println("Thread start to sleep second 5 secs");
Thread.sleep(5000);
System.out.println("Thread Wake Up");
a.terminate();
thisTimer.cancel();
catch(InterruptedException ie)
ie.printStackTrace();
cMain = this.getContentPane();
cMain.setLayout(null);
cMain.add(exitBtn);
cMain.add(startThreadBtn);
setBounds((int)((realW-mainW)/2), (int)((realH-mainH)/2), mainW, mainH);
setVisible(true);
public class doTask extends TimerTask
JDialog infoDialog;
public void run()
System.out.println("TASK IS RUNNING");
int screenWidth = (int)screenSize.getWidth();
int screenHeight = (int)screenSize.getHeight();
int w = 300;
int h = 200;
infoDialog = new JDialog(tT, true);
infoDialog.setTitle("Please Wait!!!");
Container c = infoDialog.getContentPane();
c.setLayout(new BorderLayout());
JLabel infoLbl = new JLabel("Please Wait... Program is sleeping!!!", JLabel.CENTER);
c.add(infoLbl, BorderLayout.CENTER);
infoDialog.setBounds((int)((screenWidth-w)/2), (int)((screenHeight-h)/2), w, h);
infoDialog.setVisible(true);
public void terminate()
infoDialog.setVisible(false);
infoDialog.dispose();
this.cancel();
******************************************************************************************************************************************************************************************************************************************

Similar Messages

  • HOW TO SHOW COMPONENT IN JDIALOG WHILE MAIN APP SLEEPING?

    I have done a code below and it is working but the only problem is when the main program start to sleep by use Thread.sleep(10000) for 10 secs and it will prompt out a JDialog contain JLabel inside it with message "Please wait.... program is sleeping.". And when the thread ends the JDialog will auto disappear and it back to the main program.
    The problem is:
    When the JDialog appear, it doesn't show the component so I only be able to view the JDialog window without contain any component. I already use container to add the component into JDialog but it still doesn't show. I only be able to see the JDialog window contain empty component when the main window is sleeping.
    How to make the components also appear in the JDialog when the main program is sleeping?
    Below is the code pls have a try:
    import java.util.*;
    import java.lang.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class testThread extends JFrame
    public static java.util.Timer thisTimer;
    public static doTask a;
    public static testThread tT;
    public Container cMain;
    public Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    public JButton exitBtn;
    public JButton startThreadBtn;
    /** Creates a new instance of testThread */
    public static void main(String args[])
    new testThread();
    public testThread()
    //System.out.println("Start to call JDialog");
    tT = this;
    int realW = (int)screenSize.getWidth();
    int realH = (int)screenSize.getHeight();
    int mainW = 500;
    int mainH = 300;
    setBounds((int)((realW-mainW)/2), (int)((realH-mainH)/2), mainW, mainH);
    setVisible(true);
    exitBtn = new JButton("EXIT");
    exitBtn.setBounds((int)((500-100)/2), (int)((300-50)/5), 100, 50);
    exitBtn.addActionListener
    new ActionListener()
    public void actionPerformed(ActionEvent e)
    System.exit(0);
    startThreadBtn = new JButton("Start Thread");
    startThreadBtn.setBounds((int)((500-100)/2), (int)((300-50)/5*4), 100, 50);
    startThreadBtn.addActionListener
    new ActionListener()
    public void actionPerformed(ActionEvent e)
    try
    System.out.println("Start to call JDialog");
    a = new doTask();
    thisTimer = new java.util.Timer();
    thisTimer.schedule(a, 0);
    System.out.println("Thread start to sleep first 10 secs");
    Thread.sleep(10000);
    System.out.println("Thread start to sleep second 5 secs");
    Thread.sleep(5000);
    System.out.println("Thread Wake Up");
    a.terminate();
    thisTimer.cancel();
    catch(InterruptedException ie)
    ie.printStackTrace();
    cMain = this.getContentPane();
    cMain.setLayout(null);
    cMain.add(exitBtn);
    cMain.add(startThreadBtn);
    public class doTask extends TimerTask
    JDialog infoDialog;
    public void run()
    System.out.println("TASK IS RUNNING");
    int screenWidth = (int)screenSize.getWidth();
    int screenHeight = (int)screenSize.getHeight();
    int w = 300;
    int h = 200;
    infoDialog = new JDialog(tT, true);
    infoDialog.setTitle("Please Wait!!!");
    Container c = infoDialog.getContentPane();
    c.setLayout(new BorderLayout());
    JLabel infoLbl = new JLabel("Please Wait... Program is sleeping!!!", JLabel.CENTER);
    c.add(infoLbl, BorderLayout.CENTER);
    infoDialog.setBounds((int)((screenWidth-w)/2), (int)((screenHeight-h)/2), w, h);
    infoDialog.setVisible(true);
    public void terminate()
    infoDialog.setVisible(false);
    infoDialog.dispose();
    this.cancel();
    }

    I have done a code below and it is working but the only problem is when the main program start to sleep by use Thread.sleep(10000) for 10 secs and it will prompt out a JDialog contain JLabel inside it with message "Please wait.... program is sleeping.". And when the thread ends the JDialog will auto disappear and it back to the main program.
    The problem is:
    When the JDialog appear, it doesn't show the component so I only be able to view the JDialog window without contain any component. I already use container to add the component into JDialog but it still doesn't show. I only be able to see the JDialog window contain empty component when the main window is sleeping.
    How to make the components also appear in the JDialog when the main program is sleeping?
    Below is the code pls have a try:
    import java.util.*;
    import java.lang.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class testThread extends JFrame
    public static java.util.Timer thisTimer;
    public static doTask a;
    public static testThread tT;
    public Container cMain;
    public Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    public JButton exitBtn;
    public JButton startThreadBtn;
    /** Creates a new instance of testThread */
    public static void main(String args[])
    new testThread();
    public testThread()
    //System.out.println("Start to call JDialog");
    tT = this;
    int realW = (int)screenSize.getWidth();
    int realH = (int)screenSize.getHeight();
    int mainW = 500;
    int mainH = 300;
    setBounds((int)((realW-mainW)/2), (int)((realH-mainH)/2), mainW, mainH);
    setVisible(true);
    exitBtn = new JButton("EXIT");
    exitBtn.setBounds((int)((500-100)/2), (int)((300-50)/5), 100, 50);
    exitBtn.addActionListener
    new ActionListener()
    public void actionPerformed(ActionEvent e)
    System.exit(0);
    startThreadBtn = new JButton("Start Thread");
    startThreadBtn.setBounds((int)((500-100)/2), (int)((300-50)/5*4), 100, 50);
    startThreadBtn.addActionListener
    new ActionListener()
    public void actionPerformed(ActionEvent e)
    try
    System.out.println("Start to call JDialog");
    a = new doTask();
    thisTimer = new java.util.Timer();
    thisTimer.schedule(a, 0);
    System.out.println("Thread start to sleep first 10 secs");
    Thread.sleep(10000);
    System.out.println("Thread start to sleep second 5 secs");
    Thread.sleep(5000);
    System.out.println("Thread Wake Up");
    a.terminate();
    thisTimer.cancel();
    catch(InterruptedException ie)
    ie.printStackTrace();
    cMain = this.getContentPane();
    cMain.setLayout(null);
    cMain.add(exitBtn);
    cMain.add(startThreadBtn);
    public class doTask extends TimerTask
    JDialog infoDialog;
    public void run()
    System.out.println("TASK IS RUNNING");
    int screenWidth = (int)screenSize.getWidth();
    int screenHeight = (int)screenSize.getHeight();
    int w = 300;
    int h = 200;
    infoDialog = new JDialog(tT, true);
    infoDialog.setTitle("Please Wait!!!");
    Container c = infoDialog.getContentPane();
    c.setLayout(new BorderLayout());
    JLabel infoLbl = new JLabel("Please Wait... Program is sleeping!!!", JLabel.CENTER);
    c.add(infoLbl, BorderLayout.CENTER);
    infoDialog.setBounds((int)((screenWidth-w)/2), (int)((screenHeight-h)/2), w, h);
    infoDialog.setVisible(true);
    public void terminate()
    infoDialog.setVisible(false);
    infoDialog.dispose();
    this.cancel();
    }

  • HOW TO SHOW JLABEL IN JDIALOG USE TIMERTASK WHILE MAIN CLASS IS SLEEPING?

    I have done a code below and it is working but the only problem is when the main program start to sleep by use Thread.sleep(10000) for 10 secs and it will prompt out a JDialog contain JLabel inside it with message "Please wait.... program is sleeping.". And when the thread ends the JDialog will auto disappear and it back to the main program.
    The problem is:
    When the JDialog appear, it doesn't show the component so I only be able to view the JDialog window without contain any component. I already use container to add the component into JDialog but it still doesn't show. I only be able to see the JDialog window contain empty component when the main window is sleeping.
    How to make the components also appear in the JDialog when the main program is sleeping?
    Below is the code pls have a try:
    import java.util.*;
    import java.lang.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class testThread extends JFrame
    public static java.util.Timer thisTimer;
    public static doTask a;
    public static testThread tT;
    public Container cMain;
    public Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    public JButton exitBtn;
    public JButton startThreadBtn;
    /** Creates a new instance of testThread */
    public static void main(String args[])
    new testThread();
    public testThread()
    //System.out.println("Start to call JDialog");
    tT = this;
    int realW = (int)screenSize.getWidth();
    int realH = (int)screenSize.getHeight();
    int mainW = 500;
    int mainH = 300;
    setBounds((int)((realW-mainW)/2), (int)((realH-mainH)/2), mainW, mainH);
    setVisible(true);
    exitBtn = new JButton("EXIT");
    exitBtn.setBounds((int)((500-100)/2), (int)((300-50)/5), 100, 50);
    exitBtn.addActionListener
    new ActionListener()
    public void actionPerformed(ActionEvent e)
    System.exit(0);
    // WHEN USER PRESS startThreadBtn it will make the application sleep for 15 secs and pop out JDialog window contain JLabel msg wrote "Please wait... program is sleeping"
    startThreadBtn = new JButton("Start Thread");
    startThreadBtn.setBounds((int)((500-100)/2), (int)((300-50)/5*4), 100, 50);
    startThreadBtn.addActionListener
    new ActionListener()
    public void actionPerformed(ActionEvent e)
    try
    System.out.println("Start to call JDialog");
    a = new doTask();
    thisTimer = new java.util.Timer();
    thisTimer.schedule(a, 0);
    System.out.println("Thread start to sleep first 10 secs");
    Thread.sleep(10000);
    System.out.println("Thread start to sleep second 5 secs");
    Thread.sleep(5000);
    System.out.println("Thread Wake Up");
    a.terminate();
    thisTimer.cancel();
    catch(InterruptedException ie)
    ie.printStackTrace();
    cMain = this.getContentPane();
    cMain.setLayout(null);
    cMain.add(exitBtn);
    cMain.add(startThreadBtn);
    public class doTask extends TimerTask
    JDialog infoDialog;
    public void run()
    System.out.println("TASK IS RUNNING");
    int screenWidth = (int)screenSize.getWidth();
    int screenHeight = (int)screenSize.getHeight();
    int w = 300;
    int h = 200;
    infoDialog = new JDialog(tT, true);
    infoDialog.setTitle("Please Wait!!!");
    Container c = infoDialog.getContentPane();
    c.setLayout(new BorderLayout());
    JLabel infoLbl = new JLabel("Please Wait... Program is sleeping!!!", JLabel.CENTER);
    c.add(infoLbl, BorderLayout.CENTER);
    infoDialog.setBounds((int)((screenWidth-w)/2), (int)((screenHeight-h)/2), w, h);
    infoDialog.setVisible(true);
    public void terminate()
    infoDialog.setVisible(false);
    infoDialog.dispose();
    this.cancel();
    }

    LOUD NOISES.

  • How to show two amount (based on value type and entry code)  in same column

    Hi, I have to show two amount in the same column how can i do that...
    For example there is 
    1) premium amount which depends upon the entry code lets say entry code 1000 = Premium amount .
    2) Now there is another premium amount but this amount is stored on basis of value type ...let us say for value type 'prem' = premium amount .
    these amount are in different field can i shown it in same column in BEx query.
    If you can you please help .

    use the selection criteria to restrict the field types in the query designer- use other variables to check the value
    if it doesnt reconcile- you can alternatively use a multi provider for the same thing- that way you will get the same amount in 1 column and you could restrict using the infoprovider column

  • How to show all available fields in the SQL Worksheet's Code Assist pop-up

    I have table with many fields and wanted to scroll through the fields list by typing something like:
    select a. from test a
    The Code Assist pop-up (after the 'a.') that shows the field list shows '...' as last available field before '*'. Many fields are not shown on the pop-up. I have to click on the '...' field to tell the pop-up to refresh itself with a full list of fields. Is there a way that I can configure SQL Worksheet to always show all fields on the pop-up, instead of having to select '...' on every attempt to add a field to the select SQL?

    Sure, happens to everyone ;)
    Not the case here, but often the OP gives credit to the first to respond rather than acknowledging everyone's effort and time invested, which of course is independent from posting order. Add that to the nicely conceived, but badly implemented reward point system. Should have moderators for that to work as it should. Sooo many questions remain unanswered and/or unrewarded. I even think you're the most underrated helping hand on the forum. Let's hope time will rectify all that...
    Regards,
    K.

  • How to set main class in netbeans?

    i have a class with a main method that i want to set as my main class, but i dont have the source for it. how can i set it as my main class in netbeans?
    thanks!

    ya i can run in from the comand prompt, Excellent.
    and yeah your right it should be easy. It IS easy. You just did it.
    but for the life of me i cant figure it out. What can't you figure out? How to do the same thing in NetBeans?
    i dont know where else to turn.Let me suggest the NetBeans docs. I'm sure they've got something in there to tell users how to run a .class with a main() method.
    Better yet, keep doing things on the command line until you're knowledgable about NetBeans and leave the IDE alone until you know Java. Two mysteries at once is too much.
    %

  • How to deal with  time zone while upgrading the database?

    Hi,
    How to deal with time zone while upgrading the database?
    Thanks
    Edited by: user12135020 on Jul 4, 2011 3:06 AM

    Hello,
    I answered to a Wrong post.
    Best regards,
    Jean-Valentin
    Edited by: Lubiez Jean-Valentin on Jul 4, 2011 12:15 PM

  • Could not find the main class : HelloWorldApp program will exit

    please help me
    i downloaded and installed jdk-6u13-windows-i586-p(1) from sun.java.com
    in my computer --> Advanced --> environment variables --> i had set
    user variable :
    variable value
    java_home C:\Program Files\Java\jdk1.6.0_13\bin
    System variable:
    path : C:\Program Files\Java\jdk1.6.0_13\bin
    after that i wrote a program
    * The HelloWorldApp class implements an application that
    * simply prints "Hello World!" to standard output.
    class HelloWorldApp {
    public static void main(String[] args) {
    System.out.println("Hello World!"); // Display the string.
    i saved in c:\ mywork
    i compiled it with
    javac HelloWorldApp.java and then
    java HelloWorldApp
    output / result also came
    but iam unable to create jar file . when it is created it is showing
    could not find the main class : HelloWorldApp program will exit
    i created jar file by following way
    i created
    manifest.txt
    Min-Class : HelloWorldApp and then
    start -->run--> cmd-->
    c:\mywork> jar cfm test.jar manifest.txt HelloWorldApp.class
    c:\ java -jar test.jar
    but it displays a message
    " could not find the main class : HelloWorldApp program will exit "
    please please please help me please 1000's of please help me

    Peter__Lawrey wrote:
    You have to specify the manifest with a special option (I think its was -M)
    Otherwise the jar will create one (even if you provide it)No, the text file passed as a parameter will be incorporated in the manifest file generated by the JAR tool.
    @OP: This will work:
    JarTest.java
    public class JarTest {
      public static void main(String[] args) {
        System.out.println("JarTest works!");
    }manifest.txt
    Main-Class: JarTest+(note there is an extra new line in the manifest.txt!)+
    Now execute these commands:
    javac JarTest.java
    jar cfm MyJar.jar manifest.txt JarTest.class
    java -jar MyJar.jar And on my machine, the string "JarTest works!" is displayed on the screen.
    And if you look in the MANIFEST.MF file inside your jar file (you can use almost any zip-utility for this), you will see the following:
    Manifest-Version: 1.0
    Created-By: 1.6.0_0 (Sun Microsystems Inc.)
    Main-Class: JarTestOr something similar.

  • Could not find the main class ! exception.

    hi,
    I create one java project. for this I am using netbeans 5.
    I try to run the project jar file stff.jar. When run using "java -jar stff.jar " , it throws error "could not find the main class. program will exit".
    I am extracting this jar file, in manifest, main class is set.
    i.e, in manifest, Main-Class: ems.emsFrame.
    ems is my folder ,inside it main class kept.
    here, emsFrame is my main class where " public static void main (String args[])" is located.
    I am also, set the class path for that class folder(ems) and run.
    The same error ("could not find the main class. program will exit") occured.
    Why this error occured.
    also,I am uninstall the jdk and reinstall .
    whats my problem.
    bye

    yes sir.
    In projects, inside it, in Libraries ,the SNMPInquisitor.jar is located.
    inside that jar, snmp package is located.
    but, when build and run, there is no problem sir.
    Only when i try to run the stff.jar file (java -jar stff.jar), that time only the exception thrown.
    when I double click that jar, it show, "could not find the main class. program will exit". But, I am adding the main class in manifest. when i open manifest.mf, it show, Main-Class: ems.emsFrame.
    but, when i run jar thro' cmd window, it shows,
    Exception in thread "main" java.lang.NoClassDefFoundError: snmp/SNMPGetException
    at ems.emsFrame.<init>(emsFrame.java:1163)
    at ems.emsFrame.<clinit>(emsFrame.java:1155).
    i am still trying it.

  • Using main class's methods from a different class in the same file

    Hi guys. Migrating from C++, hit a few snags. Hope someone can furnish a quick word of advice here.
    1. The filename is test.java, so test is the main class. This code and the topic title speak for themselves:
    class SomeClass
         public void SomeMethod()
              System.out.println(test.SomeOperation());
    public class test
         public static void main(String args[])
              SomeClass someObject = new SomeClass();
              someObject.SomeMethod();
         public static String SomeOperation()
              return "SomeThing";
    }The code works fine. What I want to know is, is there some way to use test.SomeOperation() from SomeClass without the test.?
    2. No sense opening a second topic for this, so second question: Similarly, is there a good way to refer to System.out.println without the System.out.? Like the using keyword in C++.
    Thanks.

    pfiinit wrote:
    The code works fine. What I want to know is, is there some way to use test.SomeOperation() from SomeClass without the test.?Yes you can by using a static import, but I don't recommend it. SomeOperation is a static method of the test class, and it's best to call it that way so you know exactly what your code is doing here.
    2. No sense opening a second topic for this, so second question: Similarly, is there a good way to refer to System.out.println without the System.out.? Like the using keyword in C++.Again, you could use static imports, but again, I don't recommend it. Myself, I use Eclipse and set up its template so that when I type sop it automatically spits out System.out.println(). Most decent IDE's have this capability.
    Also, you may wish to look up Java naming conventions, since if you abide by them, it will make it easier for others to understand your code.
    Much luck and welcome to this forum!

  • How to show staticly decleared int's in a JLabel

    hi
    how to show staticly decleared int's in a JLabel
    i have the following code but it doesnt seem to be working
           // Declear jlabel
            JLabel statuslabel = new JLabel(" X Axis : " + x + " Y Axis : + y ");
           // position of cursor
            public static int x;
            public static int y;
           

    nicchick wrote:
    um is there a easyer way to update int's inside a JLabel:)You need a MouseMotionListener
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.awt.Point;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    public class CursorPositionInLabel
      private static final String BAD_LABEL = "Bad Label";
      private static final String GOOD_LABEL = "Good Label";
      private JPanel mainPanel = new JPanel();
      private Point cursorP = new Point();
      private JLabel badLabel = new JLabel(BAD_LABEL + ";  [" + cursorP.x + ", " + cursorP.y + "]"); // this guy never gets updated, & so never changes
      private JLabel goodLabel = new JLabel(GOOD_LABEL + ";  [" + cursorP.x + ", " + cursorP.y + "]");
      public CursorPositionInLabel()
        mainPanel.setPreferredSize(new Dimension(600, 600));
        mainPanel.setLayout(new GridLayout(1, 2));
        JPanel badPanel = new JPanel();
        badPanel.add(badLabel);
        JPanel goodPanel = new JPanel();
        goodPanel.add(goodLabel);
        mainPanel.add(badPanel);
        mainPanel.add(goodPanel);
        mainPanel.addMouseMotionListener(new MouseAdapter()
          // this is the event that gets tripped each time the mouse moves
          public void mouseMoved(MouseEvent e)
            // get the location of the mouse curse
            cursorP = e.getPoint();
            // and then update your JLabel with the coordinates
            goodLabel.setText(GOOD_LABEL + ";  [" + cursorP.x + ", " + cursorP.y + "]");
      public JPanel getMainPanel()
        return mainPanel;
      // create the JFrame in a thread-safe manner as the Sun tutorials tell us to do.
      private static void createAndShowUI()
        JFrame frame = new JFrame("CursorPositionInLabel");
        frame.getContentPane().add(new CursorPositionInLabel().getMainPanel());
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      public static void main(String[] args)
        java.awt.EventQueue.invokeLater(new Runnable()
          public void run()
            createAndShowUI();
    }Edited by: Encephalopathic on Jun 18, 2008 5:28 PM

  • How to show decoration ina a jdialog

    When i show a simple jdialog, it's missing the iconize and maximize button on the right corner, a jframe show that options
    How i can to show that options in a jdialog?
    import javax.swing.JDialog;
    public class SimpleDigalog {       
        public SimpleDigalog() {
             JDialog dialog = new JDialog();
             dialog.setTitle("Simple dialog");
             dialog.setSize(400, 250);         
             dialog.setVisible(true);         
        public static void main(String[] args) {       
            new SimpleDigalog();       
    }

    Ok, i explain my problem
    i need a class that have the iconize and maximize
    button and the modal option
    jdialog have the modal option but have not the
    iconize/maximize buttons
    jframe have not the modal option but have the
    iconize/maximize buttons
    so the question is, which type of class i can you to
    have the iconize/maximize button and the modal option?You could use JFrame and block all input to the parent JFrame like this:
    parentFrame.setEnabled(false);

  • How to show all view tab (Main Report and all Sub Report) in Visual FoxPro 9

    I use ActiveX from Crystal Report Developer XI for viewer in Visual FoxPro 9 and I already know how to show Main Report by using command:
    oRptRun=createobject("CrystalRuntime.Application")
    oRptView=thisform.oleRptViewer
    oRptOpen=oRptRun.OpenReport('MyReport.rpt')
    oRptView.ReportSource=oRptOpen
    oRptView.ViewReport
    Inside the MyReport.rpt there is two subreport name :
    1. MySubReport1
    2. MySubReport2
    My Question is :
    How to show all view tab (Main Report and all Sub Report) at the 1st time we call ViewReport?
    I try to using command :
    oRptRun=createobject("CrystalRuntime.Application")
    oRptView=thisform.oleRptViewer
    oRptOpen=oRptRun.OpenReport('MyReport.rpt')
    oRptSub=oRptOpen.OpenSubreport("MySubReport1")
    oRptSub=oRptOpen.OpenSubreport("MySubReport2")
    oRptView.ReportSource=oRptOpen
    oRptView.ViewReport
    but only show Main Report (view tab name : Preview)?
    Did I miss any command before I call oRptView.ViewReport?

    Your right, there is only one tab to view the report.
    To open the subreports you will need to click on them in the main report. I don't know of a way to open them programmatically like you are doing here
    http://diamond.businessobjects.com/robhorne</a>

  • How can show the result of a measuring that is done in a sub-program in my main panel?

    How can show the result of a measuring that is done in a sub-program in my main panel?

    In your subvi, wire the result(s) you want to ouput to the main program to an output terminal on the connector pane.
    For a tutorial on subvi's, search the help for "connector panes" anc click on tutorial.
    ~Tim

  • How to show view tab Main Report and all of Sub Report in one action through Visual FoxPro

    How to show all view tab (Main Report and all of Sub Report) in one action.
    I already know how to show Main Report with this code sample:
    oRptRun=createobject("CrystalRuntime.Application")
    oRptView=this.Parent.oleRptViewer
    oRptOpen=oRptRun.OpenReport('MyReport.rpt')
    oRptView.ReportSource=oRptOpen
    oRptView.ViewReport
    Inside the 'MyReport.rpt' it has 2 subreports:
    1. MySubReport_1
    2. MySubReport_2
    I try to show MySubReport_1 and MySubReport_2 together with their own Main Report with this code sample:
    oRptRun=createobject("CrystalRuntime.Application")
    oRptView=this.Parent.oleRptViewer
    oRptOpen=oRptRun.OpenReport('MyReport.rpt')
    oRptSub1=oRptOpen.OpenSubreport('MySubReport_1')
    oRptSub2=oRptOpen.OpenSubreport('MySubReport_2')
    oRptView.ReportSource=oRptOpen
    oRptView.ViewReport
    Did I miss something because there was only view tab 'Preview' (Main Report) shown without view tab MySubReport_1 and MySubReport_2.
    Thank you.

    Your right, there is only one tab to view the report.
    To open the subreports you will need to click on them in the main report. I don't know of a way to open them programmatically like you are doing here
    http://diamond.businessobjects.com/robhorne</a>

Maybe you are looking for

  • Keep getting error message DF001, DF037... when i try to install aps. whats up??

    Exit Code: 7 Please see specific errors below for troubleshooting. For example, ERROR: DF001, DF037,D ... -------------------------------------- Summary -------------------------------------- - 0 fatal error(s), 13 error(s) ----------- Payload: Adobe

  • Multiple stereos off of Airport Express

    I was wondering if there is a way to connect my airport express up to a optical cable on my stereo and to the headphone jack from my harmon kardon soundsticks. This way it could run more speakers at once, is there a special cable that can split from

  • Did not installl Core DLL with Reader XI

    I am unable to open any pdf documents; I have Windows7 and have uninstalled and re-installed ReaderXI today (4/6/2013) and continue to get the message, "Adobe failed to install CORE DLL" how can this be corrected?

  • Featchures not working proper after update

    the back button stopped working after update. cant even past and copy ulrs to the address bar.

  • Effects on exisiting events?

    I have the following code that I would like to add effects to. I hve been trying to use the examples in the "examples" folder in the spry zip file but I can't seem to get it to work. I have three links that control sliding panels. CODE for links and