Rookie: Lock a JFrame

I just have a small question:
I have a program with a menu window. When I press a button on the menu, a new window pops up.
My question is:
How can I lock this new window until the user presses the close button (witch I have made) or the x on the top right corner? By "lock" I mean that it is not possible to press any of the other windows in my program when this window is active...
I cant find the method (if there is any)...
Thank you!

I dont know how to do that.... isnt there a method that I can just put into my JFrame that tells it that it is the only JFrame in the program that can be used at this time (until the JFrame is closed)

Similar Messages

  • Locking a JFrame in the screen

    Help!!!!!, How can i lock a JFrame in the screen???
    I mean, no matter what others applications are open (or start the user after my java app) my frame will be at the front of all always.

    thats what I though too, but I has never done that.
    Do you know where could i find some documentation or code examples of programs than manipulate the OS in java???

  • Locking a JFrame

    Please exscuse the subject - I will have to explain...
    I have an application which has an 'About Box' i.e. Copyright Notice etc. When the user clicks on 'About', the application launches a new JFrame.
    I want this new JFrame to sit above the existing application JFrame, and not allow the user to return to the main application window until they have closed the About JFrame.
    How do I 'lock the user' into this About Box JFrame until they have either clicked an OK button or closed the window.
    Thanks in advance.

    Use JOptionPane . It gives you facility to launch variety dialogs .

  • Drawing a picture within JFrame when I've already created a JFrame

    Hi everyone,
    I was wondering if you could help me out with this problem I'm getting. I'm creating a program to simulate an 'elevator.' When first creating the project I created a brand new 'Java GUI Form' : 'JFrame Form'. From here I went on to drag-and-drop various command buttons and labels to create the user interface (the 'inside' of an elevator). Here is where my question comes in. On the very left of my interface I want to have the program draw a simulation of a box (the elevator) moving up and down with the 'floor numbers' the user pushes. However i don't know how to access the coding of the jFrame object that I created through the design editor so i can input the coding.
    First Question: What do i have to 'write' that would force that box to print into the current JFrame?
    Second Question: What Code (and where do i put it) essentially 'locks' the JFrame from being resized?

    Here, maybe by putting this it might help you recognize what i'm trying to say. The code i'm trying to put in is:
    JFrame window = new JFrame ("Drawing");
            Container contentPane = window.getContentPane();
            contentPane.setBackground(new Color(125, 125, 125));
            Graphics g = contentPane.getGraphics();* This is a portion of the code
    When run, this program creates a NEW JFRAME WINDOWS, i'm trying to make it run inside an already existing JFrame, whose variable Name i dont know how to find.

  • Help ! To Lock  The Position Of a JFrame ?!!

    How can i lock the Position of a JFrme..
    my requirement is to lock the position of a JFrame.. so that it cannot be dragged on a screen.. but must be resizable... is that possible ?
    any suggestions ??
    Thanking You in advance...

    well sorry..
    i guess you are speaking with respect to windows ..
    well i left out to tell ya..
    i'm working on a macintosh..
    so i need the requirement as per the client to lock its position but not the size...
    the desktop on a macintosh can be viewed else with short keys..
    any help ?!!

  • Keyboard-lock of swing program on Linux box

    We are developing swing program on Linux, and we often meet keyboard-lock issues.
    I try to simplify some of them to small programs, and still meet keyboard-lock.
    Here I post two programs to show the error:
    //---first ----------------------------------------------
    package test;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class KeyLock extends JFrame {
      JPanel contentPanel = new JPanel();
      JPanel wizardToolPan = new JPanel();
      JButton btnBack = new JButton("Back");
      JButton btnNext = new JButton("Next");
      JButton btnAbout = new JButton("About");
      public static final String aboutMsg =
              "<html>  This program will help to find keyboard lock problems, two way to reproduce:<br><br>" +
              "1 - press Alt+N to navigate next, and don't release keys untill there are no more next page, <br>" +
              "then try Alt+B to navigate back and also don't release keys untill page 0,<br>" +
              "repeat Alt+N and Alt+B again and again, keyboard will be locked during navigating. <br><br>" +
              "2 - press Alt+A in main window, it will popup an about dialog,<br>" +
              "then press down space key and don't release, <br>" +
              "the about dialog will be closed and opened again and again,<br>" +
              "keyboard will be locked sooner or later." +
      public KeyLock() {
        this.setTitle("Keyboard lock test");
        getContentPane().setLayout(new BorderLayout());
        btnBack.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
        btnNext.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
        btnAbout.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(KeyLock.this, aboutMsg, "About", JOptionPane.INFORMATION_MESSAGE);
        contentPanel.setLayout(new BorderLayout());
        contentPanel.setPreferredSize(new Dimension(400, 250));
        contentPanel.setMinimumSize(new Dimension(400, 250));
        wizardToolPan.setLayout(new FlowLayout());
        this.getContentPane().add(contentPanel, java.awt.BorderLayout.CENTER);
        this.getContentPane().add(wizardToolPan, java.awt.BorderLayout.SOUTH);
        this.setSize(400, 300);
      private Vector<JPanel> slides = new Vector<JPanel>();
      private int current = 0;
      private void createContentPanels() {
        for (int j = 0; j < 20; ++j) {
          JPanel p = new JPanel(new FlowLayout());
          p.add(new JLabel("Page: " + j));
          p.add(new JTextField("Page: " + j + ", input something here", 20));
          p.add(new JTextField("Page: " + j + ", input something here", 20));
          p.add(new JTextField("Page: " + j + ", input something here", 20));
          p.add(new JLabel("Input something in password box:"));
          p.add(new JPasswordField(20));
          p.add(new JCheckBox("Try click here, focus will be here."));
          p.add(new JRadioButton("Try click here, focus will be here."));
      public void showCurrent() {
        if (current < 0 || current >= slides.size())
        JPanel p = slides.get(current);
        this.contentPanel.add(p, java.awt.BorderLayout.CENTER);
        Component[] comps = p.getComponents();
        if (comps.length > 0) {
          comps[0].requestFocus(); // try delete this line
      public void goNext(ActionEvent e) {
        if (current + 1 >= slides.size())
      public void goBack(ActionEvent e) {
        if (current <= 0)
      public static void sleep(int millis) {
        try {
        } catch (Exception e) {
      public static void main(String[] args) {
        KeyLock wizard = new KeyLock();
    }The first program will lead to keyboard-lock in RHEL 4 and red flag 5, both J2SE 5 and 6.
    //---second -----------------------------------------
    package test;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class KeyFocusLost extends JFrame {
      private JButton btnPopup = new JButton();
      private JTextField jTextField1 = new JTextField();
      private JPasswordField jPasswordField1 = new JPasswordField();
      private JPanel jPanel1 = new JPanel();
      private JScrollPane jScrollPane3 = new JScrollPane();
      private JTree jTree1 = new JTree();
      private JButton btnAbout = new JButton("About");
      public static final String aboutMsg =
              "<html>  This program is used to find keyboard focus lost problem.<br>" +
              "Click 'popup' button in main window, or select any node in the tree and press F6,<br>" +
              "a dialog popup, and click ok button in the dialog,<br>" +
              "keyboard focus will lost in main window." +
      public KeyFocusLost() {
        this.setTitle("Keyboard focus test");
        btnPopup.setBounds(new Rectangle(33, 482, 200, 35));
        btnPopup.setText("Popup and lost focus");
        btnPopup.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            PopupDialog dlg = new PopupDialog(KeyFocusLost.this);
        btnAbout.setBounds(new Rectangle(250, 482, 100, 35));
        btnAbout.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(KeyFocusLost.this, aboutMsg, "About", JOptionPane.INFORMATION_MESSAGE);
        jTextField1.setText("Try input here, and try input in password box below");
        jTextField1.setBounds(new Rectangle(14, 44, 319, 29));
        jPasswordField1.setBounds(new Rectangle(14, 96, 319, 29));
        jPanel1.setBounds(new Rectangle(14, 158, 287, 291));
        jPanel1.setLayout(new BorderLayout());
        jPanel1.add(new JLabel("Select any node in the tree and press F6."), java.awt.BorderLayout.NORTH);
        jPanel1.add(jScrollPane3, java.awt.BorderLayout.CENTER);
        Object actionKey = "popup";
        jTree1.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0), actionKey);
        jTree1.getActionMap().put(actionKey, new AbstractAction() {
          public void actionPerformed(ActionEvent e) {
            PopupDialog dlg = new PopupDialog(KeyFocusLost.this);
      public static void main(String[] args) {
        KeyFocusLost keytest = new KeyFocusLost();
        keytest.setSize(400, 600);
      static class PopupDialog extends JDialog {
        private JButton btnOk = new JButton();
        public PopupDialog(Frame owner) {
          super(owner, "popup dialog", true);
          btnOk.setBounds(new Rectangle(100, 100, 200, 25));
          btnOk.setText("OK, then focus lost");
          btnOk.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                Thread.sleep(100); // try delete this line !!!
              } catch (Exception ex) {
          this.setSize(400, 300);
    }The second program will lead to keyboard-focus-lost in RHEL 3/4 and red flag 4/5, J2SE 5, not in J2SE 6.
    And I also tried java demo program "SwingSet2" in red flag 5, met keyboard-lock too.
    I guess it should be some kind of incompatibleness of J2SE with some Linux platform. Isn't it?
    Please help, thanks.

    I have same problems on Ubuntu with Java 6 (all versions). I would like to use NetBeans or IntelliJ IDEA but it is not possible due to keyboard locks.
    I posted this bug
    before I found some info about it:
    I don't know from which part this bug comes, but I wonder why it isn't fixed yet. Does anybody else use NetBeans or IntelliJ IDEA on linux with Java 6 ?
    (I cannot insert link :\ )

  • Total rookie trying to get on-line with my ipod touch.

    Ok... I just got a new ipod touch for my family and have no idea what is happening when I try to go on-line.
    Whenever we try to go to a web site we are asked to select a wi-fi network. When we choose on, we are asked for a password or to join. I have no idea what to do from here?? as I said, we are absolute rookies here?
    Any help would be great!!

    Welcome aboard!
    When you see a list of WiFi networks, you'll see some of them have a little lock symbol next to their names, and others do not have that symbol. The ones with a lock are the ones that have been password protected by their owners. Unless you know the password, you won't be able to get onto those networks.
    Instead you should look for and choose the ones without a lock symbol. Those are the ones that are not password protected and therefore will allow access by your Touch. It might not work all the time (maybe there are configuration issues with that network), but it will usually work.
    However, if the open network is one that is pay-to-use (such as at an airport or at a cafe), it will seem like it lets you onto the network, and yet you cannot get Weather to work or anything else. If that happens, try starting up Safari. Try to go to a web site. If your destination gets hijacked by a login page, then you know this is a network that requires you to log in (and perhaps pay) before you can use it. For example, I was in two different airports last week. In one I got access but it was pay-to-play. In the other one, it also popped up a login screen on Safari, but it was just to have me acknowledge that they were providing free access. Once I clicked to acknowledge, I was online without any problem.
    In summary, you have four different scenarios with WiFi:
    1. None in your immediate area. You aren't going online.
    2. Ones with locks. Unless you know the password, you aren't using them.
    3. Ones with no locks, but they create a splash screen in Safari. Maybe they want money to use, maybe they don't. Give 'em a shot and see.
    4. Ones with no locks and no barriers to entry. You can go online with them unless there are some odd configuration issues.

  • IPod Classic won't Restore and FREEZES/LOCKS iTUNES! Help.

    Hi. First, the specifics:
    I have an iPOD Classic (120GB).
    I have Windows Vista R2 (64-bit).
    I have the latest version of iTunes, yes, for 64-bit.
    With that out of the way, I started seeing issues with my iPod not being able to play certain songs. I'd find the song, hit the play arrow, nothing would happen. The time would not move, song would not play. Here's what I've tried to do initially:
    Re-install iTunes, re-sync.
    Still wouldn't play these songs.. Not all, but many songs.
    So, I tried to Restore.
    Initially, it looked like it was restoring properly - - but took way longer than usual. Like 2 hours. At the end, I got an error "Could not sync this song, Could not sync iPod."
    I looked at iPod, had to set it up, choose ENGLISH as language, etc.  Search iPod, found NO MUSIC, NO VIDEOS, etc.
    Tried simply re-syncing, wouldn't work.
    So, I disconnected, restarted my computer and tried to RESTORE again.
    I connect it via a USB 2.0 and the iPod cable. I have been doing this for years and years and this iPod has worked for the 3 years I have had it.
    I have had iPod since their inception, so I'm not a rookie. I also have an iPhone and an iPad2.
    So I connect the iPod as usual. NOW, it basically FREEZES iTunes. I CONTL-ALT-DEL and find it's always iTunes (NOT RESPONDING).
    This happens EVERY TIME... I tried restarting several times, same issue.
    So, I unistalled all components of iTunes > RESTART COMPUTER.
    I re-download the latest version of iTunes, yes the correct one.
    I tried syncing or restoring. DOESN'T RECOGNIZE iPOD, FREEZES/LOCKS iTUNES.
    HERE'S OTHER THINGS I have tried:
    I downloaded the Windows Update for Vista that helps not corrupt iPod when disconnecting too early.
    Downloaded update, did NOT help with the issue.
    Un-installed iTunes again. Restarted computer. Re-installed newest version of iTunes.
    ONE THING TO POINT OUT, when I connect my iPod, iTunes launches if not open and I get a WINDOWS box that says:
    Do You Want To Scan And Fix Errors on Steven's iPod (L:) ??
    I tried both options: YES, Try to Fix, NO - Continue
    That doesn't work, and iTunes still freezes regardless of option.
    Again, tried DISK MODE, tried Regular mode...
    Nothing works...

    Guys, if you all having the same problem as Steven, then do the iPod Disk Diagnostic, as posted earlier by tt2, it wont fix your problem, but helps in troubleshooting.
    Main cause is the iPod Hardisk is dying, but if the DD report are good, then it is the USB connection timeout.
    So have a go at the Disk Diagnostic first.

  • Disk is locked message

    Just started getting this message when I try to open itunes. It was working fine and just started this. We have 4 user accounts that share the folder so when someone buys a song it is available to all users on the computer. This was setup and working fine. Keep in mind I'm new to the mac from windows and I'm a bit clueless. I tried removing the itunes library and putting it on the desktop, restarting Itunes (which it came back up without the message or any songs) then quit itunes and put the library back where it was and that did nothing. Any and all help greatly appreciated.

    The exact message is as follows: "The itunes Library file is locked, on a locked disk, or you do not have write permission for this file."
    My account is the administrator account. Itunes on my side no longer does that, it comes up to the default page with no library. I don't know if I somehow deleted it (I don't think so because I can see all the songs) or it's no longer being directed to that library. The other 3 users still get the message but when I try to use finder to figure out the permissions and the other things you mentioned it won't show me the contents of the Itunes folder. I'm a rookie on this Mac and am trying to fight my way through things I could probably figure out on a windows pc but I'm struggling mightily. I really do appreciate any and all help.

  • LUW data for smq2--Error During Delivery: Ibound processing locked

    Hi all,
    There are lot of messages(more than 7000) stucked in d Inbound queues, as viewed by SMQ2, and are in the retry mode for long.
    In the LUW data the status of the queue is showing error during delivery and the error text is <b>Inbound Processing Locked for example Deadline Processing </b>
    can anyone please suggest what this problem is about and suggstions for removing this problem will be really appreciated.
    This is urgent as the problem is in production.

    Hi Prateek,
    The BPM involved is a dicesion making BPM which is creting large Idocs.
    We have checked in SM12 and the messages are locked there. Can you please advice how can we unlock the messages from SM12.

  • Locked table columns in JTable?

    Does anyone know if a JTable can implement locked columns? By which I mean, I'd like to nominate 1 or more columns that remain locked to the left (or even right) of the table display and don't scroll out of view when scrolling horizontally.
    I can imagine some round-about ways of doing it, but I wonder if there's a simple way to do it.

    Here is my attempt at this:
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    public class FixedColumnScrollPane extends JScrollPane
        public FixedColumnScrollPane(JTable main, int fixedColumns)
            super( main );
            //  Use the table to create a new table sharing
            //  the DataModel and ListSelectionModel
            JTable fixed = new JTable( main.getModel() );
            fixed.setSelectionModel( main.getSelectionModel() );
            fixed.getTableHeader().setReorderingAllowed( false );
            fixed.getTableHeader().setResizingAllowed( false );
            fixed.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
            main.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
            //  Remove the fixed columns from the main table
            for (int i = 0; i < fixedColumns; i++)
                TableColumnModel columnModel = main.getColumnModel();
                columnModel.removeColumn( columnModel.getColumn( 0 ) );
            //  Remove the non-fixed columns from the fixed table
            while (fixed.getColumnCount() > fixedColumns)
                TableColumnModel columnModel = fixed.getColumnModel();
                columnModel.removeColumn( columnModel.getColumn( fixedColumns ) );
            //  Add the fixed table to the scroll pane
            setRowHeaderView( fixed );
            setCorner(JScrollPane.UPPER_LEFT_CORNER, fixed.getTableHeader());
        public static void main(String[] args)
            //  Build your table normally
            JTable table = new JTable(10, 8);
            JScrollPane scrollPane= new FixedColumnScrollPane(table, 2 );
            JFrame frame = new JFrame("Table Fixed Column Demo");
            frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            frame.getContentPane().add( scrollPane );
            frame.setSize(400, 300);

  • JDBC locking access db

    i can create the table from jframe. i can open the program and instantly insert records, but if i insert a table, then try and insert records i get sqlexception error saying database is locked by othe process and I DON'T have Access open or another instance of this program. but it does seem to write the new records. any help would be great. fully runnable code presuming you setup Coffee DSN. it locks on line 180 which is part of the tableExistsCreateNew method where i try and drop the table.
    screen output.
    A Table already exists with data
    Old table was deleted.
    New table was created successfully
    Table has data records, they will be deleted
    An empty table exists
    Error in creatingtable after dropping.Records were created successfully
    import java.sql.*;
    import javax.swing.JTextPane;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    * Created on July 20, 2004, 1:33 PM
    * @author Participant5
    public class CoffeeDBAdmin extends javax.swing.JFrame {
    /** Creates new form CoffeeDBAdmin */
    Connection conn;
    String message;
    public CoffeeDBAdmin() {
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    private void initComponents() {//GEN-BEGIN:initComponents
    jTextPane1 = new javax.swing.JTextPane();
    jMenuBar1 = new javax.swing.JMenuBar();
    MenuDatabase = new javax.swing.JMenu();
    CreateTable = new javax.swing.JMenuItem();
    Insert = new javax.swing.JMenuItem();
    Retrieve = new javax.swing.JMenuItem();
    Exit = new javax.swing.JMenuItem();
    addWindowListener(new java.awt.event.WindowAdapter() {
    public void windowClosing(java.awt.event.WindowEvent evt) {
    jTextPane1.setMinimumSize(new java.awt.Dimension(375, 200));
    jTextPane1.setPreferredSize(new java.awt.Dimension(375, 200));
    getContentPane().add(jTextPane1, java.awt.BorderLayout.CENTER);
    CreateTable.setText("Create Table");
    CreateTable.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseReleased(java.awt.event.MouseEvent evt) {
    Insert.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseReleased(java.awt.event.MouseEvent evt) {
    Retrieve.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseReleased(java.awt.event.MouseEvent evt) {
    Exit.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseReleased(java.awt.event.MouseEvent evt) {
    private void ExitMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ExitMouseReleased
    // TODO add your handling code here:
    public void createConnection()
    //load JDBC ODBC driver
    //setup the connection
    String url = "jdbc:odbc:Coffee";
    conn = DriverManager.getConnection
    (url, "myLogin", "myPassword");
    catch (Exception e)
    message = "DSN Error.";
    public void createTable()
    Statement stmt = conn.createStatement();
    //stmt.executeUpdate("DROP TABLE COFFEES");
    stmt.executeUpdate("CREATE TABLE COFFEES " +
    catch(NullPointerException npe)
    //we are gonna leave this empty because if you try and call an update
    //without having a database, this exception will occur. it is not
    //necessary to throw this exception as the program print a message and
    //will exit if there is a database problem.
    message = "Database Error";
    catch (SQLException tableExists)
    //System.out.println("Table already exists");
    public void tableExistsCreateNew()
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT Coffee_Name, " +
    "Price FROM COFFEES");
    if(( == true))
    message = "A Table already exists with data\n";
    message = "An empty table exists\n";
    rs = stmt.executeQuery("SELECT Coffee_Name, Price " +
    jTextPane1.setText(jTextPane1.getText() + "\n" + message);
    stmt.executeUpdate("DROP TABLE COFFEES");
    jTextPane1.setText(jTextPane1.getText() +
    "Old table was deleted.\n");
    stmt.executeUpdate("CREATE TABLE COFFEES " +
    jTextPane1.setText(jTextPane1.getText() +
    "New table was created successfully\n");
    catch(NullPointerException npe)
    //we are gonna leave this empty because if you try and call an update
    //without having a database, this exception will occur. it is not
    //necessary to throw this exception as the program print a message and
    //will exit if there is a database problem.
    jTextPane1.setText(jTextPane1.getText() + "\nDatabase Error.");
    JOptionPane.showInternalMessageDialog(jMenuBar1,"Database" +
    " Error");
    catch(Exception e)
    System.out.println("\nerror in creating table after dropping\n");
    jTextPane1.setText(jTextPane1.getText() + "\nError in creating" +
    "table after dropping.\n");
    "Error in creating table after dropping.\n");
    public void createRecords()
    { Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT " +
    "Coffee_Name, Price " + "FROM COFFEES");
    if( == false)
    jTextPane1.setText(jTextPane1.getText() +
    "\nTable has data records, they will be " +
    " deleted\n\n");
    //stmt.executeUpdate("DROP TABLE COFFEES");
    stmt.executeUpdate("INSERT INTO COFFEES " +
    "(Coffee_Name, SUP_ID, Price) " +
    "VALUES ('Colombian', 101, 7.99)");
    stmt.executeUpdate("INSERT INTO COFFEES "+
    "(Coffee_Name, SUP_ID, Price) " +
    "VALUES ('French_Roast', 49, 8.99)");
    jTextPane1.setText(jTextPane1.getText() + "Records" +
    " were created successfully\n");
    catch (Exception e)
    //System.out.println("Error in creating records");
    message = "The Table you requested does not exist.";
    public void printRecords()
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT Coffee_Name, Price " +
    jTextPane1.setText("Coffee Prices\n");
    //System.out.println("Coffee Prices");
    jTextPane1.setText((jTextPane1.getText() + rs.getString(1)
    + " " + rs.getDouble(2) + "\n" ));
    // System.out.println(rs.getString(1) + " " +
    // rs.getDouble(2) + "\n" );
    catch(NullPointerException npe)
    //we are gonna leave this empty because if you try and call an update
    //without having a database, this exception will occur. it is not
    //necessary to throw this exception as the program print a message and
    //will exit if there is a database problem.
    message = "Database Error";
    jTextPane1.setText(jTextPane1.getText() + "\n" +
    JOptionPane.showInternalMessageDialog(jMenuBar1,"You " +
    "cannot retrieve" + "records from a null or " +
    "uncreated table");
    catch (Exception e)
    //message = "Error in printing records";
    jTextPane1.setText(jTextPane1.getText() +"\n" +
    //JOptionPane.showInternalMessageDialog(jMenuBar1,"You cannot retrieve" +
    //"records from a null or uncreated table");
    public void exitRoutine()
    catch (Exception e)
    message = "error closing connection";
    private void RetrieveMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_RetrieveMouseReleased
    // TODO add your handling code here:
    private void InsertMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_InsertMouseReleased
    // TODO add your handling code here:
    private void CreateTableMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CreateTableMouseReleased
    // TODO add your handling code here:
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
    * @param args the command line arguments
    public static void main(String args[]) {
    new CoffeeDBAdmin().show();
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem CreateTable;
    private javax.swing.JMenuItem Exit;
    private javax.swing.JMenuItem Insert;
    private javax.swing.JMenu MenuDatabase;
    private javax.swing.JMenuItem Retrieve;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JTextPane jTextPane1;
    // End of variables declaration//GEN-END:variables

    Are you releasing your connections appropriately?

  • Swing locks up during event handling of a simple button... bug or feature?

    I have the following code:
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JToolBar;
    import javax.swing.SwingUtilities;
    public class Test extends JFrame {
         private static final long serialVersionUID = 1L;
         private JButton button;
         public static void main(String[] args)
              SwingUtilities.invokeLater(new Runnable(){public void run(){new Test();}});
         public Test()
              setLayout(new BorderLayout());
              JToolBar toolbar = new JToolBar();
              button = new JButton("button");
              button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { button.setEnabled(false);}});
              getContentPane().add(toolbar, BorderLayout.SOUTH);
              JPanel panel = new JPanel();
              panel.setPreferredSize(new Dimension(200,10000));
              for(int i=0;i<10000; i++) { panel.add(new JLabel(""+(Math.random()*1000))); }
              JScrollPane scrollpane = new JScrollPane();
              getContentPane().add(scrollpane, BorderLayout.CENTER);
    }This code is lethal to swing: when pressing the button, for no identifiable reason the entire UI will lock up, even though all the event handler is doing is setting the button's "enabled" property to false. The more content is located in the panel, the longer this locking takes (set -Xmx1024M and the label loop to 1000000 items, then enjoy timing how long it takes swing to realise that all it has to do is disable the button...)
    Does anyone here know of how to bypass this behaviour (and if so, how?), or is it something disastrous that cannot be coded around because it's inherent Swing behaviour?
    I tried putting the setEnabled(false) call in a WorkerThread... that does nothing. It feels very much like somehow all components are locked, while the entire UI is revalidated, but timing revalidation shows that the panel revalidates in less than 50ms, after which Swing's stalled for no reason that I can identify.
    Bug? Feature?
    how do I make it stop doing this =(
    - Mike

    However, if you replace "setEnabled(false)" with "setForeground(") the change is instant,I added a second button to the toolbar and invoked setEnabled(true) on the first button and the change is instant as well. I was just looking at the Component code to see the difference between the two. There are a couple of differences:
        public void setEnabled(boolean b) {
         * @deprecated As of JDK version 1.1,
         * replaced by <code>setEnabled(boolean)</code>.
        public void enable() {
            if (!enabled) {
                synchronized (getTreeLock()) {
                    enabled = true;
                    ComponentPeer peer = this.peer;
                    if (peer != null) {
                        if (visible) {
                if (accessibleContext != null) {
                        null, AccessibleState.ENABLED);
         * @deprecated As of JDK version 1.1,
         * replaced by <code>setEnabled(boolean)</code>.
        public void enable(boolean b) {
            if (b) {
            } else {
         * @deprecated As of JDK version 1.1,
         * replaced by <code>setEnabled(boolean)</code>.
        public void disable() {
            if (enabled) {
                synchronized (getTreeLock()) {
                    enabled = false;
                    if (isFocusOwner()) {
                        // Don't clear the global focus owner. If transferFocus
                        // fails, we want the focus to stay on the disabled
                        // Component so that keyboard traversal, et. al. still
                        // makes sense to the user.
                    ComponentPeer peer = this.peer;
                    if (peer != null) {
                        if (visible) {
                if (accessibleContext != null) {
                        null, AccessibleState.ENABLED);
        }The main difference appears to be with the KeyboardFocusManager. So instead of using a toolbar, I changed it to a JPanel (so the buttons are focusable). I then notice the same lag when I try to tab between the two buttons. So the problem is with the focus manager, not the setEnabled() method.

  • Premier Very Slow, Locking up AND intermittant garbled audio

    Wow that's a bunch but I am having real problems suddenly.
    Seems like whenever I walk away from premier Pro I come back and my mouse won't work, system is locked and I have to reboot hard!
    Prior to this I was having a new experience where one time i would open a sequence and the audio was scratchy, the next time I would open it and it would be fine. This is still happening as well.
    Whenever I go out to another program or look at a file on my system and come back to Premier Pro I get the little working circle for about 30 seconds.
    I use a scratch disk which is only half full and my hard drives are enjoying plenty of room on them....
    I have an I7 12GB Ram, NVidia 285 Video CArd, and when the system is working it is like a rocket, but right now....S-L-O-W...
    Help I am stuck on a very large project and need help!!!

    Thanks. I am curious. When I do that, and then go back to open my projects, will they refer to the same locations for files or will I have to re-connect them, and will my scratch disks holding project info still be relevant?
    As an additional question, I really don;t know when and how often I can eliminate the scratch disk data. How long is it useful? The entire duration of a project? Once completed can I delete it?
    Such a rookie question I imagine. Thanks for your feedback!
    It's all the driver info that drives me crazy when doing the OS...

  • How to get info who is locking a specific row in the RDBMS 9i?

    could some one please helop me with this? I would like to know the Oracle user name of the user who is locking a specific row in my table. I can display all locking requests with the following SQL statements. What I could not igure out how to find the rownum that is being locked by others?
    SELECT *
    FROM v$lock lk, v$session s , DBA_OBJECTS ao, wf_users wu
    WHERE lk.lmode > 1
    AND s.username IS NOT NULL
    AND lk.SID = s.SID
    AND ao.OBJECT_ID(+) = lk.id1
    AND s.username = wu.NAME(+)
    AND ao.owner = USER
    AND ao.object_name = 'BWF_IKTATASI_ADATLAPOK';
    Thank you in advance,
    Tamas Szecsy

    I'm not sure what's happening with your app. I wrote on up to see if it could handle the CTRL-C. Seems to work fine. Do you have any other JMenuItems with the same accelerator?
    import java.awt.event.*;
    import javax.swing.*;
    public class Copy extends JFrame {
         public Copy() {
              this.setSize(400, 300);
         private void initMenuBar() {
              JMenuBar menubar = new JMenuBar();
              JMenu edit = new JMenu("Edit");
              JMenuItem copy = new JMenuItem(new CopyAction("Copy"));
              copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK));
         public static void main(String[] args) {
              new Copy();
         private class CopyAction extends AbstractAction {
              public CopyAction(String label) {
              public void actionPerformed(ActionEvent e) {
                   System.out.println("Action Performed.");

Maybe you are looking for

  • How to convert a string to visa resource name

    I have a string , like "visa://", how can I convert it to a Labview visa resource name? The resource name is going to be used for "Open VI reference" control. Also, a related question is , is there a special vi control for

  • Infinite loop - first start of Adobe Photoshop Elements 13

    Hello, I just bought a new version of Adobe photoshop elements 13 (CD-Rom with Key). So I installed the software, created an account, registred the software in my account and then I started the application. What now happens is a little bit confusing.

  • MDT 2010: How to change WinPE drivers?

    We have boot images that currently work for all of our systems and is used for PXE booting with a WDS server, but I think we have lots of extra drivers in the PE image because the boot image size is quite large and it seems to spend a long time injec

  • Need to confirm Serial Key before downloading CS6 product from reseller.

    After purchasing, I found questionable comments regarding reseller. (I know. Initial research wasn't thorough enough.)  Payment has gone through. How do I verify Serial Key prior to download, in case this is a fraud? I can stop payment. They state pr

  • Control a submarine via the Flash Player

    I just wanted to post a site I have been working on. It uses Flash Media Server and the Flash Player to allow users to control a Remote Operated Vehicle (ROV) more commonly used for commercial exploratory underwater operations. The ROV is in a 100,00