Hold Focus with JFrames

I am trying to create a JFrame much like an JOptionPane.showInputDialog which disallows the user to use anything until they have clicked on the ok or cancel buttons. Does anyone know how I can make the JFrame have this property? Thanks for your help,
Anthony.
Also do you know the property to keep the JFrame inFront of all the others no matter what the user does (Like they do in photoshop). I have been trying to program this to no avail for ages, putting Listeners on all other panels to call JFrame.toFront but none of them work like those in photoshop.ta again.

Hi hope your still there, I haven't been able to get into this site for a while something to do with the automatice login which I've just disabled. I've downloaded the API and install it on my computer but I can't find the 'Always on top' method for any of the provided Classes. I have been trying to use skin window which doesn't seem to add any methods onto the existing JFrame methods,
Anthony.

Similar Messages

  • Jframe lose focus with jdk 1.4 beta90

    My jframe has two JInternalFrame. One contains a jtree, another contains a jeditorpane. A jpopup menu will appear, after I click the jtree. After I finish the jpopupmenu action, my jeditorpane can not recieve any keyboard event. The only workaround is to switch to any other application, then click jeditorpane again.
    I trace the status of the JFrame.
    1. JFrame get focus
    2. after click jtree, JFrame lose focus
    3. After finish the jpopup menu action, JFrame should gain focus. but JFrame doesn't get that.
    How can I figure it out. Any advice would be highly appreciated.

    i believe it is a bug of jdk14

  • Problem with JFrame, it goes blank

    i
    My problem is with JFrame, when it's carrying operation which takes a bit of time, if somethhing goes on
    top of the frame the frame goes blank, all the components vanished and when the operation is completed the components bacome visible. I dont know why this is happening,. The code is below, since my code is very complicated I am sending some code whcih shows the problem I have, when you press the button it execute's a for loop, whcih takes some time. If you minimize the frame and maximize again, you'll see what I mean.
    Please help!!!
    Many Thanks
    Lilylay
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Frame1 extends JFrame {
    JPanel contentPane;
    JButton jButton2 = new JButton();
    /**Construct the frame*/
    public Frame1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    /**Component initialization*/
    private void jbInit() throws Exception {
    //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(null);
    this.setSize(new Dimension(407, 289));
    this.setTitle("Frame Title");
    contentPane.setBackground(SystemColor.text);
    contentPane.setForeground(Color.lightGray);
    jButton2.setText("Press me!");
    jButton2.setBounds(new Rectangle(107, 111, 143, 48));
    jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mousePressed(MouseEvent e) {
    jButton2_mousePressed(e);
    contentPane.add(jButton2, null);
    /**Overridden so we can exit when window is closed*/
    protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
    System.exit(0);
    void jButton2_mousePressed(MouseEvent e) {
    for(int i=0; i<256898; i++){
    for(int j=0; j<5656585; j++){
    System.out.println("hello");
    public static void main(String [] args){
    Frame1 frame=new Frame1();
    frame.show();
    }

    The reason this is happening is because your loop is so intensive that your program doesn't have time to refresh its JFrame. There is no great way to get past this stumbling block without decreasing the efficiency of your code. One possible solution is to call repaint() from within your loop, but of course this slows down your loop.
    Hope that helps

  • Problem with JFrame's dispose();

    Hello everyone,
    I'm having a problem with JFrame's dispose() method. In my program I have 2 classes which go into full screen. On each screen there is a button to switch to the other screen. The first time I push the button on both of them the other screen closes, which is what I want. However, if I push the same button more than twice - like by going from Screen1 to Screen2 and Screen2 to Screen1 and then Screen1 to Screen2 - I get 2 screens. If I keep doing that I eventually get 10+ screens up, which is bad. How do I prevent that?

    There's a lot of code, so I'll just post up the part that does it.
    backButton.addActionListener(new ActionListener()
                  public void actionPerformed(ActionEvent e)
                      soundManagerM.close();
                        new MenuScreen().setVisible(true);
                        dispose();
             });I don't think it opens up 2 at once, because it would play multiple music right?

  • Back button focusing with the 6D

    I cannot get my 6D's back button focus (AF-ON) to work.  After following directions on Canon's website on how to set it up, the button just does not do anything.  Auto focus only works  with the shutter button.  I have the function set to "P" which I understood to be o.k.  Would resetting the camera to factory default help?  I would prefer not to have to send the camera to Canon for a one button repair.  The camera body was purchased new and is still under warranty.
    Thanks
    Solved!
    Go to Solution.

    It's super easy to set up BBF on a 6D....
    If you have already been changing some things and are unsure which ones, you might want to reset all the Custom Functions to factory default, before starting. (Note: There is a way to view which C.Fns are set and to what each is assigned... As you enter each of the four C.Fn groups, note the list in the lower LH corner of the LCD screen, that shows all the C.Fns in that group at a glance. The top line is the C.Fn number, the bottom line is the setting for each C.Fn.)
    To set up BBF....
    All you have to do is go into the menu, Custom Functions, C.Fn III-5, operations/others, button assignments. Select and enter that and then press "set" and this should take you right to the top of the LH column, which is a graphic illustration of the shutter release button. Press set again to enter this, then scroll to select the center option "start metering" and press "set" once more to select this choice, then press "menu" button several times to back out of the menus. Done!
    What this does is remove AF start from the shutter release button.  By default it's already assigned to the AF-On button on the back of the camera too, so BBF is set up and ready to use as soon as you remove it from the shutter release button.
    Metering and Image Stabilization will continue to start with a half press of the shutter release button or whenever you press the AF-On button. But AF will  only start with your thumb on the AF-On button. Using BBF, you now can use AI Servo most of the time, for stationary or moving subjects. If you want to "focus and recompose", simply focus and then lift your thumb off the AF-On button to leave focus where it is and recompose as you see fit. (Without BBF, you cannot do focus and recompose.... it will cause mis-focused shots.) You still might want to switch back to One Shot when you want high precision focus with stationary subjects.
    There is another option you may want to consider...
    Using the same Custom Function III-5, if you prefer you can swap the functions of the AF-On and * (AE Lock) buttons. I do this on my cameras for a couple reasons: One is that the * button is larger, more prominent, and closer to my thumb... so I prefer to use it for focusing. The other reason is that older Canon models that didn't have the AF-On button, you had to use the * button and that's the way I learned to use BBF (Note: In some cases there was an AF-On button on the body but not on the vertical grip, while older cameras simply didn't have an AF-On button at all, on the body or the grip).
    Alan Myers
    San Jose, Calif., USA
    "Walk softly and carry a big lens."
    GEAR: 5DII, 7D(x2), 50D(x3), some other cameras, various lenses & accessories
    FLICKR & PRINTROOM 

  • All is fine with JFrame, but the same code doesn't work in JApplet?

    I try to manage XML files using Xerces-perser,
    and all is ok if I work with JFrame,
    but when I try to do the same thing in JApplet,
    I get ClassDefNotFound error at the initializing
    of applet. It writes that the problem is with
    Xerces-classes (org.w3c.dom.Node f.e.),
    it seems to me that "appletviewer" (1.3.01) which
    I use to launch JApplet doesn't see these classes,
    while "java" does when I do the same with JFrame.
    May be, do you have some ideas?

    add "crimson.jar" and "jaxp.jar" in your archive list in your html, which lunch your applet.

  • I have a 2012 Ford Focus with bluetooth messeging and I was wondering if the iphone 3gs has bluetooth messeging capabilities?

    I have a 2012 Ford Focus with bluetooth messeging and I was wondering if the iphone 3gs has bluetooth messeging capabilities?

    No. The iPhone does not support the MAP (Message Access Protocol) bluetooth profile.

  • I just purchased monthly plan for creative cloud.  I understood the plan included photoshop.  But no idea how to open photoshop app.  just keep looping into screens which instruct me to purchase creative cloud.  hugely frustrating.   on hold forever with

    i just purchased monthly plan for creative cloud.  I understood the plan included photoshop.  But no idea how to open photoshop app.  just keep looping into screens which instruct me to purchase creative cloud.  hugely frustrating.   on hold forever with customer service.

    First check to see your plan is active: Adobe ID
    Try launching Photoshop choosing Trial instead of a purchase.
    Mac             /Applications/Photoshop CC/Photoshop CC.app
    Windows  C:\Program files\Adobe\Adobe Photoshop CC\Photoshop CC.exe
    Then once inside, go to Help > Sign in...  There, use the email address and password for your account and it should activate.
    If that does not work, could you tell me what version of PS you have and what os version you are using?

  • Need Some Help...I cannot sync my hold "notes" with iCloud. only the new one appears on iCloud!

    Need Some Help...I cannot sync my hold "notes" with iCloud. only the new one appears on iCloud!

    i'm using an iphone4

  • ActionListener not working with JFrame

    Hi,
    I've just rehashed an old bit of code to work with a new application but for some reason the JButton ActionListeners aren't working. However if I extend JDialog they work ok. The current code for JDialog is:-
    * File:     GUI.java
    * @author           ODL 3xx Distributed Systems - Team x
    * @description      This class provides a means for the user to
    *                    interact with file server.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    public class GUI extends JDialog implements ActionListener, ApplicationConstants {
        private JLabel label1, label2, label3, label4, label5;
        private JTextField field1, field2, field3, field4, field5;
        private JButton button1, button2, button3, button4, button5;
        private Container container;
        private Message sendFile;
        private String id;
        private String defaultText = "Enter file name here";
        private ClientForGUI client;
        private long timeStart, timeEnd;
        public GUI(JFrame frame) {
            super(frame, "File Server Actions", true);
            client = new ClientForGUI(this);
            try{
                   InetAddress addr = InetAddress.getLocalHost();
                   id = addr.getHostName() + Long.toString((new java.util.Date()).getTime());
                   if(client.connectToServer())
                   initGUI();
                   else{
                        JOptionPane.showMessageDialog(this, "Unable to connect to server", "Error", JOptionPane.WARNING_MESSAGE);
                        System.exit(0);
              catch(UnknownHostException uhe){
                   System.out.println("Unknown Host Exception");
            initGUI();
         * Create the GUI
        private void initGUI() {
            container = this.getContentPane();
            container.setLayout(null);
            label1 = new JLabel("Upload File");
            label2 = new JLabel("Rename File");
            label3 = new JLabel("Delete File");
            label4 = new JLabel("Create File");
            label5 = new JLabel("Download File");
            field1 = new JTextField();
            field2 = new JTextField();
            field3 = new JTextField();
            field4 = new JTextField();
            field5 = new JTextField();
            button1 = new JButton("Upload");
            button2 = new JButton("Rename");
            button3 = new JButton("Delete");
            button4 = new JButton("Create");
            button5 = new JButton("Download");
            label1.setBounds(10,10,80,20);
            label2.setBounds(10,40,80,20);
            label3.setBounds(10,70,80,20);
            label4.setBounds(10,100,80,20);
            label5.setBounds(10,130,80,20);
            field1.setBounds(100,40,200,20);
            field1.setText("Old name");
            field2.setBounds(310,40,200,20);
            field2.setText("New name");
            field3.setBounds(100,70,410,20);
            field3.setText(defaultText);
            field4.setBounds(100,100,410,20);
            field4.setText(defaultText);
            field5.setBounds(100,130,410,20);
            field5.setText(defaultText);
            button1.setBounds(100,10,100,20);
            button1.addActionListener(this);
            button2.setBounds(520,40,100,20);
            button2.addActionListener(this);
            button3.setBounds(520,70,100,20);
            button3.addActionListener(this);
            button4.setBounds(520,100,100,20);
            button4.addActionListener(this);
            button5.setBounds(520,130,100,20);
            button5.addActionListener(this);
            container.add(label1);
            container.add(button1);
            container.add(label2);
            container.add(field1);
            container.add(field2);
            container.add(button2);
            container.add(label3);
            container.add(field3);
            container.add(button3);
            container.add(label4);
            container.add(field4);
            container.add(button4);
            container.add(label5);
            container.add(field5);
            container.add(button5);
            setSize(640,200);
            setResizable(false);
            //Centre on the screen
            Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
              int x = (int) ((d.getWidth() - getWidth()) / 2);
              int y = (int) ((d.getHeight() - getHeight()) / 2);
              setLocation(x,y);
            setVisible(true);
        private void sendMessageToServer(Message message){
             message.setId(id);
             timeStart = new java.util.Date().getTime();
             try{
                  client.sendMessageToServer(message);
             catch(IOException ioe){
                  System.out.println("Unable to send message to server");
          * Perform some action based on user interaction
          * @param ae - ActionEvent
        public void actionPerformed(ActionEvent e){
            Object o = e.getSource();
            String name;
            if(o == button1){
                 try{
                        JFileChooser fc = new JFileChooser();
                       fc.setVisible(true);
                      //return value is what the user presses in the open File dialog
                      int returnVal = fc.showOpenDialog(null);
                      //if they choose OK
                      if (returnVal == JFileChooser.APPROVE_OPTION) {
                             //file now references the selected
                             File file = fc.getSelectedFile();
                             //create a FileInputStream from file location
                             FileInputStream fis = new FileInputStream(file);
                             // Create the byte array to hold the data, the same size as the file
                             byte [] fileBytes = new byte[(int)file.length()];
                              // Read in the bytes from the file into the byte array
                              int offset = 0;
                              int numRead = 0;
                              while (offset < fileBytes.length &&
                             (numRead=fis.read(fileBytes, offset, fileBytes.length-offset)) >=
                             0) {
                                  offset += numRead;
                             // Ensure all the bytes have been read in
                             if (offset < fileBytes.length) {
                                  throw new IOException("Could not completely read file "+file.getName());
                             fis.close();
                             sendFile = new Message(SEND_FILE, fileBytes);
                             sendFile.setId(id);
                             sendFile.setFileName(file.getName());
                             byte [] myarray = ConvertData.messageToBytes(sendFile);
                             Message sendWarning = new Message(SEND_FILE_WARNING);
                               sendWarning.setFileName(file.getName());
                              sendWarning.setFileSize(myarray.length);
                              try{
                                    sendMessageToServer(sendWarning);
                               catch(Exception excep){
                                    System.out.println(excep);
                   catch(FileNotFoundException fnfe){
                        System.out.println("File Not Found Exception");
                   catch(java.io.IOException ioe){
                        System.out.println("IO Exception");
            else if(o == button2){
                   name = field1.getText();
                   String name2 = field2.getText();
                   Message renameMessage = new Message(RENAME_FILE);
                   renameMessage.setFileName(name);
                   renameMessage.setFileRename(name2);
                   sendMessageToServer(renameMessage);
                   field1.setText("Old name");
                   field2.setText("New name");
            else if(o == button3){
                   name = field3.getText();
                   Message deleteMessage = new Message(DELETE_FILE);
                   deleteMessage.setFileName(name);
                   sendMessageToServer(deleteMessage);
                   field3.setText(defaultText);
            else if(o == button4){
                   name = field4.getText();
                   Message createMessage = new Message(CREATE_FILE);
                   createMessage.setFileName(name);
                   sendMessageToServer(createMessage);     
                   field4.setText(defaultText);     
            else if(o == button5){
                   name = field5.getText();
                   Message downloadMessage = new Message(REQUEST_FILE);
                   downloadMessage.setFileName(name);
                   sendMessageToServer(downloadMessage);
                   field5.setText(defaultText);          
        public void processServerMessage(Message message){
             switch(message.getMessageHeader()){
                   case SEND_FILE_WARNING:
                   //change the download size to file size plus max message size
                   client.setDownload((int)message.getFileSize(),true);
                   //turn message back around with acknowledgement header
                   message.setMessageHeader(SEND_FILE_ACK);
                   //send the message
                   try{
                        sendMessageToServer(message);
                   catch(Exception e){
                        System.out.println(e);
                   break;
                   //server has acknowledged that the client wishes to send a message
                   //so send the message
                   case SEND_FILE_ACK:
                   //send the message
                   try{
                        sendMessageToServer(sendFile);
                   catch(Exception e){
                        System.out.println(e);
                   break;
                   //server is sending the file to the client.
                   case SEND_FILE:
                   //reset the download size to default
                   client.setDownload(DEFAULT_MESSAGE_SIZE,false);
                   //get the file name
                   File f = new File(message.getFileName());
                   //create the file chooser
                   JFileChooser fc = new JFileChooser();
                   //set selected file as thoe one downloaded
                   fc.setSelectedFile(f);
                   //get the button hit by the user
                 int returnVal = fc.showSaveDialog(null);
                 //if button is OK
                  if (returnVal == JFileChooser.APPROVE_OPTION){
                       File temp = fc.getCurrentDirectory();
                       String [] files = temp.list();
                       java.util.List alist = java.util.Arrays.asList(files);
                       f = fc.getSelectedFile();
                       if(alist.contains(message.getFileName())){
                            if(JOptionPane.showConfirmDialog(null,
                                       message.getFileName() + " already exists. Are you sure you want to overwrite this file?",
                                       "Instant Messenger: Quit Program",
                                       JOptionPane.YES_NO_OPTION,
                                       JOptionPane.QUESTION_MESSAGE,
                                       null) == JOptionPane.YES_OPTION) {
                                            //f = fc.getSelectedFile();
                                            System.out.println(f.toString());
                                           //this is where the file is copied
                                           try{
                                                FileOutputStream fs = new FileOutputStream(f);
                                                 fs.write(message.getFile());
                                                 fs.close();
                                           catch(IOException e){
                                                System.out.println(e);
                            else fc.hide();
                       else{
                            System.out.println("Here " + f.toString());
                            try{
                                 FileOutputStream fs = new FileOutputStream(f);
                                  fs.write(message.getFile());
                                  fs.close();
                            catch(IOException e){
                                 System.out.println(e);
                  else fc.hide();
                  break;
                  case INFORMATION:
                  timeEnd = new java.util.Date().getTime();
                  Long rtrip = timeEnd - timeStart;
                  String str = Long.toString(rtrip);
                  double d = Double.valueOf(str).doubleValue();
                  String fullMessage = message.getMessage();
                  fullMessage += " The total time taken for the last request was " +
                  rtrip + " milliseconds" + " or roughly " + d/1000 + " seconds";
                   JOptionPane.showMessageDialog(null,fullMessage,"Information",JOptionPane.INFORMATION_MESSAGE);
                   break;          
    class TestGUI{
        public static void main(String [] args){
             JFrame frame = new JFrame();
             GUI myGUI = new GUI(frame);
    }     If I change the GUI constructor to empty and extend JFrame instead of JDialog and change the call to super the ActionListener stops working. I've never known this problem before (i.e. I always use e.getSource()). I've even cast the object to a JButton to ensure that the right button is pressed and it is all ok.
    Is there something fundamentally wrong when I make those simple changes to JFrame?
    Regards,
    Chris

    I think rather the approach is your action handling in terms of the buttons. The giant actionPerformed method is difficult to read and maintain.
    I would recommend the following things:
    1. Split your ActionListener into multiple smaller listeners. There's not really even a reason for the GUI class to be an action listener. Instead of having GUI implement ActionListener and trying to keep all of the functionality in one place, use anonymous classes:
    button3.addActionListener(new ActionListener()
        public void actionPerformed(ActionEvent e)
            name = field3.getText();
            Message deleteMessage = new Message(DELETE_FILE);
            deleteMessage.setFileName(name);
            sendMessageToServer(deleteMessage);
            field3.setText(defaultText);
    button4.addActionListener(new ActionListener()
        public void actionPerformed(ActionEvent e)
            name = field4.getText();
            Message createMessage = new Message(CREATE_FILE);
            createMessage.setFileName(name);
            sendMessageToServer(createMessage);     
            field4.setText(defaultText);
    2. Only use the == operator on primitives. There are very few cases in which you can properly use the == operator on objects and, in every one of those cases I have experienced, the equals(Object) method produces the same result.
    3. Name your variables more descriptively. There is really very little reason for your buttons to be named button1, button2, and so on. Give them names that mean something. For example, button1 should be named something like uploadFileButton or buttonUpload. That will give us significant information about what it is expected to do, whereas button1 does not. You may be able to remember what button1 does, but you wrote the code. I keep having to refer back to the instantiation of the button to get a hint as to what it does and, in a few months' time, so will you. :) The same goes for your labels and fields, as well.
    I'm not sure why you aren't getting the behavior you want. However, have you checked to determine that the event source of the button click is actually the button when the whole thing is inside of a JFrame? I would expect it to be, but you never know. This is why I recommend using different ActionListeners for each button. That way, you can be sure of what caused the event.
    Just my 2c. Good luck to you. :)

  • Is there a problem with JFrame and window listeners?

    As the subject implies, i'm having a problem with my JFrame window and the window listeners. I believe i have implemented it properly (i copied it from another class that works). Anyway, none of the events are caught and i'm not sure why. Here's the code
    package gcas.gui.plan;
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.event.WindowEvent;
    import java.awt.event.WindowListener;
    import java.util.Hashtable;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import gcas.plandata.TaskData;
    import gcas.util.GCASProperties;
    import gcas.gui.planlist.MainPanel;
    * MainFrame extends JPanel and is the main class for the plan details window
    public class MainFrame extends JFrame implements WindowListener
         * the container for this window
        private Container contentPane;
         * a string value containing the name of the plan being viewed
        private String labelText;
         * a string value containing the name of the window (GCAS - plan list)
        private static String title;
         * an instance of JDialog class
        private static MainFrame dialog;
         * hashTable that correlates the task name to its id as found in the
         * plan
        private Hashtable taskNameToId = new Hashtable();
         * an instance of taskSetPane.  This is the current instance of taskSetPane
         * being viewed
        private PlanTaskSet currentPane;
         * instance of TaskData class.  Each instance will hold information on
         * an individual task
        private TaskData taskData;
         * hashTable containing instances of the taskSetPane class
        private Hashtable taskSetPanes = new Hashtable();
         * an instance of the OuterPanel class
        OuterPanel mainPanel;
         * an instance of the ButtonPanel class
        ButtonPanel buttonsPanel;
         * an instance of the LeftPanel class
        LeftPanel leftPanel;
         * an instance of the the GCASProperties class
        GCASProperties gcasProps;
        private static MainFrame thisPlanMain = null;
        private MainPanel planListMain;
         * constructor for MainFrame
         * @param frame the parent frame calling this class
         * @param locationComp the location of the component that initiated the opening of the dialog
         * @param labelText the name of the plan that is being viewed
         * @param title title of window
        private MainFrame(JFrame frame, Component locationComp, String labelText,
                String title)
            super(title);
            gcasProps = GCASProperties.getInstance();
            mainPanel = new OuterPanel(labelText, currentPane,
                    taskNameToId, taskSetPanes);
            leftPanel = mainPanel.getLeftPanel();
            System.out.println("LABLE: " + labelText);
            leftPanel.setMainPanelContents();
            buttonsPanel = new ButtonPanel(labelText, taskSetPanes,
                    taskNameToId, leftPanel);
            contentPane = getContentPane();
            contentPane.add(mainPanel, BorderLayout.CENTER);
            contentPane.add(buttonsPanel, BorderLayout.PAGE_END);
            this.addWindowListener(this);
            this.labelText = labelText;
            pack();
            setLocationRelativeTo(locationComp);
            this.setVisible(true);
            planListMain = MainPanel.getInstance();
            planListMain.setVisible(false);
        public static MainFrame getInstance(JFrame frame, Component locationComp, String labelText,
                String title)
            if (thisPlanMain == null)
                thisPlanMain = new MainFrame(frame, locationComp, labelText,
                        title);
            return thisPlanMain;
        public static MainFrame getDialogObject()
        {   //from the location this is called (ButtonPanel), this will never
            //be null
            return thisPlanMain;
        public static void setABMDDialogNull()
            thisPlanMain = null;
         * returns an instance of MainFrame
         * @return MainFrame instance
        public static MainFrame getDialog()
            return dialog;
         * setter for MainFrame
         * @param aDialog a MainFrame instance
        public static void setDialog(MainFrame aDialog)
            dialog = aDialog;
         * window opened event
         * @param windowEvent the window event passed to this method
        public void windowOpened(WindowEvent windowEvent)
         * The window event when a window is closing
         * @param windowEvent the window event passed to this method
        public void windowClosing(WindowEvent windowEvent)
            gcasProps.storeProperties("PlanList");
            MainPanel abmd = MainPanel.getInstance();
    //        planMain = this.getDialogObject();
    //        if(planMain != null)
    //            planMain.setVisible(false);
    //            abmd.setVisible(true);
    //            planMain.setABMDDialogNull();
            if(this.getDialogObject()!= null)
                abmd.setVisible(true);
                setVisible(false);
                setABMDDialogNull(); 
         * Invoked when the Window is set to be the active Window
         * @param windowEvent the window event passed to this method
        public void windowActivated(WindowEvent windowEvent)
         * Invoked when a window has been closed as the result of calling dispose on the window
         * @param windowEvent the window event passed to this method
        public void windowClosed(WindowEvent windowEvent)
         * Invoked when a Window is no longer the active Window
         * @param windowEvent the window event passed to this method
        public void windowDeactivated(WindowEvent windowEvent)
            System.out.println("HI");
         * Invoked when a window is changed from a minimized to a normal state
         * @param windowEvent the window event passed to this method
        public  void windowDeiconified(WindowEvent windowEvent)
            //we could have code here that changed the way alerts are done
           System.out.println("Invoked when a window is changed from a minimized to a normal state.");
         * Invoked when a window is changed from a normal to a minimized state
         * @param windowEvent the window event passed to this method
        public  void windowIconified(WindowEvent windowEvent)
            //we could have code here that changed the way alerts are done
    //        System.out.println("Invoked when a window is changed from a normal to a minimized state.");
    }anyone know whats wrong?

    It turned out that my ide was running the old jar and not updating it, so no matter what code i added, it wasn't being seen. Everything should be fine now.

  • Holding Focus on JCombobox

    Actually I am adding FocusListener in the JTextfield of the JComboBox .In the focus lost event I am holding the focus of the textfield of the combobox unless a condition(i am not explaning right now) fulfills.works fine if TAB key is pressed but when i shift focus to a button then i am able to come out and press the button, which i do not want.

    And what do I have to do with that? I don't know. What are you trying to do?
    I was assuming that you where adding a FocusListener to the combo box, but you never received a focusGained event. Well thats because the combo box doesn't receive focus. It is a compound component consisting of an editor component and a button component. The editor component receives focus, so if you want to trap a focus event you need to add the FocusListener to the editor component.

  • Focus In Jframe

    I am trying to have a key listener inside a Jframe which will work no matter where the focus is, currently it only works when the focus is at certain locations. How can I do this, here is where I create the frame and components and attempt to get the keylistener to work....
    import java.awt.*;
    import javax.swing.*;
    //import cs1.*;
    //import java.io.*;
    import java.awt.event.*;
    //import java.applet.*;
    class Driver extends JPanel implements ActionListener, KeyListener
         static String title = "Number Munchers";     //Game title
         Board board;                                        //Game board
         public JFrame frame;                              //Game frame
         protected JButton b1,b2,b3,b4,b5;
         Score s1=new Score();
         Monster monster1;
         public void createAndShowGUI()
              frame = new JFrame("Number Munchers");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.addKeyListener(this);
              board = new Board(this);
              JMenuBar menuBar = new JMenuBar();
              JMenu fileMenu = new JMenu("File");
              JMenu optionMenu =new JMenu("Options");
              JMenuItem start = new JMenuItem("New Game");
              JMenuItem end = new JMenuItem("End Game");
              JMenuItem sound = new JMenuItem("Sound On");
              JMenuItem mute = new JMenuItem("Mute");
              start.addActionListener(this);
              start.setActionCommand("New Game");
              end.addActionListener(this);
              end.setActionCommand("Exit");
              sound.addActionListener(this);
              sound.setActionCommand("Sound");
              mute.addActionListener(this);
              mute.setActionCommand("Mute");
              menuBar.add(fileMenu);
              menuBar.add(optionMenu);
              fileMenu.add(start);
              fileMenu.add(end);
              optionMenu.add(sound);
              optionMenu.add(mute);
              frame.setJMenuBar(menuBar);
              //Add Number Muncher game board to frame
              frame.getContentPane().add(board,BorderLayout.CENTER);
              //Add score to frame
              frame.getContentPane().add(s1.scoreLabel, BorderLayout.NORTH);
              //frame.getContentPane().add(l1.livesLabel, BorderLayout.EAST);
              //Add info to frame
              frame.getContentPane().add(board.getGameLabel(), BorderLayout.EAST);
              frame.getContentPane().add(board.getScoreLabel(), BorderLayout.NORTH);
              frame.getContentPane().add(board.getLivesLabel(), BorderLayout.SOUTH);
              frame.setSize(550,550);
              frame.setVisible(true);
              monster1 = new Monster(0,0,this,board,board.muncher);
         public static void main (String args[])
              final Driver driver = new Driver();
              javax.swing.SwingUtilities.invokeLater(new Runnable()
                   public void run()
                        driver.createAndShowGUI();
         }//End main method
         public void keyPressed(KeyEvent e)
              System.out.println("Key pressed");
              if(e.getKeyCode()==KeyEvent.VK_LEFT)
                   System.out.print("LEFT ");
                   board.move(-1,0);
                   System.out.println(board.muncher.returnY() + " " + board.muncher.returnX());
              if(e.getKeyCode()==KeyEvent.VK_RIGHT)
                   System.out.print("RIGHT ");
                   board.move(1,0);
                   System.out.println(board.muncher.returnY() + " " + board.muncher.returnX());
              if(e.getKeyCode()==KeyEvent.VK_UP)
                   System.out.print("UP ");
                   board.move(0,1);
              if(e.getKeyCode()==KeyEvent.VK_DOWN)
                   System.out.print("DOWN ");
                   board.move(0,-1);
                   System.out.println(board.muncher.returnY() + " " + board.muncher.returnX());
         public void keyTyped(KeyEvent e)
         public void keyReleased(KeyEvent e)
              if(e.getKeyCode()==KeyEvent.VK_CONTROL)
                   System.out.println("MUNCH");
                   board.munch();               
              if(e.getKeyCode()==KeyEvent.VK_ENTER)
                   System.out.println("REFRESH BOARD");
                   board.refresh();
         public void actionPerformed(ActionEvent e)
              //Menu Bar
              if(e.getActionCommand().equals("New Game"))
                   System.out.println("New Game");
                   board.clear();
                   s1.refreshScore();
              if(e.getActionCommand().equals("Exit"))
                   JOptionPane.showMessageDialog(frame,"Are you sure you want to exit?");
                   System.exit(0);
              if(e.getActionCommand().equals("Sound"))
                   System.out.println("Sound On");
              if(e.getActionCommand().equals("Mute"))
                   System.out.println("Mute");
    } //end Driver class
    If you can help thanks a lot, this is a problem I have spent a long time attempting to fix.
    Geoff Gross

    chack this URL http://developer.java.sun.com/developer/bugParade/bugs/4647551.html
    I reported it as a bug 3 years ago and still did not find a solution to this problem, but sun still convince that making us a hard life and getting to no where is still not their bug.
    If you want to help me with this fight please send them also an email and report it as a bug.
    Amnonm

  • No auto focus with SQ on native lens?

    Hi FS7 users,
    Wasn't sure if anyone else is running into this problem, but when using the native sony e mount in SQ mode, it does not auto focus at all. Even when using manual and clicking the "Focus Push Auto" button it does nothing.
    On the FS700 the the auto tracking in SQ worked flawless and was a huge addition to track things in motion.
    I shoot a lot of surfing from a boat with the athlete coming at you and this on the fs700 paid off. I hope this feature could be fixed/added in the future!

    It's not just you.  There is no AF in S&Q Motion and I wouldn't hold out hope that it will ever be be added.  Better get used to focusing manually! :-) http://www.vortexmedia.com/Sony_PXW-FS7_Field_Guide.html  

  • Child JWindow containing JTextField takes focus from JFrame

    I have a bit of a unique problem.
    I have a JFrame as the main application window. I then create a JWindow with a JTextField that I would like to use as a Popup Palette. The problem is that when I click in the text box, the title bar of the JFrame changes it's appearance because the focus is now on the text box in the JWindow.
    If I use setFocusableWindowState(false) on the JWindow then the title bar of the JFrame does not change(which is the behaviour I want), but I cannot type in the JTextField.
    I understand why this is happening. The JTextField needs to have focus in order to recieve input and because it is in the JWindow, the JWindow takes the focus away from the JFrame.
    Does anyone know how I can make it so the JFrame Title Bar does not change appearance when the JTextField in the JWindow gets focus?
    The only thing that I can think of, is to somehow change the JFrame Look & Feel so that the title does not change appearance when the JFrame looses focus. I have no idea how to do that though.
    If you are wondering why I need this, it is because I need a JTextField to display on top of a Heavyweight component. I want it to appear as if it is part of the same window. Having the title bar of the JFrame change when you click in the textbox kind of destroys the illusion that it is part of the heavyweight component.
    Also, if you know of any other ways to get the JTextField to display and work on top of a Heavyweight component then I would appreciate that as well.
    Here is an example that you can run to see the behaviour. You can try it with the setFocusableWindowState line both uncommented and commented out.
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.JWindow;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    public class TestFocus implements Runnable {
        private JFrame frame;
        private JWindow popup;
        public void run() {
            //Create a new Frame
             frame = new JFrame("Frame Test");
             JButton but = new JButton("Does Nothing");
            frame.getContentPane().add(but);
            frame.setPreferredSize(new Dimension( 500, 500 ));
            frame.pack();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
            //Create a JWindow with a JTextField
            popup = new JWindow( frame );
            JPanel p = new JPanel(new BorderLayout());
            JTextField txt = new JTextField();
            p.add( txt, BorderLayout.NORTH );
            JButton but2 = new JButton("Also does nothing");
            p.add(but2, BorderLayout.SOUTH);
            popup.getContentPane().add(p);
            popup.setLocation( frame.getLocation().x + 50, frame.getLocation().y + 50 );
            popup.pack();
            //Proper title behaviour if I have this statement
            //but then I can't type in the text box.
            //popup.setFocusableWindowState(false);
            popup.setVisible(true);
        public static void main(String[] args) {
            try {
                System.setProperty("sun.java2d.noddraw", "true");
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            catch (Exception e) {
            SwingUtilities.invokeLater(new TestFocus());
    }Thanks,
    Jeff

    The code works fine on XP using JDK1.4.2, maybe its a version/platform issue check the bug database.
    -> if you know of any other ways to get the JTextField to display and work on top of a Heavyweight component
    You could try using
    JPopupMenu.setDefaultLightWeightPopupEnabled(false)and then add the JTextField to a jPopupMenu instead of a JWindow (although behind the scenes I think it will use a JWindow as the popup, so it may not solve the problem either if it is a version/platform issue).

Maybe you are looking for

  • Excel 2013 Data From Web not working with SharePoint 2013?

    In Excel 2013, on the ribbon select the 'Data' tab and 'From Web' to import data from a web page. Navigate to a SharePoint 2013 site with a table on the home page and you will not see the table import arrow on the table. With SharePoint 2010 you woul

  • Mac Pro keeps shutting off randomly

    Hey guys, My Macbook Pro keeps shutting off randomly. Its been doing it for a few months now and I was finally able to restore it to factory settings to see if that would fix the problem but it hasnt. Sometimes it will shut off every five minutes, ot

  • Check the duplicate functionality of CRM 7.0

    Dear Sirs, could someone give me some Information about of checking and eliminating of duplicate business partner data records.  This functionality should be already integrated in SAP CRM, how can I customize it? There is a Data Quality Management Fr

  • Ethernet Network ATV lost from iTunes and it wont come back!!!

    Hi everyone Had this happen a couple of times now. I've got a 160GB ATV connected to a 1080P display. Mac Mini is host for all things iTunes. All software is latest versions incl. ATV. ATV is connected to network via ethernet as is Mac Mini. Most of

  • TS1702 How do I back up my book to my computer?

    How do I back up my books from my IPad to my computer?