JDialog or JOptionPane...

Hi!
Is there any way to create a window in some block of code and kill him in another block below? I need to create a window which won't wait for OK click or something, just it comes when I create him and dissappears when I want. How to do that?

You can install a TimerTask-object who watches for a specific time you want if the user did an action. Then you can close the frame/dialog or what ever there.

Similar Messages

  • Is there any way to wait for a value without using JDialog or JOptionPane?

    I am implementing a dictionary program by detecting word in a JTextPane and asking a user to choose one of available meanings from JOptionPane or JDialog. The program runs under a while-loop until all dictionary words are detected or a user clicks cancel.
    However, I don't want to use JDialog or JOptionPane because it is sometimes annoying to have a popup window on every detected dictionary word.
    So, I use JList with Buttons on the same Frame as the JTextPane. However, now, the program does not stop when it detects a dictionary word. It just uses a default value of the JList for translating word to meaning.
    Is there any way I can simulate the JDialog or JOptionPane without using it?
    I mean I'd like to stopp the program temporary, wait for an answer from other components, and then continue to detect the next dictionary word.
    Thank you.

    I'm probably reading this all wrong, but instead of the while loop,
    the method just looked for a dictionary word from a particular caretPosition,
    so, to start, it would be findWord(0)
    when found, add whatever to wherever, note the caretPostion at the end of the 'found' word, and method returns.
    when the user selects whatever button, the button's actionListener also calls the method again, using the noted caretPosition
    findWord(42);
    so, it starts searching from 42 (instead of the start)
    basically it is event driven
    findWord sets the button/s
    click a button starts findWord

  • JButton in JDialog vs JOptionPane

    I have created two different JDialogs, one with JOptionPane and one in the old-fashioned way. My problem is that the buttons in the different JDialogs get different appearence (I'm usings javas Metal L&F). Take a look at this sample code:
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class TestFrame extends JFrame implements ActionListener {
       JDialog dialog1;
       JDialog dialog2;
       JButton button1;
       JButton button2;
       JButton dialogButton;
       public TestFrame() {
          button1 = new JButton("Open dialog 1");
          button1.addActionListener(this);
          button2 = new JButton("Open dialog 2");
          button2.addActionListener(this);
          getContentPane().add(button1, BorderLayout.NORTH);
          getContentPane().add(button2, BorderLayout.SOUTH);
          pack();
          setVisible(true);
       public static void main(String args[]) {
          new TestFrame();
       public void openDialog1() {
          JOptionPane vAbout = new JOptionPane("Just some text...", JOptionPane.INFORMATION_MESSAGE);
          dialog1 = vAbout.createDialog(this, "Dialog 1");
          dialog1.show();
       public void openDialog2() {
          dialog2 = new JDialog(this, "Dialog 2", true);
          GridBagLayout gbl = new GridBagLayout();
          GridBagConstraints gbc = new GridBagConstraints();
          dialog2.getContentPane().setLayout(gbl);
          JLabel text = new JLabel("Just some text...");
          dialogButton = new JButton("OK");
          dialogButton.addActionListener(this);
          dialog2.getContentPane().add(text, gbc);
          gbc.gridy = 1;
          dialog2.getContentPane().add(dialogButton, gbc);
          dialog2.pack();
          dialog2.setVisible(true);
       public void actionPerformed(ActionEvent e) {
          System.out.println(e.getSource());
          if (e.getSource() == button1)
             openDialog1();
          if (e.getSource() == button2)
             openDialog2();
          if (e.getSource() == dialogButton)
             dialog2.dispose();
       protected void processWindowEvent(WindowEvent e) {
          super.processWindowEvent(e);
          if(e.getID() == WindowEvent.WINDOW_CLOSING) {
             System.exit(0);
    }How can I get my button in dialog2 to look the same as the button in dialog1?

    To set the button to be default, you need some modification. Here's the basic frame work:
    public class TestFrame() extends JFrame
       //Your constructor
       public TestFrame()
          //Do stuff in here
          myDialog mydialog = new myDialog(this);
          mydialog.show()
       public static void main(String[] args)
          //etc
       private void SomeOtherMethods()
           //Declare your JOptionPane
    public class myDialog extends JDialog
       //Constructor
       public myDialog()
           //Add Components like usual
           getRootPane.setDefaultButton(DialogButton);
           getContentPane.add(Your_Panels);
        private void SomeOtherMethods()
    }Basically, you're taking your JDialog and placing it in it's own class (which is better anyway, trust me). Then it will set the button as the default and make the border darker.
    Let me know if you have anymore questions.

  • JDialog and JOptionPane

    Could anyone please help me with this. I'm getting a class cast exception when I run this code.
    final JOptionPane optionPane = new JOptionPane(message+"\nOk to proceed?",JOptionPane.QUESTION_MESSAGE,JOptionPane.YES_NO_OPTION);
         final JDialog dialog = new JDialog();
         dialog.setContentPane(optionPane);
         dialog.setDefaultCloseOperation(
              JDialog.DO_NOTHING_ON_CLOSE);
              dialog.addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent we) {
                   JOptionPane warn = new JOptionPane();
                   warn.showMessageDialog(null,"You must choose an action!","Warning",JOptionPane.WARNING_MESSAGE);
         optionPane.addPropertyChangeListener(
              new PropertyChangeListener() {
                   public void propertyChange(PropertyChangeEvent e) {
                        String prop = e.getPropertyName();
                        if (dialog.isVisible()
                        && (e.getSource() == optionPane)
                        && (prop.equals(JOptionPane.VALUE_PROPERTY) ||
                             prop.equals(JOptionPane.INPUT_VALUE_PROPERTY))) {
                                  //Do Check here
                                  dialog.setVisible(false);
                   dialog.pack();
                   dialog.setVisible(true);
                   int value = ((Integer)optionPane.getValue()).intValue();
                   if (value == JOptionPane.YES_OPTION) {
                        returnInt = 1;
                   } else if (value == JOptionPane.NO_OPTION) {
                        returnInt = 0;
                   } else {returnInt = 5;}
    return returnInt;
    I use a small applet to call this method and pass it parameters.
    thanks

    Hi,
    You have to check if a user has made a choice before casting optionPane.getValue to Integer. If the user has not made any selection yet, the object - JOptionPane.UNINITIALIZED_VALUE, which cannot be cast into Integer, will be returned.
    Try adding the following to your code:
    if (optionPane.getValue() != JOptionPane.UNINITIALIZED_VALUE) {
    value = ((Integer) optionPane.getValue()).intValue();
    or you could use a while loop to wait for a user to make a selection.

  • ActionListener in JDialog created by JOptionPane

    I have a problem I absolutely cannot get around. I've been toying with this code all day and nedd some help badly. The code is posted below. Let me give you some background. I have an application that uses "popups" to ask the user a series of questions. I have two bg images I want to display for the background,
    as well as a custom button (that's no sweat). I originally wrote a class extending JDialog to show the popups. But JDialog does not "block" and wait for user input. I started toying around with JOptionPane. I have created a JDialog from JOptionPane.createDialog(parent, title). All the components display correctly and
    the dialog blocks, BUT the actionListener I added to my button does not go into action. Am I barking up the wrong tree, or is there a way to get a JDialog to block
    the running thread?
    class myDialog{
    JDialog main;
    JTextField inputfield;
      public myDialog(JFrame parent, String display){
    main = this.createDialog(parent, "hello");
    Dimension screenSize = new Dimension(Toolkit.getDefaultToolkit().getScreenSize());
            main.setBounds(screenSize.width/2 - 195,
                      screenSize.height/2 - 50,395,110);
    JLabel textInsert = new JLabel(display);
    textInsert.setFont(new Font("Serif", Font.BOLD|Font.ITALIC, 14));
    textInsert.setForeground(Color.gray);
    JButton next = new JButton(new ImageIcon("images/gui/next.png"));
    inputfield = new JTextField(20);
    Container c = main.getContentPane();
    c.setLayout(new BorderLayout());
    c.removeAll(); // call this to remove the components added by JOptionPane.
    BackgroundComponent panel = new BackgroundComponent(new ImageIcon("images/gui/upperdialog.png").getImage());
    BackgroundComponent panel2 = new BackgroundComponent(new ImageIcon("images/gui/lowerdialog.png").getImage());
    panel.add(new JLabel(new ImageIcon("images/gui/spacer.png")));
    panel.add(textInsert);
    panel2.add(inputfield);
    panel2.add(next);
    c.add(panel, BorderLayout.NORTH);
    c.add(panel2, BorderLayout.CENTER);
    main.setResizable(true);
    main.setVisible(true);
    next.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
             main.setVisible(false);
         }Thanx in advance -- CSB

    the wrong tree, or is there a way to get a JDialog to
    block
    the running thread?Yes, by making it modal:
    main.setModal(true);
    main.setVisible(true);There are also a couple of JDialog constructors that you can use to create a modal dialog without having to use the setModal method.

  • Change Coffee cup icon on JDialog & JOptionPane

    I try to change the coffee cup icon on my JDialog and JOptionPane.
    My JDialog box does not load the Parent Icon (JFrame icon), and not even show a coffee cup icon.
    My JOptionPane would just show a coffee cup icon, eventhough its parent is the above JDialog with no icon.
    Is there anyone know how to fix this?
    I'd like show my icon on the JOptionPane instead of the coffee cup icon.
    And also to show my icon on the JDialog instead of nothing, not even a coffee icon.
    Any help is appreciated.
    CL

    Passing a parent with the desired icon to the JDialog/JOptionPane should solve your problem, however there is a bug in swing that prevents any icon from showing in the titlebar if a JDialog is made non-resizable (through a call to setResizable(false)).
    The bug adatabse says that this has been resolved but I am using jdk 1.3.1 and continue to have this problem.

  • JDialog best practice

    I am building a custom JDialog that includes a JPanel so that it's easier for me to customize (I'm using NetBeans). This is my first solo project as a developer so I want to make sure I follow best practice whenever possible. I have two questions in that regard.
    1. If I need to pop-up a user interface from my main frame that inlcudes several components (a text area, radio button groups, buttons, etc) is the JDialog my best option? I know that there are built in dialogs that are used for convenience but they aren't satisfactory for what I need from a user input perspective.
    2. The dialog I created contains almost as much code as the main JFrame. This JFrame class is becoming quite large to the point that it's hard to keep track of the code. I've thought about creating another class that extends JDialog and placing the code for the dialog in that class. Is that the generally accepted method for resolving this type of issue?
    Last note: I prefer to design my GUI using an IDE such as NetBeans so I can focus on the non-aesthetic code. Unfortunately there doesn't seem to be any logical way for me to create a JDialog outside of my main JFrame without having creating a generic class and write the aesthetic related code manually. Anyone using NetBeans have any suggestions? ( excuse me for that part if there is a separate NetBeans forum but I could not find one ).
    Thanks

    1. Yeah, I believe JDialog is your best choice. If it's quick pop-up question I instantiate the JDialog via JOptionPane, but if it's more complex I instantiate the JDialog directly.
    2. That's okay. You can separate the JDialog GUI into a system of objects working together. I usually make sure this system has only one or two points of access (that is, the reference that the main JFrame will have to it to set it visible and stuff) so that the system doesn't complicate the code that accesses it, but instead keeps its complications internal.
    3. I always code my GUIs. I hate how visual editors code it =\

  • Aligning Text in Center of JOptionPane

    Hi,
    I am trying to display messages using JOptionPane and a JDialog.
        JOptionPane pane = new JOptionPane(message,
                                           message_type,
                                           option_type,
                                           icon,
                                           options,
                                           initial_value){
          public int getMaxCharactersPerLineCount() { return    default_characters_per_line; }
        JDialog dialog = pane.createDialog(parent_component, title);
        dialog.setVisible(true);I want to be able to control the number of characters per line which I have found how to do, and to control the alignment of the text. I have not being able to work out how to control the alignment of the text. I would like to be able have the text centered so a long line followed by a short line is displayed nicely.
    I have tried using <html><center>My Text</center></html>, however, 1stly the html tags are counted as character therefore shortening the 1st line and secondly is the message is over several line then the tag are broken up and not interpreted properly.
    Any assistance greatly appreciated.
    Leon

    //Create the dialog.
                        final JDialog dialog = new JDialog(frame,
                                                           "A Non-Modal Dialog");
                        //Add contents to it. It must have a close button,
                        //since some L&Fs (notably Java/Metal) don't provide one
                        //in the window decorations for dialogs.
                        JLabel label = new JLabel("<html><p align=center>"
                            + "This is a non-modal dialog.<br>"
                            + "You can have one or more of these up<br>"
                            + "and still use the main window.");
                        label.setHorizontalAlignment(JLabel.CENTER);
                        Font font = label.getFont();
                        label.setFont(label.getFont().deriveFont(font.PLAIN,
                                                                 14.0f));extract from
    http://java.sun.com/docs/books/tutorial/uiswing/examples/components/DialogDemoProject/src/components/CustomDialog.java

  • JOptionPane Help Needed

    I basically have two problems with JOptionPane that I've searched for answers yet I haven't found an applicable answer for my application. Here they are:
    1) How can I get a JPasswordField in a JOptionPane to be given focus when the JOptionPane is displayed?
    2) How can I get the default key mappings for JOptionPane not to work or atleast make it where when a user hits "Enter", it activates the button that has current focus? I have a problem with highlighting "Cancel" and hitting "Enter".
    Here is my code being used for the JOptionPane:
    String pwd = "";
    int tries = 0;
    JPasswordField txt = new JPasswordField(10);
    JLabel lbl = new JLabel("Enter Password :");
    JLabel lbl1 = new JLabel("Invalid Password.  Please try again:");
    JPanel pan = new JPanel(new GridLayout(2,1));
    int retval;
    while(tries < 3 && !valid)
         if(tries > 0)
              pan.remove(lbl);
              pan.remove(txt);
              pan.add(lbl1);
              pan.add(txt);
              txt.setText("");
         else
              pan.add(lbl);
              pan.add(txt);
         retval = JOptionPane.showOptionDialog(DBPirate.appWindow,pan,
         "Password Input",                              JOptionPane.OK_CANCEL_OPTION,                              JOptionPane.QUESTION_MESSAGE,
         null,null,null);
         if(retval == JOptionPane.OK_OPTION)
              pwd = new String(txt.getPassword());
              setPassword(pwd);
              if(cryptoUtil.testPassword(pwd))
                   valid = true;
              else
                   tries += 1;
         else
              System.exit(0);
    }Any help would be appreciated. Thanks, Jeremy

    Hello Jeremy,
    I am not too happy with my code, for I think there must be something more efficient and elegant. But after trying in vain with KeyListener and ActionMap this is presently the only way I could do it.
    // JOptionPane where the <ret>-key functions just as the space bar, meaning the
    // button having focus is fired.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ReturnSpace extends JFrame implements ActionListener
    { JButton bYes, bNo, bCancel;
      JDialog d;
      JOptionPane p;
      public ReturnSpace()
      { setSize(300,300);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        Container cp= getContentPane();
        cp.setLayout(new FlowLayout());
        JButton b= new JButton("Show OptionPane");
        b.addActionListener(this);
        p=new JOptionPane("This is the question",
              JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION);
        d=p.createDialog(this,"JOptionPane with changing default button.");
        FocusListener fl= new FocusAdapter()
        { public void focusGained(FocusEvent e)
          {     JButton focusButton= (JButton)(e.getSource());
         d.getRootPane().setDefaultButton(focusButton);
        int i=1;
    //    if (plaf.equals("Motif")) i=2;
        bYes = (JButton)((JPanel)p.getComponent(i)).getComponent(0);
        bYes.addFocusListener(fl);
        bNo = (JButton)((JPanel)p.getComponent(i)).getComponent(1);
        bNo.addFocusListener(fl);
        bCancel = (JButton)((JPanel)p.getComponent(i)).getComponent(2);
        bCancel.addFocusListener(fl);
        cp.add(b);
        setVisible(true);
        d.setLocationRelativeTo(this);
      public void actionPerformed(ActionEvent e)
      { bYes.requestFocus();
        d.setVisible(true);
        Object value = p.getValue();
        if (value == null || !(value instanceof Integer))
        { System.out.println("Closed");
        else
        { int i = ((Integer)value).intValue();
          if (i == JOptionPane.NO_OPTION)
          { System.out.println("No");
          else if (i == JOptionPane.YES_OPTION)
          { System.out.println("Yes");
          else if (i == JOptionPane.CANCEL_OPTION)
          { System.out.println("Cancelled");
      public static void main(String argsv[])
      { new ReturnSpace();
    }Greetings
    Joerg

  • JDialogs with InternalFrames.... can someone please help?

    hi all,
    i want to create a JDialog (not JOptionPane) with the parent component being an InternalFrame... i have tried to to do, but i cant pass compilation..and i guess its cos i cant use JDialogs with InternalFrames being the parent component..
    Is this true, and if so, what can i do to solve the problem, or is there a way to get round this..?
    Thank You for ur help..

    You cannot place root level components like JWindow
    and JDialog inside something else, like a
    JDesktopPane.
    You can, however use a JDesktopPane inside a JWindow
    (you've probably done that), and insert JInternalFrame
    and JInternalDialog into that.
    Conclusion is, that unless you change from a JDialog
    to an JInternalDialog or JInternalFrame, you will
    never pass compilation. What's the problem with
    changing?as far as I'm aware, there is no such thing as JInternalDialog, however for an option pane there are showInternal.... methods, but this doesn't sound like what you want to do. my gues is that you want a dialog, you want it modal and you want it centered relative to it's supposed parent, I would make it a JDialog, set it modal, and use its setLocationRelativeTo(Component c) method to center it over the JInternalFrame parent. The dialog will not show up in the taskbar in windows and you won't be able to do anything else with your app until you close the dialog (modality). hope that helps.

  • JOptionPane, EventQueue & WToolkit Problem

    I have a swing 1.2 application where I have a customized EventQueue which checks to see how long something proceses. If the event is too long, it turns the cursor to an hourglass and then turns it back to the default cursor when complete. The problems comes in whenever I have a JOptionPane (and JDialog for that matter).
    If I'm processing a button event and I throw up a JOptionPane to ask a question, I want to continue processing the original button logic. This works fine. However, I notice I get a
    sun.awt.windows.WToolkit object in my SystemEventQueue. I really need to get the component instead so I can set the hourglass. Does anyone have an idea on how to do this? TIA!

    First of all, thanks for taking the time to look at my problem.
    Here's some answers to the previous questions.
    1. The hourglass cursor is displayed until the JOptionPane or JDialog is displayed. Then the default cursor is displayed. Once a user clicks on a yes/no/cancel button, my program will do some tasks like updating and reading records. During this updating and reading process, I want to display the hourglass. Since I know I get an object back to the event queue, I can time the actions and set the cursor - well, in every case but JOptionPane & JDialog. I really hate the thought of having to code the cursor logic in every method that calls a JOptionPane/JDialog. Just goes against the grain. There has to be a better way.
    2. Usually, I get component objects sent back to the event queue. However, whenever a JDialog or JOptionPane is displayed, I get a WToolkit object. I have no idea why. Anything else will send back components like the button,etc.
    FYI... my event queue is very similar to the one listed in Java World Tip #87 (see link http://www.javaworld.com/javatips/jw-javatip87.html). I just modified it to use a glasspane.

  • How can I do for a row of a query be data provider for a variable?

    Hi friends, I have a problem !
    How can I do for a row of a query be data provider for a variable?
    I need that a value of variable be stored when the user select a row in a query. At the BPS we can do this configuring the variable selector in WIB, and in a WAB how I can do this ?
    Best regards,
    Gustavo Liberado

    In this case when I press the key to call other forms I need to wait for the response in the secondary form and then process the result.That is exactly what a "modal JDialog" (or JOptionPane) are used for.
    Try it. Create a short demo program. All you need is a JFrame with a single button to show the modal dialog. All you modal dialog needs is a single button to close the dialog. After you show the modal dialog add a System.out.println(...) statement in your code and you will see that it is not executed until the dialog is closed.
    Then once you understand the basics you add the code to your real program.
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • GetConnection hanging, then stops. can't get connected

    am writing a java application that connects to our Oracle 8i database. i seem to be following the oracle instructions exactly, but when i go to connect it just hangs. no error and no connection. i'm using Sun's Forte IDE. here's my code, can you help?
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import java.sql.*;
    import java.sql.DriverManager;
    import java.io.*;
    import java.math.*;
    import java.lang.*;
    import oracle.jdbc.driver.OracleDriver;
    public class TableLoader implements LayoutManager {
    static String[] ConnectOptionNames = { "Connect" };
    static String ConnectTitle = "Connection Information";
    Dimension origin = new Dimension(0, 0);
    JButton fetchButton;
    JButton showConnectionInfoButton;
    JPanel connectionPanel;
    JFrame frame; // The query/results window.
    JLabel userNameLabel;
    JTextField userNameField;
    JLabel passwordLabel;
    JTextField passwordField;
    // JLabel queryLabel;
    JTextArea queryTextArea;
    JComponent queryAggregate;
    JLabel serverLabel;
    JTextField serverField;
    JLabel driverLabel;
    JTextField driverField;
    JPanel mainPanel;
    TableSorter sorter;
    JDBCAdapter dataBase;
    JScrollPane tableAggregate;
    * Brigs up a JDialog using JOptionPane containing the connectionPanel.
    * If the user clicks on the 'Connect' button the connection is reset.
    void activateConnectionDialog() {
    if(JOptionPane.showOptionDialog(tableAggregate, connectionPanel, ConnectTitle,
    JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
    null, ConnectOptionNames, ConnectOptionNames[0]) == 0) {
    System.out.println("Inside activateConnectionDialog about to connect, next output is - should be connected");
    connect();
    frame.setVisible(true);
    System.out.println("should be connected");
    else if(!frame.isVisible())
    System.out.println("didnt connect");
    // System.exit(0);
    * Creates the connectionPanel, which will contain all the fields for
    * the connection information.
    public void createConnectionDialog() {
    // Create the labels and text fields.
    userNameLabel = new JLabel("User name: ", JLabel.RIGHT);
    userNameField = new JTextField("tiger");
    passwordLabel = new JLabel("Password: ", JLabel.RIGHT);
    passwordField = new JTextField("scott");
    serverLabel = new JLabel("Database URL: ", JLabel.RIGHT);
    // serverField = new JTextField("jdbc:sybase://dbtest:1455/pubs2");
    serverField = new JTextField("jdbc:oracle:oci8:@LMTD");
    driverLabel = new JLabel("Driver: ", JLabel.RIGHT);
    // driverField = new JTextField("connect.sybase.SybaseDriver");
    driverField = new JTextField("oracle.jdbc.driver.OracleDriver");
    connectionPanel = new JPanel(false);
    connectionPanel.setLayout(new BoxLayout(connectionPanel,
    BoxLayout.X_AXIS));
    JPanel namePanel = new JPanel(false);
    namePanel.setLayout(new GridLayout(0, 1));
    namePanel.add(userNameLabel);
    namePanel.add(passwordLabel);
    namePanel.add(serverLabel);
    namePanel.add(driverLabel);
    JPanel fieldPanel = new JPanel(false);
    fieldPanel.setLayout(new GridLayout(0, 1));
    fieldPanel.add(userNameField);
    fieldPanel.add(passwordField);
    fieldPanel.add(serverField);
    fieldPanel.add(driverField);
    connectionPanel.add(namePanel);
    connectionPanel.add(fieldPanel);
    public TableLoader() {
    mainPanel = new JPanel();
    // Create the panel for the connection information
    createConnectionDialog();
    // Create the buttons.
    showConnectionInfoButton = new JButton("Configuration");
    showConnectionInfoButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    System.out.println("About to connect...");
    activateConnectionDialog();
    fetchButton = new JButton("Fetch");
    fetchButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    fetch();
    // Create the query text area and label.
    queryTextArea = new JTextArea("SELECT * FROM DAILY_LSNR_LOG WHERE C_IP = 192.168.60.138", 25, 25);
    queryAggregate = new JScrollPane(queryTextArea);
    queryAggregate.setBorder(new BevelBorder(BevelBorder.LOWERED));
    // Create the table.
    tableAggregate = createTable();
    tableAggregate.setBorder(new BevelBorder(BevelBorder.LOWERED));
    // Add all the components to the main panel.
    mainPanel.add(fetchButton);
    mainPanel.add(showConnectionInfoButton);
    mainPanel.add(queryAggregate);
    mainPanel.add(tableAggregate);
    mainPanel.setLayout(this);
    // Create a Frame and put the main panel in it.
    frame = new JFrame("TableExample");
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {System.exit(0);}});
    frame.setBackground(Color.lightGray);
    frame.getContentPane().add(mainPanel);
    frame.pack();
    frame.setVisible(false);
    frame.setBounds(200, 200, 640, 480);
    activateConnectionDialog();
    public void connect() {
    String[] tstarr = new String[100];
    try {
    Class driverOK = Class.forName("oracle.jdbc.driver.OracleDriver");
    // DriverManager.getConnection ("jdbc:oracle:oci8:@lmdw","lmtlog", "yama");
    System.out.println("Set the driver, now doing connect");
    DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
    System.out.println("Made it past driver registration " + serverField.getText() + ", " + userNameField.getText() + ", " + passwordField.getText());
    Connection con = DriverManager.getConnection (serverField.getText(),userNameField.getText(),passwordField.getText());
    System.out.println("I made it");
    Statement stmt = con.createStatement();
    for(int i=0; i<10; i++) { tstarr[i] = "component#" + i; }
    stmt.close();
    con.close();
    catch (ClassNotFoundException nf) {
    System.out.println("Couldn't find driver - jeh");
    catch (SQLException badsql) {
    System.out.println("Caught SQL exception in TableLoader - jeh");
    catch (Exception e) {
    System.out.println( e.getMessage());
    e.printStackTrace();
    /* dataBase = new JDBCAdapter(
    serverField.getText(),
    driverField.getText(),
    userNameField.getText(),
    passwordField.getText());
    sorter.setModel(dataBase);
    jeh */
    public void fetch() {
    dataBase.executeQuery(queryTextArea.getText());
    public JScrollPane createTable() {
    sorter = new TableSorter();
    //connect();
    //fetch();
    // Create the table
    JTable table = new JTable(sorter);
    // Use a scrollbar, in case there are many columns.
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    // Install a mouse listener in the TableHeader as the sorter UI.
    sorter.addMouseListenerToHeaderInTable(table);
    JScrollPane scrollpane = new JScrollPane(table);
    return scrollpane;
    // public static void main(String s[]) {
    // new TableLoader();
    public Dimension preferredLayoutSize(Container c){return origin;}
    public Dimension minimumLayoutSize(Container c){return origin;}
    public void addLayoutComponent(String s, Component c) {}
    public void removeLayoutComponent(Component c) {}
    public void layoutContainer(Container c) {
    Rectangle b = c.getBounds();
    int topHeight = 90;
    int inset = 4;
    showConnectionInfoButton.setBounds(b.width-2*inset-120, inset, 120, 25);
    fetchButton.setBounds(b.width-2*inset-120, 60, 120, 25);
    // queryLabel.setBounds(10, 10, 100, 25);
    queryAggregate.setBounds(inset, inset, b.width-2*inset - 150, 80);
    tableAggregate.setBounds(new Rectangle(inset,
    inset + topHeight,
    b.width-2*inset,
    b.height-2*inset - topHeight));
    }

    judeyash wrote:
    Hi there
    I've set up a home office upstairs but can't connect to the Internet. Sometimes I can see 4 bars on wifi but can't connect (after buying a N dongle - it helped for one day and now it doesn't!). I can see all my neighbours networks.
    So tried using powerline Ethernet adaptors upstairs - again worked for one day then as soon as my husband used his laptop downstairs (plugged in) they stopped working.
    This is taking so much time to try and fix. If I bought a booster would that help and if so which one? Or are there fancy powerline adaptors that I could use (I'm using the ones given with my bt vision box)
    Please help
    INSSIDER
    Download Inssider2 for free from http://www.metageek.net/products/inssider/download install on your lap top then use your laptop downstairs same room as router
    it will  show you if your hub is still sending wifi when the husbands laptop is plugged in downstairs
    as power line adapters do the same its probably not interference
    If any post helps tick the star box on the left
    Just cause Im paranoid dont mean they are not out to get me

  • Need to wait for answer

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

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

  • Turn off close window icon

    Does anybody know how to disable the X in a JDialog so that it cannot be closed by the user? How do I do that? I see a setDefaultLookAndFeelDecorated(boolean) on JDialog and could set that to false but then what would I do?
    thanks,
    dean

    Err...
    On my computer, JDialog doesn't have window minimizing, maximizing or closing icons in the upper right corner of the dialog box itself. Did you mean that you don't want people to be able to close the parent (or application) window whenever there is a dialog box being displayed?
    For example, you cannot close the web browser by clicking on the "X" if there is a dialog box present?
    In which case you want the dialog box to be modal. That means the user cannot send any input whatsoever to any other window within the application - the dialog box commands focus and will not give it up until you click the YES, NO, or CANCEL buttons for example.
    By default, JDialog() is not modal. Certain JOptionPanes such as JOptionPane.showMessageDialog(), are modal. However, making things even more confusing, showMessageDialog() extends JDialog. If you ask that it extend JInternalFrame instead, the result is non-modal by default.
    Anyway, look at the examples within:
    http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html
    Depending on what you are trying to do within your application, it may be easier to just simply switch the JComponent from JDialog to JOptionPane.showMessageDialog() or another option. If not, there is a section in there on dealing with window closing events.

Maybe you are looking for

  • HT201269 How do I get the music from my iPod onto my iPad

    What cable do I need to link my iPod to my iPad (retina display)

  • Need a way to extract substring from string in oracle

    Hi all, I have one requirement related to extracting string from a paramater. suppose the string may like this in various format string:= 'This my string <Rid//problem/123456>' or string:= '<Rid//problem/123456> This my string' or string:= ' This is

  • File Adapter - Sender Problem

    Hi, While implementing a file to file interface I am facing problem in Integration Engine. Data is not passing to Integration engine, so it is not able to reach receiver. Receiver file adapter is working fine for other scenarion like IDoc to File. Fi

  • CS6 Prod Prem upgrade; Is there anyway I could get shipped disks?

    I qualify  for the free upgrade to CS6 Production Premium.  Once this becomes available, in roughly 10 days, would it be at all possible to get disks, rather than having to download it? CS6 PP is 12GB plus, and I have lowest end DSL. Downloading coul

  • Itunes Store is not loading..can't create an account.=c

    I have read a lot of discussions here to resolve my issue, but I came up with the same result.. my itunes store is not loading. It was working very fine before but now, it really doesn't load. I want to make my newest and first account in itunes stor