Waiting for a JFrame to dispose

Hello,
i have this situation: i have 2 JFrames, let's say JFrame1 and JFrame2.
JFrame1 invokes and displays JFrame2, like this:
/* JFrame1 code */
JFrame2 f2 = new JFrame2();
f2.setVisible(true);
//wait f2 to dispose
other code...My problem is how to make JFrame1 to wait until the dispose call of the other frame, and then execute the "other code"...
I tried some solutions..like a busy waiting on some flag..or using a CountDownLatch..but i didn't solve the problem...
It seems that everything i use to stop the execution of JFrame1, stops JFrame2 also, even if i run it as a new thread.
I hope someone can give me some hints!

Use a modal JDialog.
[http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html]

Similar Messages

  • Getting a JFrame to display  from a JSP, remaining JSP code waits for frame

    Hello,
    I'm new to Java and just started using JSPs. My objective is to call a display window (from a JSP) that shows the user a list of project selections. Once the user has made their selections and clicked a Submit button, the display class captures the selected projects to the request object as an attribute and then closes the window. The next command in the jsp then forwards the request attribute to a controller. I'm having trouble getting the display window to show-the JSP seems to hang and then timeout. Is there code I'm missing to get the JSP to stop processing while it waits for the choices to be made in the JFrame?
    Below is the JSP code and the class I'm calling. I'm seeing all my debug System.out statements but no JFrame pops up. In the JFrame class, the line f.addWindowListener(... does the capture of user selections to the request attribute.
    Any help will be greatly appreciated!!
    JSP:
    <%@ page language="java" contentType="text/html;charset=UTF-8" import="com.plumtree.remote.portlet.*,edu.app.projects.*" %>
    <%
        request.setAttribute("action", "prefDisplay");
        request.setAttribute("orderby", "title");
        ServletContext jc = getServletContext();
        DualListBox dual = new DualListBox(request,(String)jc.getAttribute("db.driver"), (String)jc.getAttribute("db.connectionstring"),"title");
         JFrame f = dual.getFrame();
         f.setVisible(true);//expect code to stop here and display frame, waiting for the user to finish.
            //Debug code that tests if frame is visible at this point -came true though did not see Jframe displayed
         if(f.isShowing()){
         System.out.println("Jframe visible");}
           //Send to ProjectsController
          request.getRequestDispatcher("pc").forward(request, response);%>               ---------------------------------------------------------------------------------------------
    JFrame Class (below)
    -Sets up Frame and corresponding Dialog box
    -Populates Dialog box with options from a database call (for user selection)
    -Should wait for user input - Window close or Submit! to capture selection and dispose of Jframe
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.EventQueue;
    import java.awt.Frame;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowEvent;
    import java.lang.reflect.InvocationTargetException;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.ArrayList;
    import java.util.Arrays;
    import java.util.Collection;
    import java.util.Iterator;
    import java.util.SortedSet;
    import java.util.TreeSet;
    import javax.servlet.http.HttpServletRequest;
    import javax.swing.AbstractListModel;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JList;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.ListCellRenderer;
    import javax.swing.ListModel;
    public class DualListBox extends JPanel {
      private static final long serialVersionUID = 1L;
      private static final Insets EMPTY_INSETS = new Insets(0, 0, 0, 0);
      private static final String ADD_BUTTON_LABEL = "Add >>";
      private static final String REMOVE_BUTTON_LABEL = "<< Remove";
      private static final String DONE_BUTTON_LABEL = "Submit!";
      private static final String DEFAULT_SOURCE_CHOICE_LABEL = "Available Projects";
      private static final String DEFAULT_DEST_CHOICE_LABEL = "Your Selections";
      private String orderby, mydriver, connectionString;
      private JLabel sourceLabel;
      private JList sourceList;
      private SortedListModel sourceListModel;
      private JList destList;
      private String chosenprojects;
      private SortedListModel destListModel;
      private JLabel destLabel;
      private JButton addButton;
      private JButton removeButton;
      private JButton doneButton;
      private DatabaseHelper dh;
      protected HttpServletRequest request;
      protected JFrame f;
      protected JDialog jd;
      public DualListBox(HttpServletRequest req, String driver, String connection, String ordering) {
         System.out.println("In DualList Setup");
        request =req;
         orderby =ordering;
         connectionString = connection;
         mydriver = driver;
         f = new JFrame("Projects List Selector");     
         jd =new JDialog(f,true);
         jd.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
         System.out.println("B4 initscreen");
        initScreen();
        System.out.println("After initscreen");
        String[] DBprojects = this.dbCall();
        System.out.println("After DB Call");
        this.addSourceElements( DBprojects );   
        System.out.println("Filled screen");
        jd.getContentPane().add(this, BorderLayout.CENTER);
        //f.getContentPane().add(jd, BorderLayout.CENTER);
        jd.setSize(800, 600);
        System.out.println("OK2");
        jd.setVisible(true);
        System.out.println("OK3");
        Runnable runner = new FrameShower(jd);
        EventQueue.invokeLater(runner);
      public String getSourceChoicesTitle() {
        return sourceLabel.getText();
      public String chosenprojects() {
             return chosenprojects;
      public JFrame getFrame() {
             return f;
      public void setSourceChoicesTitle(String newValue) {
        sourceLabel.setText(newValue);
      public String getDestinationChoicesTitle() {
        return destLabel.getText();
      public void setDestinationChoicesTitle(String newValue) {
        destLabel.setText(newValue);
      public void clearSourceListModel() {
        sourceListModel.clear();
      public void clearDestinationListModel() {
        destListModel.clear();
      public void addSourceElements(ListModel newValue) {
        fillListModel(sourceListModel, newValue);
      public void setSourceElements(ListModel newValue) {
        clearSourceListModel();
        addSourceElements(newValue);
      public void addDestinationElements(ListModel newValue) {
        fillListModel(destListModel, newValue);
      private String[] dbCall(){
             if(dh==null)
                  dh = new DatabaseHelper(mydriver, connectionString);
              PreparedStatement ps = null;
              ResultSet rs = null;
              ArrayList<String>children = new ArrayList<String>();
              ArrayList<String[]>tree =new ArrayList<String[]>();
              if(orderby==null || orderby.equals("")){
                   orderby ="region";
              String query = "select title,id from projects";// order by " + orderby;
              System.out.println(query);
              try {
                   Connection conn =dh.getConnection();
                   ps = conn.prepareStatement(query);
                   rs = ps.executeQuery();
                   while (rs.next()) {
                        children.add(new String(rs.getString(1)));
                        System.out.println(rs.getString(1));
                        tree.add(new String[]{rs.getString(1),rs.getString(2)});
                   request.setAttribute("ResultTree",tree);
                   return (String[])children.toArray(new String[children.size()]);
              } catch (SQLException e) {
                   throw new RuntimeException(e);
              } finally {
                   try {
                        if (null != rs) rs.close();
                   } catch (SQLException e) {
                   try {
                        if (null != ps) ps.close();
                   } catch (SQLException e) {
      private void fillListModel(SortedListModel model, ListModel newValues) {
        int size = newValues.getSize();
        for (int i = 0; i < size; i++) {
          model.add(newValues.getElementAt(i));
      public void addSourceElements(Object newValue[]) {
        fillListModel(sourceListModel, newValue);
      public void setSourceElements(Object newValue[]) {
        clearSourceListModel();
        addSourceElements(newValue);
      public void addDestinationElements(Object newValue[]) {
        fillListModel(destListModel, newValue);
      private void fillListModel(SortedListModel model, Object newValues[]) {
        model.addAll(newValues);
      public Iterator sourceIterator() {
        return sourceListModel.iterator();
      public Iterator destinationIterator() {
        return destListModel.iterator();
      public void setSourceCellRenderer(ListCellRenderer newValue) {
        sourceList.setCellRenderer(newValue);
      public ListCellRenderer getSourceCellRenderer() {
        return sourceList.getCellRenderer();
      public void setDestinationCellRenderer(ListCellRenderer newValue) {
        destList.setCellRenderer(newValue);
      public ListCellRenderer getDestinationCellRenderer() {
        return destList.getCellRenderer();
      public void setVisibleRowCount(int newValue) {
        sourceList.setVisibleRowCount(newValue);
        destList.setVisibleRowCount(newValue);
      public int getVisibleRowCount() {
        return sourceList.getVisibleRowCount();
      public void setSelectionBackground(Color newValue) {
        sourceList.setSelectionBackground(newValue);
        destList.setSelectionBackground(newValue);
      public Color getSelectionBackground() {
        return sourceList.getSelectionBackground();
      public void setSelectionForeground(Color newValue) {
        sourceList.setSelectionForeground(newValue);
        destList.setSelectionForeground(newValue);
      public Color getSelectionForeground() {
        return sourceList.getSelectionForeground();
      public String getProjects(){
           return chosenprojects;
      private void clearSourceSelected() {
        Object selected[] = sourceList.getSelectedValues();
        for (int i = selected.length - 1; i >= 0; --i) {
          sourceListModel.removeElement(selected);
    sourceList.getSelectionModel().clearSelection();
    private void clearDestinationSelected() {
    Object selected[] = destList.getSelectedValues();
    for (int i = selected.length - 1; i >= 0; --i) {
    destListModel.removeElement(selected[i]);
    destList.getSelectionModel().clearSelection();
    private void initScreen() {
    setBorder(BorderFactory.createEtchedBorder());
    setLayout(new GridBagLayout());
    sourceLabel = new JLabel(DEFAULT_SOURCE_CHOICE_LABEL);
    sourceListModel = new SortedListModel();
    sourceList = new JList(sourceListModel);
    add(sourceLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0,
    GridBagConstraints.CENTER, GridBagConstraints.NONE,
    EMPTY_INSETS, 0, 0));
    add(new JScrollPane(sourceList), new GridBagConstraints(0, 1, 1, 5, .5,
    1, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
    EMPTY_INSETS, 0, 0));
    addButton = new JButton(ADD_BUTTON_LABEL);
    add(addButton, new GridBagConstraints(1, 2, 1, 2, 0, .25,
    GridBagConstraints.CENTER, GridBagConstraints.NONE,
    EMPTY_INSETS, 0, 0));
    addButton.addActionListener(new AddListener());
    removeButton = new JButton(REMOVE_BUTTON_LABEL);
    add(removeButton, new GridBagConstraints(1, 4, 1, 2, 0, .25,
    GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(
    0, 5, 0, 5), 0, 0));
    removeButton.addActionListener(new RemoveListener());
    doneButton = new JButton(DONE_BUTTON_LABEL);
    add(doneButton, new GridBagConstraints(1, 6, 1, 2, 0, .25,
    GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(
    0, 10, 0, 10), 0, 0));
    doneButton.addActionListener(new DoneListener());
    f.addWindowListener(new java.awt.event.WindowAdapter() {
         public void windowClosing(WindowEvent winEvt) {
              //could set to null here to force use of Done button only
         chosenprojects = destList.getSelectedValues().toString();
              request.setAttribute("ProjectIDs", destList.getSelectedValues().toString());
              System.exit(0);
    destLabel = new JLabel(DEFAULT_DEST_CHOICE_LABEL);
    destListModel = new SortedListModel();
    destList = new JList(destListModel);
    add(destLabel, new GridBagConstraints(2, 0, 1, 1, 0, 0,
    GridBagConstraints.CENTER, GridBagConstraints.NONE,
    EMPTY_INSETS, 0, 0));
    add(new JScrollPane(destList), new GridBagConstraints(2, 1, 1, 5, .5,
    1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
    EMPTY_INSETS, 0, 0));
    private class AddListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
    Object selected[] = sourceList.getSelectedValues();
    addDestinationElements(selected);
    clearSourceSelected();
    private class RemoveListener implements ActionListener {
    public void actionPerformed(ActionEvent e) {
    Object selected[] = destList.getSelectedValues();
    addSourceElements(selected);
    clearDestinationSelected();
    private class DoneListener implements ActionListener {
         public void actionPerformed(ActionEvent e) {
         chosenprojects = destList.getSelectedValues().toString();
         request.setAttribute("ProjectIDs", destList.getSelectedValues().toString());
         System.exit(0);      
    class FrameShower implements Runnable {
         final JDialog frame;
         public FrameShower(JDialog frame) {
              this.frame = frame;
         public void run() {
              System.out.println("B4 make visible");
              frame.setVisible(true);          
         System.out.println("Made screen visible");
    class SortedListModel extends AbstractListModel {
    private static final long serialVersionUID = 8777627817685130496L;
    SortedSet model;
    public SortedListModel() {
    model = new TreeSet();
    public int getSize() {
    return model.size();
    public Object getElementAt(int index) {
    return model.toArray()[index];
    public void add(Object element) {
    if (model.add(element)) {
    fireContentsChanged(this, 0, getSize());
    public void addAll(Object elements[]) {
    Collection c = Arrays.asList(elements);
    model.addAll(c);
    fireContentsChanged(this, 0, getSize());
    public void clear() {
    model.clear();
    fireContentsChanged(this, 0, getSize());
    public boolean contains(Object element) {
    return model.contains(element);
    public Object firstElement() {
    return model.first();
    public Iterator iterator() {
    return model.iterator();
    public Object lastElement() {
    return model.last();
    public boolean removeElement(Object element) {
    boolean removed = model.remove(element);
    if (removed) {
    fireContentsChanged(this, 0, getSize());
    return removed;
    }{code}
    Edited by: redm14A on Oct 10, 2007 11:34 AM
    Edited by: redm14A on Oct 10, 2007 11:37 AM
    Edited by: redm14A on Oct 10, 2007 11:40 AM
    Edited by: redm14A on Oct 10, 2007 11:45 AM
    Edited by: redm14A on Oct 10, 2007 11:47 AM

    redm14A wrote:
    Hmm, I was trying to avoid writing an applet. Seems my only other option then is to write a JSP that returns a javascript menu populated by options from a database call. Then I'd have the user click submit to send the options to another JSP that simply sets the request attribute and forwards to the controller. Will this be a sound alternative?
    Edited by: redm14A on Oct 10, 2007 12:29 PMSounds good to me.

  • Trying to wait for a button press on a seperate JFrame- problems.

    Hi,
    I've been getting aquainted with Java recently. I'd like to think I was reasonable now at creating console based applications but I'm having a lot of trouble getting used to the swing API. I'm making a little game type thing at the moment and part of it involves displaying a problem to the user in a seperate JFrame and returning which option they picked. If I was doing this in a console based App I'd probably do something along the lines of:
         while (UserInput == null) { //while they haven't entered anything continue to loop.
              UserInput = InputScanner.next(); //get the user's input
         }I thought I'd do something similar for my JFrame based app but haven't been able to do it. I essentially would like the code to not execute past a certain point until one of the options on the JFrame has been picked. Here's the code for the JFrame showing the dilemma to the user:
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    * This is the window displayed to a user with dilemma details
    public class DilemmaWindow extends JFrame implements ActionListener {
        int OptionPicked = 0; //the option the user picks
        JLabel DescriptionLabel;
        JButton Button1;
        JButton Button2;
        public DilemmaWindow(String WindowTitle, String LabelText, String Button1Text, String Button2Text) {
            //construct the JFrame with the relevant parameters
            setTitle(WindowTitle);
            setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
            setLayout(new FlowLayout(FlowLayout.CENTER));
            Button1 = new JButton(Button1Text);
            Button2 = new JButton(Button2Text);
            Button1.addActionListener(this);
            Button2.addActionListener(this);
            DescriptionLabel = new JLabel();
            DescriptionLabel.setText(LabelText);
            add(DescriptionLabel);
            add(Button1);
            add(Button2);
            pack();
            setVisible(true);
        public void actionPerformed(ActionEvent evt) {
            //determine which button was clicked and set OptionPicked accordingly
            if(evt.getSource() == Button1) {
                OptionPicked = 1;
            } else {
                OptionPicked = 2;
        public int GetDilemmaChoice() {
            if (OptionPicked > 0) { //if an option was picked
            this.dispose(); //clean up the window
            return OptionPicked; //return which option was picked
    }The idea of this being that it constructs a window and when the GetDilemmaChoice() function is called it'll return which button has been clicked.
    I do, as I said, want to wait until one of the buttons has been clicked before continuing with the execution of the code in the class that constructs the JFrame, so I made the following function:
    public int GetDilemmaChoice() {
            int Choice = 0;
            DilemmaWindow MyDilemmaWindow = new DilemmaWindow(CaperDilemma.GetDilemmaName(),CaperDilemma.GetDilemmaDescription(),CaperDilemma.GetOption1Text(),CaperDilemma.GetOption2Text());
            while (Choice == 0) {
                Choice = MyDilemmaWindow.GetDilemmaChoice();      
            return Choice;
        }The idea being that while the window returns that no buttons have been clicked the function loops round. The problem I'm having is that the while loop continually looping seems to hog all the CPU time or something, as the dilemma JFrame doesn't display properly (I get a blank window, with none of the buttons) and so I can't click any of the options. I've been banging my head against a brick wall all day trying to get round this and am wondering if I should put the looping in a seperate thread or something. Sadly, though, I don't know anything about threads so wouldn't know where to start.
    If anyone has any idea of how to solve this problem I'd be very grateful! I hope I've managed to explain it well enough.

    Why not use a modal JDialog here and not a JFrame. You probably shouldn't be coding directly to a JFrame (or JDialog) anyway but to a JPanel that can be placed on the proper root container of choice (which again here is a JDialog). You can make your JPanel as complex as desired, then place it in the JDialog, make that dialog application modal, and when you show it via setVisible(true), the application will halt at that point until the dialog has been dealt with.

  • Make jFrame wait for jDialog to finish

    I am making a project in Netbeans i have a main Frame and some Dialog windows that open up if you press some buttons.
    when one window opens i want the main Frame script to pause and wait for it to complete.
    i have tried 3 different ways:
    questionDialog.setVisible(true);
    while (questionDialog.isVisible()) {
        try {
            Thread.sleep(200);
        } catch (Exception e) {
    } but that shows the frame of the dialog box but never loads the inside and the whole application freezes.
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            questionDialog.setVisible(true);
    while (questionDialog.isVisible()) {
        try {
            Thread.sleep(200);
        } catch (Exception e) {
    }that loaded my Dialog box but the script never waits for it to close i assume it is because it waits until "later" to show the dialog box and in that time it skips the while loop.
    Thread t = new Thread(new Runnable() {
        public void run() {
            questionDialog.setVisible(true);
            while (questionDialog.isVisible()) {
                try {
                    Thread.sleep(200);
                } catch (Exception e) {
    t.start();
    System.out.println("Dialog started");
    System.out.println(questionDialog.isVisible());
    try {
        t.join();
    } catch (Exception e) {
    }but that had the same result as the first code it waited but never showed the dialog.
    where am i going wrong how should i go about this?
    Scott.
    EDIT:
    by finish i mean become not Visible. so isVisible() will return false
    Edited by: ratcateme on Nov 20, 2008 3:02 PM

    You don't have to do anything to do that
    questionDialog.setVisible(true), this method will block the thread, it would't keep going until the questionDialog is unvisible, this is the mistake of the way 1 and way 3.
    and the way 2: the while block will be execute before the questionDialog.setVisible(true) is execute, so questionDialog.isVisible() will return false
    my en is very poor, good luck!

  • Waiting for R/3 respose for a long time

    Hi,
    I am creating a loss disposal invoice,
    The status of the invoice is in ' Billing document already being transferred'. It should change to ' Billing document transferred'.
    In the MW cockpit, these messages are in the status 'waiting for R/3 response'
    In the MW Monitor, the BDocs are in ' Intermediate state o01'
    The connections seem fine between CRM and ERP.
    Can anyone help please.
    Pratima

    Dear Pratima,
    the Bdocs are in intermediate status because no response is coming from R/3 due to a short dump or update termination in your R/3 system.
    You should also be able to see the errors in CRM, transaction SMW01.
    Please reward points if it helps you.
    Regards, José Ignacio

  • How to know the child JFrame  is dispose

    There are two JFrames, the first one is a parent, and the second is child and created by the parent.
    How to parent knows the child disposed.
    Because of the other member functions of parent shall be running while child is disposed.

    hi!
    do you know about window listener ? if not then learn it, it will solve your problem i hope.
    http://www.java-tips.org/java-se-tips/javax.swing/how-to-use-windowlistener-for-closing-jframes.html
    regards
    Aniruddha

  • Need to wait for answer

    In the following code, my get.start(); lines, opens another jframe that is used to accept values from the user. There are 2 textfields on the jframe that the user is entering information into. However, once the get.start(); is called, the function proceeds on with itself, and doesn't wait for an answer from the jframe, which is something I understand and know, but my issue is, getting it to wait for the user to input information. I'm not sure what I can do to wait for the information before my code goes through and runs the if(goahead){.... code. 
      public void uploadFile(){
            //   patronObject patron = new patronObject();
            boolean goahead = true;
            getInfo get = new getInfo();
            int result = filechooser.showOpenDialog(this);
            if (result == filechooser.APPROVE_OPTION){
                String filename = filechooser.getSelectedFile().getAbsolutePath();
                System.out.println("filename = " + filename);
                if (filename.toLowerCase().endsWith(".pdf") || filename.toLowerCase().endsWith(".PDF")){
                    try {
                        System.out.println("filename in uploadFILE = " + filename);
                        FileInputStream input = new FileInputStream(new File(filename));
                        ByteArrayOutputStream output = new ByteArrayOutputStream();
                        byte[] buf = new byte[1024];
                        byte[] data = null;
                        long num = 0;
                        int numBytesRead = 0;
                        while ((numBytesRead = input.read(buf)) != -1) {
                            output.write(buf, 0, numBytesRead);
                        get.start();
                        if(goahead){
                            //   patronObject patron = new patronObject();
                            System.out.println("go to the printing section");
                            patron.setAction("updatePDF");
                            patron.setPatronID(get.getPatronID());
                            patron.setPDFName(get.getPdfName());
                            patron.setPDF(output.toByteArray());
                            sendPatron();
                    }catch(FileNotFoundException ex) {
                        ex.printStackTrace();
                    } catch (IOException ex) {
                        ex.printStackTrace();
                }else{
                    JOptionPane.showMessageDialog(null, "Please make sure to select only a PDF file");
        }

    Use a modal JDialog or JOptionPane.showInputdialog(...) instead of JFrame.
    In future, Swing questions should be posted in the [Swing forum|http://forum.java.sun.com/forum.jspa?forumID=57]
    db

  • Jdev freeze while waiting for "something"

    Hi All,
    I have problem in my jdeveloper. everytime when i open my jsp file (contains ADF component) and it is freeze and when i look at the thread information, it is waiting for my internal db connection. If i try to comment out, it is fine but when i am going to deploy, i have to dis-comment my db connection. After that, i open another jsp file, the problem comes out again even i have comment out my db connection after deployment.
    thx for reply and here is the thread information:
    Full thread dump Java HotSpot(TM) Client VM (1.5.0_05-b05 mixed mode):
    "Designer-Layout-Dispatcher" prio=7 tid=0x2e561028 nid=0x2cc in Object.wait() [0x3dfef000..0x3dfef9e4]
    at java.lang.Object.wait(Native Method)
    - waiting on <0x09ca2968> (a oracle.jdevimpl.webapp.view.DisplayManager$RefreshQueue)
    at java.lang.Object.wait(Object.java:474)
    at oracle.jdevimpl.webapp.view.DisplayManager$RefreshDispatcher.run(DisplayManager.java:1436)
    - locked <0x09ca2968> (a oracle.jdevimpl.webapp.view.DisplayManager$RefreshQueue)
    at java.lang.Thread.run(Thread.java:595)
    "Designer-Layout-Dispatcher [file:/C:/Projekts/ViewController/public_html/UserManagement.jsp]" prio=7 tid=0x2e6e75d8 nid=0x5d0 in Object.wait() [0x3c57f000.
    at java.lang.Object.wait(Native Method)
    - waiting on <0x08fa15f8> (a oracle.jdevimpl.webapp.view.DisplayManager$RefreshQueue)
    at java.lang.Object.wait(Object.java:474)
    at oracle.jdevimpl.webapp.view.DisplayManager$RefreshDispatcher.run(DisplayManager.java:1436)
    - locked <0x08fa15f8> (a oracle.jdevimpl.webapp.view.DisplayManager$RefreshQueue)
    at java.lang.Thread.run(Thread.java:595)
    "JSP VE Design Time Thread: ViewController.jpr 1145178935291" prio=7 tid=0x375d0030 nid=0x488 runnable [0x39b7e000..0x39b7f9e4]
    at java.net.Inet4AddressImpl.getHostByAddr(Native Method)
    at java.net.InetAddress$1.getHostByAddr(InetAddress.java:842)
    at java.net.InetAddress.getHostFromNameService(InetAddress.java:532)
    at java.net.InetAddress.getHostName(InetAddress.java:475)
    at java.net.InetAddress.getHostName(InetAddress.java:447)
    at java.net.InetSocketAddress.getHostName(InetSocketAddress.java:210)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:341)
    at java.net.Socket.connect(Socket.java:507)
    at java.net.Socket.connect(Socket.java:457)
    at java.net.Socket.<init>(Socket.java:365)
    at java.net.Socket.<init>(Socket.java:178)
    at org.postgresql.core.PGStream.<init>(PGStream.java:60)
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:77)
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:65)
    at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:116)
    at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
    at org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
    at org.postgresql.Driver.makeConnection(Driver.java:369)
    at org.postgresql.Driver.connect(Driver.java:245)
    at java.sql.DriverManager.getConnection(DriverManager.java:525)
    - locked <0x27504420> (a java.lang.Class)
    at java.sql.DriverManager.getConnection(DriverManager.java:171)
    - locked <0x27504420> (a java.lang.Class)
    at com.oneNetwork.accountingSystem.common.DAO.GeneralDBDAO.getConnection(GeneralDBDAO.java:36)
    at com.oneNetwork.accountingSystem.common.DAO.CountryDAOPostgresql.getCountryList(CountryDAOPostgresql.java:172)
    at com.oneNetwork.accountingSystem.common.valueobjects.basic.CountryVO.getCountriesList(CountryVO.java:78)
    at com.oneNetwork.accountingSystem.webclient.actions.CountryAction.getList(CountryAction.java:24)
    at com.oneNetwork.accountingSystem.webclient.forms.UserRegister.createCountryList(UserRegister.java:189)
    at com.oneNetwork.accountingSystem.webclient.forms.UserRegister.load(UserRegister.java:137)
    at com.oneNetwork.accountingSystem.webclient.forms.UserRegister.<init>(UserRegister.java:103)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
    at oracle.jdevimpl.webapp.design.renderer.utils.RenderUtils.createBean(RenderUtils.java:232)
    at oracle.jdevimpl.webapp.design.renderer.FacesActionRenderer._addManagedBean(FacesActionRenderer.java:1938)
    at oracle.jdevimpl.webapp.design.renderer.FacesActionRenderer._initialize(FacesActionRenderer.java:1911)
    at oracle.jdevimpl.webapp.design.renderer.FacesActionRenderer._initializeFromFacesConfig(FacesActionRenderer.java:1895)
    at oracle.jdevimpl.webapp.design.renderer.FacesActionRenderer.tagInitialize(FacesActionRenderer.java:1079)
    at oracle.jdevimpl.webapp.design.renderer.DesignTimeJspActionRenderer.renderCustomParentNode(DesignTimeJspActionRenderer.java:877)
    at oracle.jdevimpl.webapp.design.renderer.utils.FacesUtils.renderFakeNamespaceContainer(FacesUtils.java:179)
    at oracle.jdevimpl.webapp.design.support.jsp.DesignTimeJspServlet._renderSource(DesignTimeJspServlet.java:183)
    at oracle.jdevimpl.webapp.design.support.jsp.DesignTimeJspServlet.serviceJsp(DesignTimeJspServlet.java:109)
    at oracle.jdevimpl.webapp.design.support.jsp.DesignTimeJspServlet.service(DesignTimeJspServlet.java:73)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at oracle.jdevimpl.webapp.design.support.http.DesignTimeServletInfo.service(DesignTimeServletInfo.java:268)
    at oracle.jdevimpl.webapp.design.support.http.DesignTimeRequestDispatcher.dispatch(DesignTimeRequestDispatcher.java:197)
    at oracle.jdevimpl.webapp.design.support.http.DesignTimeRequestDispatcher.forward(DesignTimeRequestDispatcher.java:72)
    at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
    at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
    at oracle.adfinternal.view.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:157)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
    at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
    at oracle.jdevimpl.webapp.design.support.http.DesignTimeServletInfo.service(DesignTimeServletInfo.java:268)
    at oracle.jdevimpl.webapp.design.support.http.DesignTimeRequestDispatcher$DesignTimeFilterChain.doFilter(DesignTimeRequestDispatcher.java:315)
    at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._invokeDoFilter(AdfFacesFilterImpl.java:367)
    at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl._doFilterImpl(AdfFacesFilterImpl.java:336)
    at oracle.adfinternal.view.faces.webapp.AdfFacesFilterImpl.doFilter(AdfFacesFilterImpl.java:196)
    at oracle.adf.view.faces.webapp.AdfFacesFilter.doFilter(AdfFacesFilter.java:87)
    at oracle.jdevimpl.webapp.design.support.http.DesignTimeRequestDispatcher$DesignTimeFilterChain.doFilter(DesignTimeRequestDispatcher.java:292)
    at oracle.jdevimpl.webapp.design.support.http.DesignTimeRequestDispatcher.dispatch(DesignTimeRequestDispatcher.java:193)
    at oracle.jdevimpl.webapp.design.support.http.DesignTimeServletContainerContext._service(DesignTimeServletContainerContext.java:611)
    at oracle.jdevimpl.webapp.design.support.http.DesignTimeServletContainerContext.service(DesignTimeServletContainerContext.java:570)
    at oracle.jdevimpl.webapp.design.DesignTimeRenderThread.runImpl(DesignTimeRenderThread.java:264)
    - locked <0x08082168> (a oracle.jdevimpl.webapp.design.DesignTimeRenderThread)
    at oracle.jdevimpl.webapp.design.DesignTimeThread.run(DesignTimeThread.java:147)
    "CssObservreTimer" daemon prio=5 tid=0x376c9878 nid=0x6a4 in Object.wait() [0x39a7f000..0x39a7fa64]
    at java.lang.Object.wait(Native Method)
    - waiting on <0x08082280> (a java.util.TaskQueue)
    at java.lang.Object.wait(Object.java:474)
    at java.util.TimerThread.mainLoop(Timer.java:483)
    - locked <0x08082280> (a java.util.TaskQueue)
    at java.util.TimerThread.run(Timer.java:462)
    "IdeMinPriorityTimer" daemon prio=2 tid=0x375847c8 nid=0x4c4 in Object.wait() [0x3947f000..0x3947fd64]
    at java.lang.Object.wait(Native Method)
    - waiting on <0x07d4c028> (a java.util.TaskQueue)
    at java.lang.Object.wait(Object.java:474)
    at java.util.TimerThread.mainLoop(Timer.java:483)
    - locked <0x07d4c028> (a java.util.TaskQueue)
    at java.util.TimerThread.run(Timer.java:462)
    "AuditExecutor-15" daemon prio=7 tid=0x2e4955c8 nid=0x690 in Object.wait() [0x38c7f000..0x38c7fae4]
    at java.lang.Object.wait(Native Method)
    - waiting on <0x06b15110> (a oracle.javatools.util.SynchronizedQueue)
    at java.lang.Object.wait(Object.java:474)
    at oracle.javatools.util.SynchronizedQueue.remove(SynchronizedQueue.java:61)
    - locked <0x06b15110> (a oracle.javatools.util.SynchronizedQueue)
    at oracle.jdevimpl.audit.util.SwingExecutor.run(SwingExecutor.java:467)
    at java.lang.Thread.run(Thread.java:595)
    "WaitCursorTimer" daemon prio=5 tid=0x2da7f568 nid=0x3d0 in Object.wait() [0x3895f000..0x3895fce4]
    at java.lang.Object.wait(Native Method)
    - waiting on <0x0671c150> (a java.util.TaskQueue)
    at java.lang.Object.wait(Object.java:474)
    at java.util.TimerThread.mainLoop(Timer.java:483)
    - locked <0x0671c150> (a java.util.TaskQueue)
    at java.util.TimerThread.run(Timer.java:462)
    "BufferDomModel background parse thread" daemon prio=2 tid=0x2da7e490 nid=0x654 in Object.wait() [0x3885f000..0x3885fd64]
    at java.lang.Object.wait(Native Method)
    - waiting on <0x06051f88> (a java.util.TaskQueue)
    at java.lang.Object.wait(Object.java:474)
    at java.util.TimerThread.mainLoop(Timer.java:483)
    - locked <0x06051f88> (a java.util.TaskQueue)
    at java.util.TimerThread.run(Timer.java:462)
    "WeakDataReference polling" prio=2 tid=0x368297d0 nid=0x630 in Object.wait() [0x3875f000..0x3875f9e4]
    at java.lang.Object.wait(Native Method)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
    - locked <0x06050ac8> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
    at oracle.ide.util.WeakDataReference$Cleaner.run(WeakDataReference.java:88)
    at java.lang.Thread.run(Thread.java:595)
    "Native Directory Watcher" prio=2 tid=0x373618d0 nid=0x4fc runnable [0x3855f000..0x3855fae4]
    at oracle.ide.natives.NativeHandler.enterWatcherThread(Native Method)
    at oracle.ide.natives.NativeHandler$1.run(NativeHandler.java:244)
    at java.lang.Thread.run(Thread.java:595)
    "IconOverlayTracker Timer" prio=5 tid=0x3738f010 nid=0x2f8 in Object.wait() [0x3845f000..0x3845fb64]
    at java.lang.Object.wait(Native Method)
    - waiting on <0x05ffe648> (a java.util.TaskQueue)
    at java.lang.Object.wait(Object.java:474)
    at java.util.TimerThread.mainLoop(Timer.java:483)
    - locked <0x05ffe648> (a java.util.TaskQueue)
    at java.util.TimerThread.run(Timer.java:462)
    "TimerQueue" daemon prio=5 tid=0x2dc17ec0 nid=0x500 in Object.wait() [0x2e3ff000..0x2e3ffd64]
    at java.lang.Object.wait(Native Method)
    - waiting on <0x059a0678> (a javax.swing.TimerQueue)
    at javax.swing.TimerQueue.run(TimerQueue.java:233)
    - locked <0x059a0678> (a javax.swing.TimerQueue)
    at java.lang.Thread.run(Thread.java:595)
    "AWT-EventQueue-0" prio=7 tid=0x2dbec780 nid=0x458 in Object.wait() [0x2e28e000..0x2e28f9e4]
    at java.lang.Object.wait(Native Method)
    - waiting on <0x08082168> (a oracle.jdevimpl.webapp.design.DesignTimeRenderThread)
    at java.lang.Object.wait(Object.java:474)
    at oracle.jdevimpl.webapp.design.DesignTimeRenderThread.service(DesignTimeRenderThread.java:141)
    - locked <0x08082168> (a oracle.jdevimpl.webapp.design.DesignTimeRenderThread)
    at oracle.jdevimpl.webapp.design.DesignTimeEngine.service(DesignTimeEngine.java:346)
    at oracle.jdevimpl.webapp.design.view.DesignTimeViewDocument._serviceJsp(DesignTimeViewDocument.java:930)
    at oracle.jdevimpl.webapp.design.view.DesignTimeViewDocument.rebuildTree(DesignTimeViewDocument.java:206)
    at oracle.jdevimpl.webapp.design.view.DesignTimeFixedViewDocument.rebuildTree(DesignTimeFixedViewDocument.java:155)
    at oracle.jdevimpl.webapp.model.content.dom.view.proxy.ProxyViewDocument.initialize(ProxyViewDocument.java:80)
    at oracle.jdevimpl.webapp.editor.AbstractWebAppEditor.rebuildViewDocument(AbstractWebAppEditor.java:686)
    at oracle.jdevimpl.webapp.editor.html.HtmlEditor.rebuildViewDocument(HtmlEditor.java:621)
    at oracle.jdevimpl.webapp.editor.jsp.JspEditor.rebuildViewDocument(JspEditor.java:209)
    at oracle.jdevimpl.webapp.editor.AbstractWebAppEditor.createDocuments(AbstractWebAppEditor.java:1206)
    at oracle.jdevimpl.webapp.editor.AbstractWebAppEditor.open(AbstractWebAppEditor.java:393)
    at oracle.jdevimpl.webapp.editor.html.HtmlEditor.open(HtmlEditor.java:172)
    at oracle.jdevimpl.webapp.editor.jsp.JspEditor.open(JspEditor.java:113)
    at oracle.ideimpl.editor.EditorState.openEditor(EditorState.java:239)
    at oracle.ideimpl.editor.EditorState.createEditor(EditorState.java:147)
    at oracle.ideimpl.editor.EditorState.getOrCreateEditor(EditorState.java:90)
    at oracle.ideimpl.editor.SplitPaneState.canSetEditorStatePos(SplitPaneState.java:231)
    at oracle.ideimpl.editor.SplitPaneState.setCurrentEditorStatePos(SplitPaneState.java:194)
    at oracle.ideimpl.editor.TabGroupState.createSplitPaneState(TabGroupState.java:103)
    at oracle.ideimpl.editor.TabGroup.addTabGroupState(TabGroup.java:275)
    at oracle.ideimpl.editor.EditorManagerImpl.createEditor(EditorManagerImpl.java:1261)
    at oracle.ideimpl.editor.EditorManagerImpl.createEditor(EditorManagerImpl.java:1196)
    at oracle.ideimpl.editor.EditorManagerImpl.openEditor(EditorManagerImpl.java:1131)
    at oracle.ideimpl.editor.EditorManagerImpl.whenOpenEditor(EditorManagerImpl.java:2332)
    at oracle.ideimpl.editor.EditorManagerImpl.handleDefaultAction(EditorManagerImpl.java:1893)
    at oracle.ide.controller.ContextMenu.fireDefaultAction(ContextMenu.java:343)
    - locked <0x05b615b0> (a java.util.ArrayList)
    at oracle.ideimpl.explorer.BaseTreeExplorer.fireDefaultAction(BaseTreeExplorer.java:1504)
    at oracle.ideimpl.explorer.BaseTreeExplorer.dblClicked(BaseTreeExplorer.java:1841)
    at oracle.ideimpl.explorer.BaseTreeExplorer.mouseReleased(BaseTreeExplorer.java:1862)
    at oracle.ideimpl.explorer.CustomTree.processMouseEvent(CustomTree.java:176)
    at java.awt.Component.processEvent(Component.java:5253)
    at java.awt.Container.processEvent(Container.java:1966)
    at java.awt.Component.dispatchEventImpl(Component.java:3955)
    at java.awt.Container.dispatchEventImpl(Container.java:2024)
    at java.awt.Component.dispatchEvent(Component.java:3803)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
    at java.awt.Container.dispatchEventImpl(Container.java:2010)
    at java.awt.Window.dispatchEventImpl(Window.java:1774)
    at java.awt.Component.dispatchEvent(Component.java:3803)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    "Java2D Disposer" daemon prio=5 tid=0x2db98d40 nid=0x54c in Object.wait() [0x2e08f000..0x2e08fae4]
    at java.lang.Object.wait(Native Method)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
    - locked <0x05986308> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
    at sun.java2d.Disposer.run(Disposer.java:107)
    at java.lang.Thread.run(Thread.java:595)
    "AWT-Windows" daemon prio=7 tid=0x2db7c5e0 nid=0x650 runnable [0x2df8f000..0x2df8fb64]
    at sun.awt.windows.WToolkit.eventLoop(Native Method)
    at sun.awt.windows.WToolkit.run(WToolkit.java:269)
    at java.lang.Thread.run(Thread.java:595)
    "AWT-Shutdown" prio=5 tid=0x2dbd2268 nid=0x3a0 in Object.wait() [0x2de8f000..0x2de8fbe4]
    at java.lang.Object.wait(Native Method)
    - waiting on <0x059863f0> (a java.lang.Object)
    at java.lang.Object.wait(Object.java:474)
    at sun.awt.AWTAutoShutdown.run(AWTAutoShutdown.java:259)
    - locked <0x059863f0> (a java.lang.Object)
    at java.lang.Thread.run(Thread.java:595)
    "Low Memory Detector" daemon prio=5 tid=0x01119d10 nid=0x67c runnable [0x00000000..0x00000000]
    "CompilerThread0" daemon prio=5 tid=0x01118600 nid=0x5b8 waiting on condition [0x00000000..0x2d95fa48]
    "Signal Dispatcher" daemon prio=5 tid=0x010f94d8 nid=0x160 waiting on condition [0x00000000..0x00000000]
    "Finalizer" daemon prio=8 tid=0x010eb008 nid=0x680 in Object.wait() [0x2d75f000..0x2d75fae4]
    at java.lang.Object.wait(Native Method)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
    - locked <0x0592aa40> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
    "Reference Handler" daemon prio=5 tid=0x007afc20 nid=0x5fc in Object.wait() [0x2d65f000..0x2d65fa64]
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:474)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
    - locked <0x0592aac0> (a java.lang.ref.Reference$Lock)
    "main" prio=5 tid=0x007a9b18 nid=0x69c waiting on condition [0x00000000..0x0012fb60]
    "VM Thread" prio=5 tid=0x010e8ae8 nid=0x644 runnable
    "VM Periodic Task Thread" prio=5 tid=0x0112cc00 nid=0x550 waiting on condition
    NAV _ ENTITY TYPE :: End Customer

    I was just going to suggest these two solutions myself. If you've got the time, check into this stuff.
    1) use Thread.join() to wait (block) until a given
    Thread completes its task.
    2) Bite the bullet and learn how to use
    wait()/notify() (Google should send you to some good
    tutorials). Granted, it can be a complex topic, but
    it is vital to know if you want to write efficient
    asynchronous programs.
    Good luck!

  • How to do custom dialog so it displays the dialog and waits for user to end

    I have an application that I want to create my own dialog screens. For example, the user cliks on one frame, and I want to open a window for the user to enter data, after the user finishes, he presses OK and then the main app continues.
    On the class that I open the dialog, I open it with:
    NewOkCancelDialog.abrePopup();
    System.out.println("Program should wait for the dialog to close");And the 'NewOkCancelDialog' class is defined like:
    public class NewOkCancelDialog extends javax.swing.JDialog {
    The constructor is like:
    public NewOkCancelDialog(java.awt.Frame parent, boolean modal) {
    super(parent, true);
    initComponents();
    this.setLocation(400,400);
    This methods are when the user activates the button and the popup closes..
    private void cierraPopupOk(){
    resultados.setciudad1(this.fld_ciudad1.getText());
    if (resultados.getciudad1length() < 3) {
    System.out.println("Error en la entrada!");
    } else {
    doClose(RET_OK);
    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {                                        
    cierraPopupOk();
    private void doClose(int retStatus) {
    returnStatus = retStatus;
    this.estaAbierto = false;
    setVisible(false);
    dispose();
    I would like to have the application in the first lines, after calling
    NewOkCancelDialog.abrePopup();
    to wait until the method doClose() in NewOkCancelDialog class is finnished. But right now, after the ...abrePopup() is called, it continues.
    What am I doing wrong? or what am I not doing?

    Use the "code" tags not the "bold" tags when posting code.
    But right now, after the ...abrePopup() is called, it continues.Well your posted code doesn't show this method so we don't know what you are doing in this method.
    Why are you using a static method to show the dialog? Normally the code would be:
    JDialog dialog = new CustomDialog();
    dialog.setVisible( true );
    But you are correct with the basic idea in that you need to use a modal dialog.

  • Wait for resizing JPanel

    nice day,
    during rezize JFrame simultaneously changing the size of JFrame Childs, how to stop, pause or wait for that and resize JFrame Childs just one time
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    import javax.swing.border.EmptyBorder;
    public class PaintPanels extends JFrame {
        private static final long serialVersionUID = 1L;
        private final JPanel fatherPanel = new JPanel();
        private SomePanel centerPanel;
        private SomePanel northPanel;
        private SomePanel southPanel;
        public void makeUI() {
            centerPanel = new SomePanel();
            northPanel = new SomePanel();
            southPanel = new SomePanel();
            centerPanel.setName("centerPanel");
            northPanel.setName("northPanel");
            southPanel.setName("southPanel");
            northPanel.setPreferredSize(new Dimension(1020, 170));
            centerPanel.setPreferredSize(new Dimension(1020, 300));
            southPanel.setPreferredSize(new Dimension(1020, 170));
            fatherPanel.setLayout(new BorderLayout(5, 5));
            fatherPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
            fatherPanel.add(northPanel, BorderLayout.NORTH);
            fatherPanel.add(centerPanel, BorderLayout.CENTER);
            fatherPanel.add(southPanel, BorderLayout.SOUTH);
            setLayout(new BorderLayout(5, 5));
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            add(fatherPanel, BorderLayout.CENTER);
            pack();
            setVisible(true);
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    new PaintPanels().makeUI();
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import javax.swing.BorderFactory;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    public class SomePanel extends JPanel {
        private static final long serialVersionUID = 1L;
        private GradientPanel titlePanel;
        protected JLabel titleLabel;
        int borderOffset = 2;
        public SomePanel() {
            setLayout(new BorderLayout(5,5));
            setBorder(BorderFactory.createLineBorder(Color.gray, 1));
            addMouseListener(new MouseListener() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    Component comp = e.getComponent();
                    String compName = comp.getName();
                    System.out.print("Mouse click from " + compName + "\n");
                @Override
                public void mousePressed(MouseEvent e) {
                @Override
                public void mouseReleased(MouseEvent e) {
                @Override
                public void mouseEntered(MouseEvent e) {
                @Override
                public void mouseExited(MouseEvent e) {
            titleLabel = new JLabel("  Welcome World  ", JLabel.LEADING);
            titleLabel.setForeground(Color.darkGray);
            titlePanel = new GradientPanel(Color.black);
            titlePanel.setLayout(new BorderLayout());
            titlePanel.add(titleLabel, BorderLayout.WEST);
            titlePanel.setBorder(BorderFactory.createEmptyBorder(borderOffset, 4, borderOffset, 1));
            titlePanel.setBorder(BorderFactory.createLineBorder(Color.lightGray));
            titlePanel.setMinimumSize(new Dimension(300, 25));
            titlePanel.setPreferredSize(new Dimension(800, 25));
            titlePanel.setMaximumSize(new Dimension(1200, 25));
            add(titlePanel, BorderLayout.NORTH);
    import java.awt.Color;
    import java.awt.GradientPaint;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Paint;
    import javax.swing.JPanel;
    class GradientPanel extends JPanel {
        private static final long serialVersionUID = 1L;
        public GradientPanel(Color background) {
            setBackground(background);
        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            if (isOpaque()) {// Color controlColor = UIManager.getColor("control");
                //Color background = new Color(44, 61, 146);
                //Color controlColor = new Color(168, 204, 241);
                Color background = new Color(168, 210, 241);
                Color controlColor = new Color(230, 240, 230);
                int width = getWidth();
                int height = getHeight();
                Graphics2D g2 = (Graphics2D) g;
                Paint oldPaint = g2.getPaint();
                g2.setPaint(new GradientPaint(0, 0, background, width, 0, controlColor));
                //g2.setPaint(new GradientPaint(0, 0, getBackground(), width, 0, controlColor));
                g2.fillRect(0, 0, width, height);
                g2.setPaint(oldPaint);
    }

    nice day,
    could you hepl me with some definitions, still I can't to define gap for first and last of JLabel (matrix), is there some hack for GridBagLayout,
    hmmm, interesting that if I replace South JPanel and put there JPanet that contains only JButtons, then that's/just only this one (JPanel) doesn't any problems with synchronizations for repaint with JFrame,
    result is: resize isn't smooth, Border jump, resize breaking,
    already at a fraction of JComponents that I would like to display,
    I certainly know that the reason is the LCD display, where its native resolution makes a huge problem with the edge of Border and FontSize, 'glass screen' doesn't suffering from similar diseases,
    so there my question is how to stop the refresh, resize JPanels with its parents, therefore wait until the resize event ends on JFrame
    import java.awt.*;
    import javax.swing.*;
    public class ChildPanel extends JPanel {
        private static final long serialVersionUID = 1L;
        public ChildPanel() {
            JLabel hidelLabel;
            JLabel firstLabel;
            JTextField firstText;
            setLayout(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
            for (int k = 0; k < 50; k++) {
                hidelLabel = new JLabel("     ");
                //hidelLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
                gbc.fill = GridBagConstraints.HORIZONTAL;
                gbc.weightx = 0.5;
                gbc.weighty = 0.5;
                gbc.gridx = k;
                gbc.gridy = 0;
                add(hidelLabel, gbc);
            for (int k = 0; k < 5; k++) {
                firstLabel = new JLabel("Testing Label : ", SwingConstants.RIGHT);
                firstLabel.setFont(new Font("Serif", Font.BOLD, 20));
                firstLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
                gbc.fill = GridBagConstraints.HORIZONTAL;
                //gbc.ipady = 0;       //reset to default
                //gbc.weighty = 1.0;   //request any extra vertical space
                //gbc.anchor = GridBagConstraints.PAGE_END; //bottom of space
                gbc.insets = new Insets(0, 0, 5, 0);  //top padding
                gbc.gridx = 0;       //aligned with JLabel 0
                gbc.gridwidth = 8;   //8 columns wide
                gbc.gridy = k + 1;
                add(firstLabel, gbc);
            for (int k = 0; k < 5; k++) {
                firstText = new JTextField("Testing TextField");
                firstText.setFont(new Font("Serif", Font.BOLD, 20));
                firstText.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
                gbc.fill = GridBagConstraints.HORIZONTAL;
                gbc.insets = new Insets(0, 0, 5, 0);
                gbc.gridx = 9;
                gbc.gridwidth = k + 8;
                gbc.gridy = k + 1;
                add(firstText, gbc);
            for (int k = 0; k < 5; k++) {
                firstLabel = new JLabel("Testing Label : ", SwingConstants.RIGHT);
                firstLabel.setFont(new Font("Serif", Font.BOLD, 20));
                firstLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
                gbc.fill = GridBagConstraints.HORIZONTAL;
                gbc.insets = new Insets(0, 0, 5, 0);
                gbc.gridx = 20 + k;
                gbc.gridwidth = 8;
                gbc.gridy = k + 1;
                add(firstLabel, gbc);
            for (int k = 0; k < 5; k++) {
                firstText = new JTextField("Testing TextField");
                firstText.setFont(new Font("Serif", Font.BOLD, 20));
                firstText.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
                gbc.fill = GridBagConstraints.HORIZONTAL;
                gbc.insets = new Insets(0, 0, 5, 0);
                gbc.gridx = 29 + k;
                gbc.gridwidth = 21 - k;
                gbc.gridy = k + 1;
                add(firstText, gbc);
    import java.awt.*;
    import javax.swing.JPanel;
    class GradientPanel extends JPanel {
        private static final long serialVersionUID = 1L;
        public GradientPanel(Color background) {
            setBackground(background);
        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            if (isOpaque()) {
                Color background = new Color(168, 210, 241);
                Color controlColor = new Color(230, 240, 230);
                int width = getWidth();
                int height = getHeight();
                Graphics2D g2 = (Graphics2D) g;
                Paint oldPaint = g2.getPaint();
                g2.setPaint(new GradientPaint(0, 0, background, width, 0, controlColor));
                g2.fillRect(0, 0, width, height);
                g2.setPaint(oldPaint);
    }

  • Pause program code and wait for window deactivation

    I have the following code. I need the frame to show then the code to pause until the frame is deactivated.
    The problem is that the frame is shown but only the backgound and its contents are not shown and since the while loop waits for a deactivation it goes into an endless loop. If I press the X on the frame it still does not close. I am guessing for some reason the compiler goes into the while loop before it completes the above task of showing the frame. Can you help me out with my problem?
    final viewMemRecordsFrame memframe = new viewMemRecordsFrame(ff);
    memframe.show();
    memframe.setLocation(80, 80);
    memframe.addWindowListener(new WindowAdapter()
    public void windowDeactivated(WindowEvent e)
    acctnumber = -1;
    memframe.dispose();
    public void windowActivated(WindowEvent e)
    Object waitObject = new Object();
    Thread waitThread = new Thread();
    waitThread.start();
    while(memframe.isVisible())
    try
    waitThread.sleep(200);
    catch(InterruptedException ie)
    waitThread.stop();
    ried the Thread.sleep(200) I had the same problem as above. The frame above the while loop shows but does not show the contents of the frame so an input can not be entered and the frame cannot be deactivated and it runs into an endless loop.

    You appear to have some confusion about threads. Your waitThread doesn't have any code to run, which means it will terminate as soon as you start it.
    "stop" is now depracated and there's really no need for it.
    I'm guessing that this piece of code is activated by some kind of GUI control, which would accont for your program hanging, since no other GUI control (e.g. the close box) can be serviced until an ActionPerfomed method or similar has finished.
    If you want a thread to wait for a window to close the appropriate syncrhonization methods are wait and notify, not sleep.
    For example override "dispose" in "viewMemrecords with:
    public void dispose() {
        synchronized(this) {   // grab the window as a monitor
              super.dispose();  // call the underlying dispose to close the window
              notifyAll();      // wake any waiting threads
       }Then the thread which is to wait does something like:
    syncrhonized(memframe) {
         while(memframe.isVisible())
              memframe.wait();
          }This should make the WindowListener unecessary.
    But [b[don't[/b] make code executed from an GUI action handler wait. GUI action handlers should always return promptly, creating a new Thread if any continuing action is required.

  • Custom JDialog, waiting for Button Press

    I want to create a custom dialog so i can do the following:
    Color yrColor = MyColorChooser().showDialog();
    I can create the dialog just fine but i cant get it to return a value
    on a button press.
    Here is my code:
    public class MyColorChooser extends JDialog implements ActionListener{
    public MyColorChooser(){
    super(Main.Frame, "Color Chooser", true);
    // Gui Stuff
    public Color showDialog(){
    setVisible(true);
    // ?? how do i have it wait for button press??
    return YourColor;
    public void actionPerformed(ActionEvent e) {
    if( e.getSource() == Button ){
    returnColor()
    public void returnColor(){
    Color YourColor;
    JButton Button = new JButton();
    }Im clueless when it comes to JDialogs.
    I know i am probably approaching this all wrong.
    I need guidance more in the approach rather than the code.
    If anyone has any suggestions id appreciate it.
    Thank you!

    Maybe this simple example can give you some ideas. Note how I make the dialog modal. This will halt the program flow until the dialog is dismissed.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SimpleTextInputDialog extends JDialog implements ActionListener {
        private JTextField  inputField;
        private JButton     okButton;
        private JButton     cancelButton;
        private String      value;
        private SimpleTextInputDialog() {
            setTitle("Enter a value");
            setModal(true);
            inputField = new JTextField(20);
            JPanel textPanel = new JPanel();
            textPanel.add(inputField);
            getContentPane().add(textPanel, BorderLayout.CENTER);
            okButton = new JButton("OK");
            okButton.addActionListener(this);
            cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(this);
            JPanel buttonPanel = new JPanel(
                    new FlowLayout(FlowLayout.CENTER, 10, 10));
            buttonPanel.add(okButton);
            buttonPanel.add(cancelButton);
            getContentPane().add(buttonPanel, BorderLayout.SOUTH);
            pack();
            setLocationRelativeTo(null);
        public void actionPerformed(ActionEvent e) {
            if( e.getSource() == okButton ) {
                value = inputField.getText();
            dispose();
        public static String getValue() {
            SimpleTextInputDialog dlg = new SimpleTextInputDialog();
            dlg.setVisible(true);
            return dlg.value;
        public static void main(String[] args) {
            String value = SimpleTextInputDialog.getValue();
            System.out.println("Entered value: " + value);
    }And as always, you should study the tutorials:
    "How to Make Dialogs":
    http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html

  • Switching Frames (cardsLayout), doing something, waiting for button

    Hi,
    I am switching JFrames in my application and each frame is to call a specific function and then wait for a button click.
    so the code would be:
    function(){
            cardsLayout.show();
            doSomeCalculations();
            waitForButtonClick
            continueWithSomething //depending on which Button was clicked
    }My problem is, how to realize the waitForButtonClick?
    What would you suggest? I have heard about synchronize. Is this the way to go, or is there an easier/better way?
    Besides a while(notClicked) way ;-)
    Thanks!

    pir wrote:
    it is not that I do not want to learn Java. Please understand that Java is not with what I am earning my living, it is a tool for me, to make some task easier, which I would have otherwise have to do step by step by hand. I will never be as good as someone who spends his time with Java every day. I also have only a specific task to perform in a given time, so I need only specific information - which I am definitely willing to learn - and not all there is about Java and Swing.You must understand that at its core, your question is not about anything specific but rather it boils down to: "how to create an event driven program in Swing".
    The only reasonable answer to this is to send you to the Swing tutorials where, if you have the interest, ability, and inclination, you can learn the tools needed to do Swing and event programming. If you choose not to do this, no one in this forum can help you. Period.
    I hope this clarifies the situation enough, to allow someone to have a heart and point me in the right specific direction, even knowing that I might use this knowledge only once.And once again, I recommend that you hit the Sun Swing tutorials and start learning. Accept this and follow this recommendation and you will find success. If not, well,... it's your choice.
    Thank you in advance for any specific help.This is as specific as it's going to get at this stage. Much luck.

  • Wait for a button click

    Hi,
    Here's the problem :
    my main class calls :
    LoginContext loginContext = new LoginContext("Main",
    new DialogCallbackHandler());
    I've made a DialogCallbackHandler class which opens a JFrame with 2 fields (TextField & PasswordField) and a button "ok".
    But the LoginContext wants immediately an answer (the login & the password). How can I make the loginContext waiting for the button click.
    I tried with a
    while(!buttonClicked);
    but it's not a good solution.
    I also tried with a Thread inside this loop while and sleeps (during a 500 ms). But I think there's a better solution...
    Can I make a wait, and a notify for this or not.
    Thank you for your help.
    Yann
    -- http://www.objectweb.org/jonas

    Why don't you use the JOptionPane class.
    I think it provides all that you need.
    For example use the method :
         String pass = "azedvge";
         JPasswordField passwordField = new JPasswordField(20);
         int result = JOptionPane.showConfirmDialog(parentComponent, password, "Password check", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
         if (result == JOptionPane.OK_OPTION) {
              String p = new String(passwordField.getPassword());
              if (p.equals(pass)) {
                   // OK !
              else {
                   System.exit(0);
         else {
              System.exit(0);
    I hope this helps,
    Denis

  • Waiting for connection

    Hy
    I have created a class which make the user interface and a class which is taking care of connection to a server.
    I would like that UserInterface class to waint until the ConnectServer is finished the bussines and only then to continue; but in the same time to repaint itself if necessary.
    If I make the ConnectServer class a thread the UserInterface is not wainting for answer otherwise is not repinted itself.
    public class UserInterface extends JFrame implements ACtionListener
    JButton button;
    Connection connection;
    UserInterface()
    button=new JButton("Connect");
    button.addActionListener(this);
    public void actionPerformed(ActionEvent e)
    if(e.getSource==button)
    ConnectServer cs=new ConnectServer();
    // I want to stop here until the connection to server is finished but in the same time to repint itself if necessary
    connection=cs.getConnection();
    Thank you!

    Unfortunately this has nothing to do with JDBC.
    Basically you have two things that need to happen at the same time. So you need two threads. And a way to communcate between them. One thread waits for the connection and sets a flag when it it waiting and when it is done. The other thread reads that flag.

Maybe you are looking for

  • Track po in sales order in not make to order scenario

    Hi, There is a simple sales scenario.1. create a sales order -availability check- if there are enough stock in the storage location then the rest of the process is possible (creating outbound ,...) otherwise, the MRP should be run. 2- convert the aut

  • Acrobat X Pro: Word 2003 Hangs Up When I Print to Adobe PDF

    I have to print to Adobe PDF a LOT.  Recently, I have been unable to do so from Word 2003.  Whenever I go to print, it says "Word is preparing to background print your document" and freezes.  I have experimented with turning background printing off,

  • Not able to send SMS  " Application server error"

    Hi Experts, I am trying to send sms using one URL . but it is giving application server error. if i seperately copy this url on internet explor it is working fine . I am getting error in below methos call method client->receive exceptions http_commun

  • Best Practice for stopping unsolicited e-mails that are not detected as SPAM or Marketing?

    I have roughly 40,000 mailboxes behind some IronPort appliances.   My question for all of you veteran SMTP admins is how do you handle situations where you have an individual sending multiple e-mails to one of your mailboxes?  It's not really a big e

  • ABAP program can't connect to a HTTP destination

    Hello, I have an ABAP program that's used to download data from an internet site. As an internet access proxy has been installed, the program stopped working, displaying an error message: ...Connect to host...Port 80 error: NIECONN_REFUSED Reading th