Thread - jdialog etc

Hi!
My good old problem still :(
So in a button's actionlistener I made a much-time-needed thing. During that I want to popup a jdialog that displays 'please-wait'. I made a thread, which gets the main-frame as a parameter, so in this thread I make a dialog, the main-frame as the owner, I put it modal etc. And when the much-time-needed thing stops, then I want the dialog to be closed etc. I made after much-time-needed source to .stop() the thread, but the jdialog is still there. I hope it's clear, help me asap plz :)
thanks,
athalay

.stop() shouldn't be used. It might not even work anymore. You need to create your first design in concurrency :) You will have to wait on some lock after you put the "please wait" screen. Your other Thread (could be the AWT) will then change a condition and notify.. (with notifyAll().. bad names ... another story) The waiting Thread. Past the wait loop will be the code to dispose of the dialog... sound fun? I think it is, I love concurrent designs.
// The processing Thread (could be in an AWT event)
new Thread(new Runnable() {
  pubic void run() {
    // I'm about to do a ton of processing
    new Thread( pleaseWait ).start();
    // I'm processing... la la la la
    // I'm done processing... la la la
    pleaseWait.endIt();  }
// somewhere else
pleaseWait = new Runnable() {
  boolean done = false;
  public void run() {
    // put up the dialog here
    while( !done ) {
      synchronized( this ) { // this is good for a lock :)
        wait();
    // if your here you are done... close the dialog
  public void endIt() {
    synchronized( this ) { // notice it's the same lock :)
     done = true;
     notifyAll();

Similar Messages

  • ContentPane not rendering in threaded JDialog

    I want to popup a small dialog whilst my main thread is executing telling the user to be patient.
    So, I create JDialog that implements Runnable.
    public class TheSplash extends JDialog implements Runnable
    public TheSplash(Frame f) {
        super(f, true);
        setTitle("blabla");
        JPanel p = new JPanel();
        JLabel l = new JLabel("text");
        p.add(l);
        getContentPane().add(p, BorderLayout.CENTER);
        setSize(150, 100);
        setLocationRelativeTo(f);
    public void run() {
        setVisible(true);
    }Now, in my main thread (Event Despatch Thread) I do
    final TheSplash splash = new TheSplash(someFrameInstance);
    Thread t = new Thread(splash);
    t.start();
    // lengthy processes happen here
    splash.setVisible(false);
    splash.dispose();
    // more stuffNow, the dialog displays and disappears at the required times, but the only things rendered on screen are the actual dialog and title, but not the contentPane of the TheSplash instance.
    What gives? I tried forcing it to repaint right after completion, doing a step-by-step debug through the code, the code runs through the entire TheSplash constructor as expected, without errors...
    Any help appreciated....

    Hi,
    you have to put the setVisible(true) method in the EventDispatchingThread. At the moment it is not in the E-Thread because you explicitly start a new Thread Thread t = new Thread(splash);Change this to
    SwingUtilities.invokeLater(splash);and run the lengthy process in a separate Thread (not the E-Thread) and join() this thread to get informed of the end.
    Thread t = new Thread(new Runnable() {
      public void run() {
         // lengthy process
    t.start();
    t.join();All GUI-things in the lengthy process must be dispatched to the E-Thread.
    Ulrich

  • Threads (webservices etc)

    hi,
    i'm writing webservices, portal components etc which use a custom-base-class which starts a thread and listens on a given port. so far so good. everything works fine etc etc.
    but my problem is, when i re-deploy the application or i stop it within the visual administrator's deploy feature, the webservice or portalcomponent stops successful (cant open it using the portal or the webservice navigator), but the thread is still running and i dont know why. i even abstracted the finalize() function to kill my sub-threads, but that doesnt work either.
    any help or suggestions? i just want to have my applications clean, so if i stop them, all subthreads will die... or even better, a function call.. like finalize() would ne the best damn thing for me.
    thanks,
    constantin

    hi, this is a very simple code, just to demonstrate what i want to do.
    this is a simple sap webservice, which i simply deploy and test the webservice using the "web services navigator" (function which is public to the service is "test(String)". so far so good. everything works as expected. but when i stop the web service with the deploy service using the visual administrator. the application and/or thread is still running... printing "zzz ZZZ zzz" in my debug log. even the simple checks in "run()" doesn't work. is there any work around? i COULD implement a function/service in my portal administration app which starts/stops applications using the sap deploy-service using the deploy.jar to start and stop the applications.. but let the application know that they are about to stop before, so they can shutdown their threads, open sockets etc...
    package de.wsa.test;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    public class Test {
         private static final Log LOG = LogFactory.getLog(Test.class);
         private TestThread thread;
         public Test() {
              LOG.debug("TEST");
              thread = new TestThread(this);
         public String test(String test) {
              LOG.debug("test");
              return test;
         protected void finalize() throws Throwable {
              LOG.debug("finalize");
              thread.setStop(true);
              super.finalize();
         public static class TestThread extends Thread {
              private static final Log LOG = LogFactory.getLog(TestThread.class);
              private Test test;
              private boolean stop = false;
              public TestThread(Test test) {
                   LOG.debug("TestThread");
                   this.test = test;
                   start();
              public void setStop(boolean stop) {
                   LOG.debug("setStop");
                   this.stop = stop;
              public void run() {
                   LOG.debug("run");
                   while (true) {
                        if (stop) {
                             LOG.warn("stop");
                             break;
                        if (Thread.currentThread().isInterrupted()) {
                             LOG.warn("Thread.currentThread().isInterrupted()");
                             break;
                        if (isInterrupted()) {
                             LOG.warn("isInterrupted()");
                             break;
                        if (test == null) {
                             LOG.warn("test == null");
                             break;
                        LOG.debug("zzz ZZZ zzz");
                        try {
                             Thread.sleep(5000);
                        } catch (Exception e) {
                             //swallow silently
    Edited by: Constantin Wildförster on Apr 23, 2010 11:46 AM

  • Threads, swing etc...

    Hi, I need to develop a software that manage the windows creation. Each windows make some operation: eg. show or manage some data or is a text editor and so on.. I need to know the general idea that is behind the design of a software of this type. I make myself more clear: I don't know the startup, if I need to make a tread manager and use a thread for each window, or use some kind of design pattern for manage this situation.
    Someone has the expertise for explain this such of problem?

    The systematic difference in GUI programming as opposed to a simple command line program is that it's handled as events. An event usually represents a user action (sometimes it's a timer or the like). You provide code to handle that event, which may result in a change in what is displayed. But once you've handled an event your handler code finishes and the system goes back to waiting for the next event.
    In an ordinary program there's a definite sequence to be executed, in a GUI program the program spends most of it's time waiting for the user to decide what he wants to do next.
    However sometimes an event launches an activity which runs for some time in the background and, when it's ready, changes the display. These activities are called "worker threads" and have more resemblance to ordinary programs.
    The GUI event processing occurs as a loop on a single thread, and only one event is processed at a time. This means event handlers must finish quickly, to let other events proceed. An event that launches an action that is likely to take more than a fraction of a second should start a worker thread.

  • Using JDialog etc in Fullscreen

    Has anyone had any success using JDialog or any other pop-up type classes in Fullscreen applications? If so, how did you go about it?
    We're trying to migrate an old swing application to fullscreen and it would be really useful if we didn't have to write custom alerts, filechoosers and everything else...

    hi Ram,
    welcome to SDN ...
    basically we have two 'notation', business content delivered objects and our own created objects,
    business content objects will have prefix /bi0/ ...
    and our own created objects will start with /bic/ ...
    next is the p, q notation,
    it's tables' name, p is the master data attribute table (for non time dependent),
    e.g we have infoobject 0customer then the table is /bi0/pcustomer (no zero),
    and we created our own infoobject zcountry, the table is /bic/pzcountry (use z)
    you can check multidimentional data modeling doc for the tables name
    and SELECT we will deal with field name .... you can check the table structure with SE11, e.g 0customer attribute table /BI0/PCUSTOMER
    you will see that field name for business content is without zero,
    customer, country, and e.g we have add attribute zarea to 0customer,
    the field name is /bic/zarea
    hope this helps.

  • How many  threads are running?

    here's the code... i am trying to understand, at each point, how many threads are running:
    I understand that one thread belongs to the caller of the start()
    & at the same time there is another thread belonging to the instances of each thread (thread1, thread2, thread 3 etc.)
    1public class ThreadTester {
    2   public static void main( String args[] )
    3   {
    4      PrintThread thread1, thread2, thread3, thread4;
    5
    6      thread1 = new PrintThread( "thread1" );
    7      thread2 = new PrintThread( "thread2" );
    8      thread3 = new PrintThread( "thread3" );
    9      thread4 = new PrintThread( "thread4" );
    10
    11      System.err.println( "\nStarting threads" );
    12
    13      thread1.start();
    14      thread2.start();
    15      thread3.start();
    16      thread4.start();
    17
    18      System.err.println( "Threads started\n" );
    19   }
    }can you tell me if i am counting the number of threads in existance correctly...
    LINE#.....CALLER...START...TOTAL THREADS
    13..............1.........1.......2
    14..............1+1......1+1.....4
    15..............2+1......2+1.....6
    16..............3+1......3+1.....8
    so by the time line 16 executes i have a total of 8 threads,
    4 threads belonging to each caller plus
    4 threads created by start()
    or is it
    LINE#.....CALLER...START...TOTAL THREADS
    13..............1........1........2
    14..............1........1+1.....3
    15..............1........2+1.....4
    16..............1........3+1.....5
    after line 16 executes does the caller thread die, thus leaving only a total of 4 threads?
    there is only one thread belonging to the caller at line 13(plus the thread it creates).
    at the start of line 14, the previous callers thread is dead & now a new thread is created that belongs to the caller on line 14... etc.

    well, i realize at the end there would be 4 threads but im trying to get my head around this explanation in the book:
    "A program launches a threads executioin by calling the threads start method, which in turn call the run method. After start launches the thread, start returns to tis caller immediately. The caller then executes concurrently with the lauched thread." there fore if i have 2 concurrent processes, are there 2 threads running????
    now having said the above, my question was:
    for each line,
    how many threads are in existance at
    line13
    line14
    line15
    line16
    thanks.

  • DHCP_TIMEOUT in /etc/conf.d/netcfg has no effect

    I want to set DHCP_TIMEOUT to 30 for all netcfg profiles. On  this page in wiki it is suggested to set the variable in /etc/conf.d/netcfg. But this has no effect. I tried 'NETCFG_DEBUG="yes" netcfg <arguments>' and the timeout was still 10.
    How can I set DHCP_TIMEOUT for all profiles without editing every profile?

    opt1mus wrote:Could you paste into this thread your /etc/conf.d/netcfg and the debug output. It's easier for people to help with troubleshooting when actual output is to hand.
    Here it is (network names changed):
    # cat /etc/conf.d/netcfg
    # Enable these netcfg profiles at boot time.
    #   - prefix an entry with a '@' to background its startup
    #   - set to 'last' to restore the profiles running at the last shutdown
    #   - set to 'menu' to present a menu (requires the dialog package)
    # Network profiles are found in /etc/network.d
    NETWORKS=(network1 network2)
    # Specify the name of your wired interface for net-auto-wired
    WIRED_INTERFACE="eth0"
    # Specify the name of your wireless interface for net-auto-wireless
    WIRELESS_INTERFACE="wlan0"
    # Array of profiles that may be started by net-auto-wireless.
    # When not specified, all wireless profiles are considered.
    #AUTO_PROFILES=("profile1" "profile2")
    DHCP_TIMEOUT=30
    # NETCFG_DEBUG="yes" netcfg network1
    DEBUG: Loading profile network1
    DEBUG: Configuring interface wlan0
    :: network1 up                                                                                                                                                                          [ BUSY ] DEBUG: status reported to profile_up as:
    DEBUG: Loading profile network1
    DEBUG: Configuring interface wlan0
    DEBUG: wireless_up start_wpa wlan0 /run/network/wpa.wlan0/wpa.conf nl80211,wext
    Successfully initialized wpa_supplicant
    DEBUG: wireless_up Configuration generated at /run/network/wpa.wlan0/wpa.conf
    DEBUG: wireless_up wpa_reconfigure wlan0
    DEBUG: wpa_cli -i wlan0 -p /run/wpa_supplicant reconfigure
    DEBUG: wireless_up ifup
    DEBUG: wireless_up wpa_check
    DEBUG: Loading profile network1
    DEBUG: Configuring interface wlan0
    DEBUG: ethernet_up bring_interface up wlan0
    DEBUG: ethernet_up dhcpcd -qL -t 10 wlan0
    DEBUG:
    > DHCP IP lease attempt failed.
    DEBUG: Loading profile network1
    DEBUG: Configuring interface wlan0
    DEBUG: Loading profile network1
    DEBUG: Configuring interface wlan0
    DEBUG: ethernet_down bring_interface flush wlan0
    DEBUG: wireless_down stop_wpa wlan0
    DEBUG: wpa_cli -i wlan0 -p /run/wpa_supplicant terminate
    DEBUG: profile_up connect failed

  • Objects running on threads

    Hi everyone,
    I have an engine that I have coded that provides a set of services to various applications. Currently the engine is single-threaded, meaning that if more than one person where to access the same instance of the engine there would be shared data violations. I'm sure that you know the drill...
    So, I am about the add a "UserSpace" class to the engine. Each person that logs into the engine will be assigned a user space, within which is stored information that is pertinent to them (and is isolated from all other users).
    I am familiar with using threads to perform lengthy operations (ie: making an object Runnable and calling the start() method to get things going). But I have never used threads in this way before.
    What I mean is that I want to be able to assign a thread to each user space. In other words every user will have their own unique thread just for them. Method calls on the user space do not need to be synchronized because the information within them is, by definition, not shared. If the user space has to make calls to other areas of the engine then those methods would have to be synchronized but I can deal with that.
    So how would I go about accomplishing this? Is it just a case of implementing Runnable as I normally do, calling start() and then make method calls?
    Thanks in advance for your help. :)
    Ben

    I believe you could accomplish what you wish w/3 classes. In accordance with your example and subsequent explanation, they are as follows:
    public class UserSpace {
    private Object mDataThatIsNotShared; // etc.
    public String methodOne() { /*some code */ }
    public void methodTwo(String s) { /*some code */ }
    public class Server {
    // This class would accept socket connections. For each socket
    // connection accepted, create an object of the third class called
    // ServerThread (see below):
    while (true) {
    // The line below blocks until connection:
    Socket socketAccepted=serverSocket.accept();
    ServerThread srvrThrd=new ServerThread(socketAccepted);
    srvrThrd.start();
    public class ServerThread extends Thread {
    private Socket mSocket;
    private UserSpace userSpace;
    ServerThread(Socket socket) {
    mSocket=socket;
    userSpace=new UserSpace(...); //See, each ServerThread owns its own
    public void run() {
    // Do whatever work you want w/UserSpace.
    Of course, this is way overly simplistic...Does not take into account the fact that you could have unlimited threads...i.e., your Server class needs to implement some sort of thread pool, etc.
    Does this help you?
    --Mike                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Is there a way to abort a processing thread

    Straight forward question... How do I handle timeouts for server-side script execution in a web server?
    Let's say I have a very simple server that only handles one request at a time... A request arrives for a webpage including a piece of some server-side script (that may contain an infinite loop). My server parses the request and starts executing the corresponding script in a new thread. Now, I could do join(timeout) on this thread and then call stop() if the script is still executing... the problem is that stop() is depricated and thus it feels like the wrong approach. But what are my alternatives?

    >
    Re: Is there a way to abort a processing threadNo, there isn't.
    Straight forward question... How do I handle timeouts for server-side script execution in a web server?From the client end or on the server? If it's on the server see the first reply
    Let's say I have a very simple server that only handles one request at a time... A request arrives for a webpage including a piece of some server-side script (that may contain an infinite loop).In general, this is a very very bad thing. You never want to expose functionality to a client that could put you into an infinite loop or kill your system somehow.
    For more information, google for "SQL injection", see what that is and why it's very very evil
    My server parses the request and starts executing the corresponding script in a new thread. Now, I could do join(timeout) on this thread and then call stop() if the script is still executing... the problem is that stop() is depricated and thus it feels like the wrong approach. But what are my alternatives?Stop() is not only deprecated, but it's not implemented / non-functional (at least on my machine).
    The best alternative is not to run anything that you aren't confident at compile time will return in finite time.
    Another alternative that I do not recommend is that there is a debug API... I forget the name - something used in IDEs to get the state of threads + mem, etc. Honestly, I don't think that even that will allow you terminate a thread, but you might want to look into it.

  • Creating threads in Weblogic

    For a variety of reasons I need to write my own messaging bridge between Weblogic and MQ. The reasons have been validated by BEA, so I'm not completely off my rocker :)
    I can either write this as a standalone java application that acts as a client to weblogic's JMS server, or as a deployed webapp (using the ServletContextListener method to start/stop it). Either way the app will <shudder>create one thread per queue</shudder> and listen on that queue until a message arrives.
    The pros of a deployed application (cost-free clustering, management, can use a webapp to manage the threads/queues, etc) leads me in that direction, but creating threads in a J2EE server dubious at best.
    Ideally this webapp runs in its own execute queue, and the holy grail is to have the threads run in that execute queue. However, there doesn't seem to be any supported way to create threads from an execute queue.
    Has anyone done anything like this? Any suggestions on how to spawn and manage the threads properly? Should it be deployed or stand-alone?
    cheers
    mike

    Hello,
    The webapp route sounds better to me than a standalone java app, you will get things up and running a lot more quickly and get all the goodies associated with webapps.
    You don't explicity create threads from the queue for example in the way you get connections from a connection pool. Once you have created and configuered your execute queue you just add a few init parameters to your web.xml deployment descriptor:
    <servlet>
    <servlet-name>MainServlet</servlet-name>
    <jsp-file>/myapplication/critical.jsp</jsp-file>
    <init-param>
    <param-name>wl-dispatch-policy</param-name>
    <param-value>CriticalAppQueue</param-value>
    </init-param>
    </servlet>
    see:
    http://e-docs.bea.com/wls/docs81/perform/AppTuning.html#1105201
    for complete instructions.
    cheers
    Hussein Badakhchani
    www.orbism.com

  • Threads and signature coming through as attachments?

    I'm using MacMail on a G5 running OS10.3.9. and I've recently been getting feedback from clients and friends saying that all my email threads, signatures, etc. are coming through as attachments. Anyone experienced this or have a fix/workaround?
    G5 tower   Mac OS X (10.3.9)  

    Signature as jpg in BlackBerry is not possible till date. It can accept only text formats.
    Message Edited by tanzim on 07-21-2008 12:37 AM
    tanzim                                                                                  
    If your query is resolved then please click on “Accept as Solution”
    Click on the LIKE on the bottom right if the post deserves credit

  • Forum threads.

    I do hope this is the right forum. Using Safari I find the threads / topics etc are highlighted after I have read them and remain that way for several days. Excellent! I find
    it very helpful.
    But using Firefox currently no such highlighting occurs - although I seem to remember that a similar highlighting effect used to occur in Firefox too.
    Would anyone know what might have prompted the loss of the facility in Firefox?

    Problem solved. I had set Firefox in Private Browsing mode, hence it would not register the that I had clicked on various discussions.

  • Displaying an Indeterminate Progress Bar While a DB2 Stored Proceedure Runs

    How do I display a dialog with an indeterminate progress bar while a DB2 query runs? Could anyone point me to an example or some strong docs?
    I learned Java about six months ago, so I'm relatively new to the language. Through searching and documentation, I've been able to find all the examples and answers I've needed so far. Now I've run into an issue I can't find anywhere. It seems like the most basic thing in the world. I have a DB2 stored procedure that takes about 5 minutes to run. While it's running, I want to display a simple dialog with a progress bar going back and forth (no buttons, no user interaction).
    I'm using Eclipse 3.3.1.1 as my IDE, and running the application from a JAR file. I have Java 1.6.0.30 installed. The DB2 query is running in response to a user clicking a button on the form (an ActionEvent). All of my forms are using Swing (JFrame, JDialog, etc.).
    The crux of my problem seems to be that I can bring up a dialog (which should contain the progress bar), but I can't get it to paint. All I get is a window that's the right size/location, but contains an after-image of what was behind it. I can't even get a dialog to display with a "Please Wait" label while the DB2 procedure runs.
    I tried separating both the DB2 stored procedure and the progress dialog into separate threads. I tried yielding in the DB2 thread to give the progress dialog a chance to update. I tried using invokeAndWait, but I got the following error:
    Exception in thread "AWT-EventQueue-0" java.lang.Error: Cannot call invokeAndWait from the event dispatcher thread
    It seems like I'm doing something wrong in my use of Theads, but I can't for the life of me figure out what it is. If anyone could help out a bit of a Java newbie, I would be extremely grateful.

    Demo:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ProgressBarExample2 {
        private JProgressBar bar = new JProgressBar(0,99);
        private JButton button = new JButton("Lengthy operation");
        private ActionListener al = new ActionListener(){
           public void actionPerformed(ActionEvent evt) {
                button.setEnabled(false);
                bar.setIndeterminate(true);
                new Worker().execute();
        private class Worker extends SwingWorker<Boolean, Boolean>{
            protected Boolean doInBackground() {
                try {
                    Thread.sleep(10000); //10 secs
                } catch (InterruptedException e) {
                return Boolean.TRUE;
            protected void done() {
                button.setEnabled(true);
                bar.setIndeterminate(false);
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new ProgressBarExample2();
        ProgressBarExample2() {
            button.addActionListener(al);
            JPanel cp = new JPanel();
            cp.add(button);
            cp.add(bar);
            JFrame f = new JFrame("ProgressBarExample2");
            f.setContentPane(cp);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • Swing interview questions

    I thought this would be the best place to ask some of you all what type of questions should be asked in an interview for a Swing developer. I also would love to have some questions about general GUI development.
    I have to interview a guy and I need to know what to expect from him and this is the first GUI interview I've done.

    So, after discussing this thread with some co-workers we came up with the following, which I think are acceptable GUI and Swing questions. They aren't too hard but aren't easy, and they tend to more relevant than just asking for specific information that can be looked up in the API.
    We did go through them and give some of what should be heard in an answer. These 'answers' aren't catch-alls, and may not have what individual interviewers are looking for but I think they make a good starting point. Some of the questions require a mockup or screenshot to ask them and these weren't included. Since different jobs require different skills an interviewer will need to create their own mockups and screenshots to focus the interview to the job listing.
    Interview Questions
    Graphical User Interface and Swing
    Section 1 - General Swing and GUI Questions
    What types of components have you used?
    This will depend on what the company does but you can never go wrong with JTables and JTrees. If you do MDI development, obviously JInternalFrames might be something you want to hear. The interviewee gets extra points for GridBagLayout experience since it is so powerful but feared by many Java delevopers.
    When you are building a GUI do you prefer to use an IDE or build it by hand?
    You want an employee who can do it by hand but you don't want the person to be inefficient and not use an IDE if it's available. If the person doesn't have any experience with an IDE that's not a plus or minus, it just means they will need to learn (if you are an IDE shop). If the person is only creating GUIs through an IDE builder, that may be a problem but there are other questions to clarify the person's skills.
    What is the difference between AWT and Swing?
    The difference is that an AWT component is a 'heavyweight' and Swing is a 'lightweight' component. Obviously, the interviewee needs to know that a heavyweight component depends on the native environment to draw the components. Swing does not. The interviewee gets extra points for some of the other things Swing brings to the table, like a pluggable look & feel, MVC architecture, and a more robust feature set.
    Can you name four or five layout managers?
    GridBagLayout, GridLayout, BorderLayout, FlowLayout, and CardLayout tend to be the most common. There are others that are listed in the Java API; check out the java.awt.LayoutManager interface for more.
    What is the difference between a component and a container?
    All Swing 'objects' are components, like buttons, tables, trees, text fields, etc. A container is a component that can contain other components. Technically, since JComponent inherits from Container all Swing components are containers as well. However, only a handful of top-level containers exist (JFrame, JDialog, etc.), and to be visible and GUI must start by adding components to a top-level container.
    Some components do not implement their 'add' methods so while they may be containers they do not allow the nesting of other components within their bounds. Specifically, JPanels can be used for component-nesting purposes.
    What would you change about this dialog?
    Using a dialog screenshot that has a poor layout, uses the wrong component for a specific task, has poor spacing between components, allow the interviewee to dissect the dialog and describe what should be done. I would suggest that a completely fictitious dialog is used to remove any personal biases the interviewer might have.
    This definitely needs to come before the next question, since we don't want to taint the interviewee with how we think a dialog should look. So the next question is:
    Explain how you would achieve the layout given this mockup.
    Using a screenshot of a dialog with a fair number of components, the user is to explain how they would get the components to be in the locations that they are in the mockup. This is much like the layout manager question although in this case the skill with the layout managers is being questioned. The weight each interviewer places on this question is up to them, but it can be used to discover whether someone knows about, has used it occasionally, or is intimately familiar with GridBagLayout or other layout managers. Also take into consideration the grouping of logical components in panels that might make a new piece of data that needs to be reflected in the dialog easier to add in later.
    What is the significance of a model in a component (for example, in a JTable or JTree)?
    What are the advantages of using your own model?
    The model in a component is used to fine-tune what the component displays by returning the specific data in specific instances where either the default values are used (a default model) or custom values are used (a custom model).
    When would you use a renderer or editor on a component?
    A renderer is used to create a custom display for the data in a component. The custom display is all that a renderer does. Implementing an editor allows the user to manipulate the data as well as have a custom display. However, once editing is completed the renderer is once again used to display the data.
    Why is Swing not 'thread safe'?
    A Swing application is run completely in the event-dispatching thread. Changes to components are placed in this thread and handled in the order they are received. Since threads run concurrently, making a change to a component in another thread may cause an event in the event-dispatching thread to be irrelevant or override the other thread's change.
    To get around this, code that needs to be run in a thread should be run in the event-dispatching thread. This can be achieved by creating the thread as normal but starting the thread by using SwingUtilities.invokeLater() and SwingUtilities.invokeAndWait().
    What would you do if you had to implement a component you weren't familiar with?
    This question is more about the process a person uses to solve a coding problem. Where do they go to find an answer? The order of the sources of information is just as important as which sources. Asking team members or other co-workers should be first, with other sources like the Internet (documents and forums) and books next. The Java API can also be useful in some cases but I think we have to assume that the component's requirements were more complex than just the API documentation can tell you.
    Section 2 - GUI Design Skills
    In this section, we are going to give the user an example of some inputs that need to be implemented and have them design a GUI for us. This will be completely done on the whiteboard and we don't care about any code. The timeframe is irrelevant so any component or custom component can be used.
    What we are looking for:
    - A design that focuses on the workflow from the user's perspective.
    - The proper components used to represent the data, but also
    - Unique and interesting ways of displaying data.

  • Signalling between two Windows

    I am not sure how to signal between two Windows created in the same Thread.
    Suppose I have two Windows, WindowA and WindowB (either is a descendent from the Window hierarchy - ie. JFrame, JDialog, etc.).
    WindowB can be instantiated with different parameters that cause it to look different.
    I want to do something like this in a method in my WindowA class: (pseudo-code)
    for int 1 to n
    hide this window; (i.e. WindowA)
    instantiate and display a new WindowB object (with xxxxx parameters)
    wait for WindowB to signal this WindowA object that it should
    now create a new WindowB object and display that new object
    somewhere in Class code for WindowB
    signal WindowA;
    How do I set up a "wait and signal" between the two Windows? Without it, WindowA will keep going through the for loop creating new Windows immediately -> I would like it to wait until WindowB signals that it is ok to do so.
    Thanks for any help.
    -TJW

    Here's an example:
    class CreateWindows {
         int count = 0;
         int limit = 5;
         public CreateWindows(int limit) {
              this.limit = limit;
              create();
         void create() {
              if (++count < limit) {
                   new WindowA(new SignalListener() {
                        public void signal() {
                             create();
    interface SignalListener {
         void signal();
    class WindowA {
         public WindowA(SignalListener listener) {
              // do things
              listener.signal();

Maybe you are looking for

  • Is there a way to sort by songs that require a password or marked with !

    My laptop was wiped clean and I had to fetch all backed up songs from external. Now many songs have ! marks next to them and others require an old user name and password. Is there any way to view these by sorting so I don't just have to stumble upon

  • Why is a ripped DVD much bigger when imported to iDVD?

    HI I am quite confused and cant find any help on this. I have a DVD which I ripped to the computer. If I import the resulting mv4 files to iDVD it becomes over 10Gb and is too big to go back on a DVD. What I am trying to do is copy a DVD. Its a DVD a

  • Batch Activation for existing material

    Dear All, We have uploaded material last year that time we are not used batch management, now our clients requirement is to activate batch for the existing material, this materials has lot of transactions & stock is availabele in unresticated, Qualit

  • PDF merge limitations...

    I have a question for the Acrobat gurus. I can merge multi pdfs up to 106 pages. My problem is that we deal with high page count media and I am having issues with merging anything over 106 PDFs into one at a time. When Acrobat is merging, it hits pag

  • Opening a new form by clicking a button...

    How is it possible to open a new form by clicking a button in a form? I have tried following methods: htp.formOpen(owa_util ... go('<URL>'), call('<URL>'), portal30.www_user_utilities.get_url ... portal30.wwa_app_module.link ...