Btn in JFrame to Open JDialog

Hi Guys
In NetBeans GUI Builder I have created and designed a MainGUI (JFrame Form) that has some buttons. I also went ahead and created and designed a SubGUI (JDialog Form).
What do I need to do to link MainGUI to SubGUI through the press of a button ????
I have added the ActionPerformed / ActionEvent method to the button, and inside that I have tried:
SubGUI.setVisible(true);but it doesn't work !!
I would greatly appreciate any help.
Thank You.

Here is the other bit that I think might be relevant:
private void starterBtnActionPerformed(java.awt.event.ActionEvent evt) {                                          
        StarterDialog.setVisible(true);
    private void maincourseBtnActionPerformed(java.awt.event.ActionEvent evt) {                                             
        MainCourseDialog.setVisible(true);
    private void dessertBtnActionPerformed(java.awt.event.ActionEvent evt) {                                          
        DessertDialog.setVisible(true);
    private void adminBtnActionPerformed(java.awt.event.ActionEvent evt) {                                        
        AdminDialog.setVisible(true);
    private void starterListMouseClicked(java.awt.event.MouseEvent evt) {                                        
        Starter selectedStarter = (Starter)starterList.getSelectedValue();
        if (selectedStarter != null)
            populateSDialog(selectedStarter);
    private void sOKBtnActionPerformed(java.awt.event.ActionEvent evt) {                                      
        // TODO add your handling code here:
    private void sCancelBtnActionPerformed(java.awt.event.ActionEvent evt) {                                          
        this.dispose();
    private void maincourseListMouseClicked(java.awt.event.MouseEvent evt) {                                           
        MainCourse selectedMC = (MainCourse)maincourseList.getSelectedValue();
        if (selectedMC != null)
            populateMCDialog(selectedMC);
    private void mcOKBtnActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
    private void mcCancelBtnActionPerformed(java.awt.event.ActionEvent evt) {                                           
        // TODO add your handling code here:
    private void dessertListMouseClicked(java.awt.event.MouseEvent evt) {                                        
        Dessert selectedDessert = (Dessert)dessertList.getSelectedValue();
        if (selectedDessert != null)
            populateDDialog(selectedDessert);
    private void dOKBtnActionPerformed(java.awt.event.ActionEvent evt) {                                      
        // TODO add your handling code here:
    private void dCancelBtnActionPerformed(java.awt.event.ActionEvent evt) {                                          
        // TODO add your handling code here:
    private void populateSDialog(Starter s1)
        sNameJLi.setText(s1.getName());
        sCalsJLi.setText(String.valueOf(s1.getCalories()));
        sDescTA.setText(s1.getDescription());
        sPriceJLi.setText(String.valueOf(s1.getPrice()));
    private void populateMCDialog(MainCourse mc1)
        mcNameJLi.setText(mc1.getName());
        mcCalsJLi.setText(String.valueOf(mc1.getCalories()));
        mcDescTA.setText(mc1.getDescription());
        mcPriceJLi.setText(String.valueOf(mc1.getPrice()));
    private void populateDDialog(Dessert d1)
        dNameJLi.setText(d1.getName());
        dCalsJLi.setText(String.valueOf(d1.getCalories()));
        dDescTA.setText(d1.getDescription());
        dPriceJLi.setText(String.valueOf(d1.getPrice()));
    * @param args the command line arguments
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new MainGUI().setVisible(true);
    }

Similar Messages

  • Hiding/showing JFrame with active JDialog

    Hi,
    I have a problem with hiding and re-showing a JFrame that contains an active JDialog.
    I have a JFrame (named operatorFrame) that holds the main application and a JFrame that I use for showing a screensaver. When the screensaver has to be shown I perform a hide() of the operatorFrame and a show() of the screensaver frame.
    These actions are done in a Runnable that is called through SwingUtilities.invokeAndWait(). Now when the operatorFrame contained an opened JDialog and the screensaver started, when closing the screensaver the operatorFrame.show() method is called and there it stops. The instruction that follows the show() is never reached.
    Does anybody have any ideas?
    Thanks,
    Taaje

    I understand that but then why does it work when I run the same code in Windows (the normal environment is Red Hat Linux)?
    I just found out that it works when running it under Windows.

  • How do I know how many JFrames has opened ?

    Hi,
    I've got an application which has a main form (JFrame).
    Inside this main form there are buttons which opens others JFrames.
    When I close the main form I need to show how many others Jframes has opened.
    How do I know how many Jframes has opened in my whole application ?
    and
    How can I get them ?
    Can someone help me, please ?
    Thanks.
    wmiro.

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class FrameTest
        static JLabel label;
        static int
            frameCount = 0,    // number of visible frames
            frameNumber = 0;   // consecutive frame number
        public static void main(String[] args)
            label = new JLabel("frame count = 0", JLabel.CENTER);
            JButton addButton = new JButton("add frame");
            addButton.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    makeNewFrame(++frameCount);
                    label.setText("frame count = " + frameCount);
                    label.repaint();
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.weightx = 1.0;
            gbc.fill = gbc.HORIZONTAL;
            panel.add(label, gbc);
            JPanel northPanel = new JPanel();
            northPanel.add(addButton);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(northPanel, "North");
            f.getContentPane().add(panel);
            f.setSize(175,120);
            f.setLocation(50,50);
            f.setVisible(true);
        private static void makeNewFrame(int count)
            final JFrame f = new JFrame(String.valueOf(++frameNumber));
            f.addWindowListener(new WindowAdapter()
                public void windowClosing(WindowEvent e)
                    reportFrameClosing();
                    f.dispose();
            f.getContentPane().add(new JLabel("frame " + frameNumber));
            f.setSize(140,70);
            f.setLocation(175 + count*40, 120 + count*80);
            f.setVisible(true);
        public static void reportFrameClosing()
            frameCount--;
            label.setText("frame count = " + frameCount);
            label.repaint();
    }

  • To close JFrame over a JDialog

    Hi,
    I am facing a slight problem. Say I have a code like under
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class abc extends JDialog implements ActionListener
         JPanel jp1 = new JPanel();
         JButton ok1 = new JButton("OK");
         public abc()
              this.getContentPane().setLayout(new BorderLayout());
              this.getContentPane().add(jp1,BorderLayout.CENTER);
              jp1.add(ok1);
              ok1.addActionListener(this);
              ok1.setActionCommand("ok1");
         public void actionPerformed(ActionEvent e)
              if (e.getActionCommand().equals("ok"))
                   System.out.println("Inside action performed method");
              else if (e.getActionCommand().equals("ok1"))
              JFrame j1 = new JFrame();
              JPanel jp2 = new JPanel();
              JButton btn1 = new JButton("OK");
              j1.getContentPane().add(jp2);
              jp2.add(btn1);     
              btn1.addActionListener(this);
              btn1.setActionCommand("ok");
              j1.show();
              j1.pack();
              j1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    public static void main(String args[])
              abc ABC = new abc();
              ABC.show();
              ABC.pack();
    Now here in this code the line
    j1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    closes the application itself. What I want is only the JFrame closes while the main Dialog stills stays in context.
    Can someone help with me how I can achieve the same.
    Regards.
    Anand

    There is a dialog it has a OK button. When I click the OK button a frame opens with another OK1 button in it.
    Now if I click the "x" sign of the frame it should be disposed without doing anything. frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE)But if I click the OK1 button then also the frame should be disposed but
    after doing something other processing corresponding to the OK1 button.
    OK1.addActionListener( new ActionListener() {
        public void actionPerformed(ActionEvent e) {
              // do processing
             frame.setVisible(false);
             // add this if you want to remove the frame from memory and recreate it when it needs to be opened
             frame.dispose();
    })>
    And within all this the parent(JDialog) and the child(JFrame) should be modal.A JFrame unfortunately cannot be modal, so you shd use a JDialog instead.
    ICE

  • JFrame references in JDialog constructors.

    If you have a single JFrame that houses your GUI and have Dialogs scattered through out your application, what is the best way to make create each dialog with a reference to that one master JFrame.
    Currently, I am passing the JFrame reference all over the place. Practically every constructor now has a JFrame as part of its argument list. The object graph is fairly deep, because I have screens that open sub screens, I have panels that are resused among screens; I have table editor that popup messages; etc; etc. It would be so nice if I didn't have to pass this JFrame reference to ever thing I created.
    I could use the Singleton pattern, but I heard this was a bad idea.
    Can someone give me some guidance, and perhaps an example?
    Thanks.

    When I say "Dialogs scattered throughout the application", I'm trying to say that I have one JFrame with a main method. When launched through the main method, the primary view is loaded. From there, the user can click in different areas to launch "detail" screens. Within these "detail" screens, I have fields that need validation. These validations require a lot of messages to be generated for the user. To do this, I use JOptionPane. JOptionPane requires a JFrame. (Technically, the JFrame is optional, but without it you run into other issues.)
    For example, here's some I have plugged into one of my JTable Editors:
      public boolean stopCellEditing(){
        String startTime = (String)_table.getModel().getValueAt(_row, _col - 1);
        if(startTime == null || "".equals(startTime)){
          return super.stopCellEditing();
        Float start = getTimeAsDecimal(startTime);
        Float end = getTimeAsDecimal(_editor.getText());
        if(end < start){
          Object response = Message.showMessageDialog(_frame, "MESSAGE", JOptionPane.INFORMATION_MESSAGE, "End must be after start");
          _editor.setBackground(Color.RED);
          _editor.setForeground(Color.WHITE);
         _editor.requestFocus();
          return false;
        return super.stopCellEditing();
      }You will notice that I have "_frame" as a variable in my showMessageDialog. I have to pass this "_frame" object from the very top, pass it into the JDialog that houses the JTable, then pass it into the editor that has this message. Now, this is only three layers. There are occasions where I have to pass it even more layers.
    Is this bad architecture? Can it be done better or more efficiently?
    Why is it bad to have a singleton JFrame object? How is everyone else doing it?
    Thanks.
    Edited by: Kazan on Jan 21, 2009 2:11 PM

  • 2 classes, open JDialog

    I am new to Java... and have a problem: I have two classes in 2 different files (2 main methods). The first class, "Game", displays a JFrame with JPanel etc etc. Then I created a second class, "CTabel", that shows a complex table - I used the Netbeans 5 GUI Builder to do this. It's a JDialog (public class CTable extends javax.swing.JDialog)
    I am feeling a bit sheepish about it but I don't know how to open this CTable from my first class "Game" :/
    Thanks for your help!

    But one of the fundamentals is missing: how do I call a class which is in another file? How can I call "public class CTable extends javax.swing.JDialog" from my first class?
    Hmm... It's really hard to know exactly where your disjoint is so I'll punt.
    You can instantiate an object of type CTable with:
    CTable table = new CTable();  //using default constructor, there may be others....Then, since it extends JDialog you can display it with:
    table.setVisible(true);If, when you say "I have two main functions" that you wrote two functions with this header:
    public staic void main(String []args) {Then you're probably going to want to move some code around. Minimally, you won't be calling main() on CTable. To be more robust, you'd move almost all logic out of both main() methods and into the constructors and bodies of your two classes. You may even want to use a common practice of having a jbInit() method which can be called in GUI classes, so that different constructors can easily provide consistent behavior.
    Currently you may have something like:
    class CTable extends JDialog {
        //A few over-ridden methods exist here perhaps.
        public static void main(String []args) {
            //almost all code exists here....
    class Game {
        //A few utility methods etc may exist here...
        public static void main(String []args) {
            //almost all code exists here....
    }What you could try is:
    class CTable extends JDialog {
        CTable() {
            super();
            jbInit();
        CTable(JComponent parent) {
            super(parent);
            jbInit();
        jbInit() {
            //All GUI initialization goes here.
        //Other useful functionality goes here, modularized into methods.
        //A few over-ridden methods exist here perhaps.
        public static void main(String []args) {
            //almost all code exists here....
    class Game {
        Game() {
            initialize();
        initialize() {
            //most initialization logic goes here...
        public void startPlaying() {
            //game is set into motion (assuming it was initalized) here.
        //Useful/modular methods, and possibly even internal classes exist here.
        public static void main(String []args) {
            Game g = new Game();
            g.startPlaying();
    }This may seem rather long and tedious, but it's a powerful framework, and moves the complexity of your code out of one or two knots into a common framework that other programmers will easily understand. (Also, how you organize your code is all about your own personal "coding style" so feel free to look around at other's projects and examples and use ideas you really like...)
    One final thought here. I'm not going to recommend some book or tutorial at this point, because it's clear that you're very new to programming (and from the last thread/discussion we had) that you're picking things up pretty quickly. Instead, I recommend you get into a good basic "intro" to programming class as quickly as possible, perhaps at a local community college if you can't find anything else more available.
    This would give you a solid foundation and teach you some good habits early so you don't have to break bad habits later on. (We could debate the relative merits of self-directed study and formal education all day, but my personal experience is that close contact with a seasoned educator is the most effective way to learn the fundamentals.)
    Oh yeah... and if I'm way off base here, a code snippet or two would help us figure out what's going on.

  • Writing a class to open jDialog that can be used over and over

    Hi All
    I am hoping that some out there can help me with this.
    I have a lot of Dialogs that I what to open and close.
    I am using the code to do that , and it works fine.
    What i would like to do is write a class that I can call and just pass in the name of the dialog that I what to open.
    Something like this
    private String dialogeName;
    dialogeName = Contacts;
    So from another class using a button I could do this type of call
    some way of passing into this class the Dialog name. I don't know how to do that ether .
    Is there some way of getting to this private String dialogeName; from another class ??
    Is this posable ??
    PLEASE SOMEONE HELP ME .....................
        Contacts dlg = new Contacts();   // Works fine  but to have to call the same code over and over
       // is a pain and the only difference is the name of the dialog.
        dialogeName = Contacts;  // this is what I would like to be able to do
       // dialogeName dlg = new dialogeName();
        Dimension dlgSize = dlg.getPreferredSize();
        Dimension frmSize = getSize();
        Point loc = getLocation();
        dlg.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
                        (frmSize.height - dlgSize.height) / 2 + loc.y);
        dlg.setModal(true);
        dlg.pack();
        dlg.show();Thanks to all that have taken the time to look and to help
    Craig

    Why not simply create a method that wraps all the redundant stuff?
    public JDialog showDialog(JDialog dlg)
        Dimension dlgSize = dlg.getPreferredSize();
        Dimension frmSize = dlg.getSize();
        Point loc = dlg.getLocation();
        dlg.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
                        (frmSize.height - dlgSize.height) / 2 + loc.y);
        dlg.setModal(true);
        dlg.pack();
        dlg.show();
        return dlg;
    }Then you could call it with all your various dialog types:
    Contacts dlg = (Contacts)showDialog(new Contacts());
    OtherDialog dlg2 = (OtherDialog)showDialog(new OtherDialog());Of course in this example Contacts and OtherDialog classes must extend JDialog.

  • How I can get a JFrame to open in the middle of the screen?

    Okay, I have been looking for an answer on how I can make a JFrame open in the center of the screen like the JOptionpane's "null" argument does. Maybe, I am putting the wrong words in the search but I can't find any help on this.
    Thanks
    ***Sample***
    import java.awt.FlowLayout;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    public class JFrameProb extends JFrame
         private JLabel someText;
         private JLabel someText2;
         private JLabel someText3;
         public JFrameProb()
              super("Why is this always going to the Corner?");
              setLayout( new FlowLayout() );
              someText = new JLabel("This Window Popped open in the top-left Corner...");
              add(someText);
              someText2 = new JLabel("Is there a way to open in the Center of the Screen?");
              add(someText2);
              someText3 = new JLabel("I know JOptionPane does.");
              add(someText3);
    }

    JosAH,
    I tried using your code but it errored out:
    C:\Program Files\Java\jdk1.5.0\PimpThatHo\PimpNameGetter.java:78: cannot find symbol
    symbol : variable Centralizer
    location: class PimpNameGetter.TextFieldHandler
    Centralizer.centralize(comboBox);
    ^
    1 error
    Process completed.
    So I made a java file for the Cebtralizer Class but it gave me this:
    --------------------Configuration: <Default>--------------------
    C:\Program Files\Java\jdk1.5.0\PimpThatHo\Centralizer.java:3: cannot find symbol
    symbol : class Component
    location: class Centralizer
    public static void centralize(Component c) {
    ^
    C:\Program Files\Java\jdk1.5.0\PimpThatHo\Centralizer.java:5: cannot find symbol
    symbol : class Dimension
    location: class Centralizer
    Dimension screenSize= Toolkit.getDefaultToolkit().getScreenSize();
    ^
    C:\Program Files\Java\jdk1.5.0\PimpThatHo\Centralizer.java:5: cannot find symbol
    symbol : variable Toolkit
    location: class Centralizer
    Dimension screenSize= Toolkit.getDefaultToolkit().getScreenSize();
    ^
    C:\Program Files\Java\jdk1.5.0\PimpThatHo\Centralizer.java:6: cannot find symbol
    symbol : class Dimension
    location: class Centralizer
    Dimension compSize= c.getPreferredSize();
    ^
    4 errors
    Process completed.
    I know I am missing packages but I don't know which ones.
    Roman03_

  • Change jFrame to be jDialog

    I wrote a big application using mostly jFrames as pop up screens to collect data. I only realized now I should have used jDialogs instead. Is there a way to convert the jFrames to jDialog instead of writing all new??

    question is - is there a way to convert a jFrame to be a jDialog?They are the same. You use either:
    JFrame frame = new JFrame();
    or
    JDialog dialog = new JDialog();
    They both use a content pane and you add components to the content pane the same way whether its a frame or a dialog.
    So your question doesn't make sense. You go through the code and change JFrame to JDialog. That is the simplest way.
    Of course it is not the best design as was stated in the first reply.

  • Problem with JFrame, JInternalFrame and JDialog

    problem solved..sorry

    I have just found this post:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=302473
    And the first way seems to be the only way to solve the problem... :(
    Now the question is, does it exist a way to refresh a JFrame after that I have uset setVisible(true)?
    If it does exist I could have something like this:
    setVisible(true)
    new panel(getInsets(););
    contpan.add(panel);
    REFRESH();

  • 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!

  • JFrame-Window Opening

    Dear Sir,
    There are a Window with a Button. If Button is Clicked, then another window will Open. How will I write code for this?
    First Form is SalesForm.java and second form is CashRegister.java
    If the button (GO) of SalesForm.java is clicked then CashRegister.java will be open.
    Please, give me the code of this. Please.

    Here is a link to a tutorial on building GUIs.
    The answer to your question is in there.
    http://java.sun.com/docs/books/tutorial/uiswing/index.html
    You will need to set up a listener for your button. The code to show the window will go in the actionPerformed() method for your button listener. Once you have created your window and set its size (with setSize() or pack()) then you can show it by calling setVisible(true) on the window.
    Most people around here won't do your work for you, so please don't come here asking for people to code for you.

  • Detecting a JDialog opening and closing

    Hey everyone,
    This is a simple question, or at least, it should be :). I need a Timer to start when a JDialog opens and stop when it closes so a cute icon animation shows.
    So far, I managed to detect when the window opens, but not when it closes. This code is at the JDialog constructor:
    addWindowListener(new WindowAdapter()
                @Override
                public void windowClosed(WindowEvent we)
                    System.out.println("\t\t\t\twindowClosed");
                    busyIconTimer.stop();
                @Override
                public void windowOpened(WindowEvent we)
                    System.out.println("\t\t\t\twindowOpened");
                    busyIconTimer.start();
            });When I call "setVisible(true)", the windowClosed event is raised.
    When I call "setVisible(false", no event is called whatsoever (tried all the events available).
    Instead, if I call "mydialog.dispose()", the windowClosed event is called correctly.
    But after this, if I call "setVisible(true)" again, the windowOpened isn't called.
    Can anyone help me? :)
    Thanks in advance.

    I find that setVisible(false) calls windowDeactivate:
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowListener;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class DialogStateListener
      private static void createAndShowUI()
        final JFrame frame = new JFrame("DialogStateListener");
        final JDialog dialog = new JDialog(frame, "Dialog", true);   
        JButton showDialogBtn = new JButton("Show Dialog");
        showDialogBtn.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent e)
            dialog.setVisible(true);
        frame.getContentPane().add(showDialogBtn);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        JButton setVisibleFalseBtn = new JButton("setVisible(false)");
        JButton disposeBtn = new JButton("dispose");
        setVisibleFalseBtn.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent e)
            dialog.setVisible(false);
        disposeBtn.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent e)
            dialog.dispose();
        dialog.setPreferredSize(new Dimension(200, 200));
        JPanel contentPane = (JPanel)dialog.getContentPane();
        contentPane.setLayout(new FlowLayout());
        contentPane.add(setVisibleFalseBtn);
        contentPane.add(disposeBtn);
        dialog.pack();
        dialog.setLocationRelativeTo(null);
        dialog.addWindowListener(new WindowListener()
          public void windowActivated(WindowEvent e)
            System.out.println("window activated");
          @Override
          public void windowClosed(WindowEvent e)
            System.out.println("window closed");
          @Override
          public void windowClosing(WindowEvent e)
            System.out.println("window closing");
          @Override
          public void windowDeactivated(WindowEvent e)
            System.out.println("window deactivated");
          @Override
          public void windowDeiconified(WindowEvent e)
            System.out.println("window deiconified");
          @Override
          public void windowIconified(WindowEvent e)
            System.out.println("window iconified");
          @Override
          public void windowOpened(WindowEvent e)
            System.out.println("window opened");
      public static void main(String[] args)
        java.awt.EventQueue.invokeLater(new Runnable()
          public void run()
            createAndShowUI();
    }

  • Open a JDialog from an JApplet

    Hello,
    I have an applet and I want to open a separate window. The problem is that I want this window to be modal, and therefore I have to use a JDialog, but a JDialog needs an owner that can only be a JFrame or a JDialog, so I cannot use the JApplet as an owner. I tried to set the owner to null, but then if the user changes the focus to another window in his/her OS, and then returns to the browser, the JDialog does not reappear, so the applet is stuck!
    Does anybody have an idea how I can solve this problem?
    Thanks very much.

    Yes, cuz all applets have a frame....
    Frame f =
    (Frame)SwingUtilities.getAncestorOfClass(Frame.class,
    this);Thank you very much. I will try this solution.

  • Open One jframe at a time

    I have various links in a table  on a page and when a user clicks on a link a jinternalframe will open up .
    I just want one frame to be open at a time. User should be allowed to open only one frame unless he closes that and opens another one.
    Can any one suggest how to implement this ?
    I am new to Swing.
    Thanks,

    888525 wrote:
    Thanks for the reply.I already have the application built ,I have to fix this bug and the frame I mentioned is already pre created and doing the main function
    of the application,I cannot change it to be a dialog. [...]
    This is simply not true.
    Your code may have an awful structure so that it may be (or may look) hard to change. But switching from a JFrame to a JDialog is mainly changing the extends clause of your Frame Component. (I assume that the coder of this part did not yet realize that extending Swing classes like JFrame or JDialog directly isn't a good idea anyway...)
    bye
    TPD

Maybe you are looking for

  • How do I add another email to my Apple ID account

    Is it possible to add another email account to my Apple ID? I have one Apple ID that I would like to share between my Iphone 4S, my wife's Iphone 4, my Ipad, and Ipod. I would like to add/ authorize her email address to my one Apple ID. Is it possibl

  • Can't get hand off working

    i have hand off enabled on iPad and iPhone but it won't work can someone tell me how to get it to work please?

  • Problems in JVM 10.1.2

    Hi, I have for the oc4j_BPEL instance in a 10.1.2 AS this java option. -server -Xms512M -Xmx2048M ..... But when running dmstool ( and via the enterprise monitoring tool and the AggreSpy page ) I get this maxValue, kbytes -> 513025 How can I know the

  • Day  book  standard  report

    Dear  All can any  one  give  the  list  for  standard  reports  available  for  day book regards sree

  • Referencing buttons in AS3

    I am trying to figure out a way to reference a specific button out of a large group of buttons in AS3. I'll explain. Let's say, for instance, I have a lot of buttons on the stage (let's say 100.) Each of these buttons causes something to happen. Inst