InvokeandWait and button

Hello world

Just a simple question.
 

public static void main(String[] args) {
          try {
               EventQueue.invokeAndWait(new Runnable() {
                    public void run() {
                         try {
                              temp_intf frame = new temp_intf();
                              frame.setVisible(true);
                              
                         } catch (Exception e) {
                              e.printStackTrace();
                         }
                    }
               });
          } catch (InterruptedException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          } catch (InvocationTargetException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          }
     }

public temp_intf() {

// database connection instance 

Read values from tables and populated into few combobox 


button actionevent  {
process data depending on the above selected items of combobox and communicates back to the database
}

//database instance close()

}
All of the code works fine if I remove the button event and provide some default values.

as I am reading data at the time when I click on the button my instance is closed and raises the closed connection failure.

Is there a way that my instance of connection does not, close until I'm close or exit the Jframe, as there are chances I might add several events in the future


Thanks for all your time and help.

Hello

Looks like you need to read the chapter on concurrency in Swing tutorial: http://download.oracle.com/javase/tutorial/uiswing/concurrency/index.html - in particular, it is recommended to "long" things such as DB queries in the Event Dispatch Thread that runs all of the event handlers.
Although your question also suggests that you need to read the threads in general.

In addition, I suggest to use a connection pool DB (using for example Apache dbcp), which, for simple cases, ominously on connection closing almost not worth (but does not replace good multi-threading design).

Best regards

J.

Published by: jduprez on June 24, 2011 13:39

Tags: Java

Similar Questions

  • In the forum Coursera pages there are different icons and buttons, but I see that only holders of palce, small squares with letters in there. Any help?

    In the pages of the coursera.org forum, there are different icons and buttons. They do not display correctly. I can see only tiny forms square with characters in them. Hovering on them can display information in some cases, but it is not very convenient. Although they recommend Firefox, I use Chrome instead. Chrome has no questions here so far. Is it possible to view these icons correctly?

    Many sites now use downloadable fonts to create their icons instead of the traditional image files. So, there are some Firefox settings that might be a factor, as well as the NoScript extension, if you use this (blocked objects).

    (1) in the dialog box fonts Advanced, unchecking the checkbox which allows the site to use its own choice of fonts. To check that:

    "3-bar" menu button (or tools) > Options > content > button "Advanced".

    Here you must "allow pages to choose their own fonts.

    (2) on the deactivation of fonts downloaded in: config. It's less likely, or you remember probably not, but here's how to check on it.

    • In a new tab, type or paste Subject: config in the address bar and press ENTER. Click on the button promising to be careful.
    • In the search box at the top of the list, type or paste the gfx and make a pause so that the list is filtered
    • If gfx.downloadable_fonts.enabled preference is bold and user, set false, double-click it to return it true.

    This seems useful.

  • HP Pavilion 17-f065us: power and buttons f6 (Mute) remain lit after a stop on HP Pavilion 17 - f065us

    I have upgraded to Windows 10 in October 2015 and everything worked very well until about two weeks ago, I noticed that when I would stop my computer Power and buttons f6 would remain lit.  I would go ahead and close the lid of my but next time I would go to to open they would always be lit.  I have to press on and hold the Power button until the lights go out.

    Hello

    Try disabling the startup of Windows 10 hybrid - you can do the following.

    Open settings and select System.  Select food and sleep, and then click additional power settings - in the next window, click on "Choose what the power button" in the left pane.

    In the next window, click on "Change settings that are currently unavailable" (close), then Remove the check mark from the box against 'Turn on a quick start (recommended) '.  Click on the button Save the settings, and then close open windows and stop the laptop by right clicking on the icon from the Start Menu, select prompt (Admin) and click 'Yes' to the uac prompt.

    Type (or copy and paste) the following command (including spaces) and click Enter.

    Shutdown /s /t 0

    Start Notepad and let Windows take over completely for a few minutes before checking if the lights now now disable to stop correctly.

    If this has fixed the problem, it may be useful by turning the quick start back on - sometimes simply remove and re-create the file will solve the problem.

    Kind regards

    DP - K

  • his silence and buttons wireless seems to have been disabled

    I accidentally spilled coffee on my notebook Pavilion dv6 notes and in a frantic attend to mop up the liquid, I must have somehow disabled the silent sound and buttons wireless while wiping the keys.  They worked before the oil spill, but not after.

    Also, as an aside, the left shift key works more so.  It can be bypassed, but it would be nice if the worked.  Any help would be appreciated

    Hey @306hp ,.

    Thank you for visiting the Forums HP's Support and welcome. I read on your HP laptop and get a fix of coffee. Try perform a reset. When you perform a hard reset note remove all USB devices and remove cards memory card reader location. Disconnect all non-essential devices.

    If that doesn't help try to turn on the computer, on which you begin to press F11 repeatedly until the menu opens. You can do a System Restore. System restore allows you to convert any changes that might have happened after the accident.

    I would use q-tips to ear slightly moistened to clean around the stuck key. Coffee gets in it a causes it to stick.

    Hope it will be useful.

    Thank you.

  • Windows and buttons locked tab appearance on screen

    I don't know why, but my windows and buttons drop-down menu is locked to the appearance on the view menu tab

    Here is a picture http://imageshack.us/photo/my-images/199/probro.png/

    My profile
    Intel Core i3
    3.10 Ghz clock speed
    Intel High Defination Familly with 1024 MB of VRAM graphics
    Windows XP Professional SP3 32-bit version
    4 GB OF RAM
    500 GB hard drive
    Help me

    Hello

    • How long have you been faced with the same question?

    You can view these methods:

    Method 1:

    How to configure Windows XP to start in a "clean boot" State
    http://support.Microsoft.com/kb/310353
    Note:
    How to configure Windows to use a Normal startup state
    After you have used the boot is a way to solve your problem, you can follow these steps to configure Windows XP to start normally.
    1. click on start and then click Run.
    2. type msconfig and click OK.
    The System Configuration Utility dialog box appears.
    3. click on the tab general, click Normal Startup - load all services and device drivers and then click OK.
    4. When prompted, click on restart to restart the computer.
     
    Method 2:
    You can check in another user account.
    How to create and configure user accounts in Windows XP
     
    Method 3:
    I also suggest you to update display drivers on the manufacturer's Web site.
     
     
  • What do you do when windows and buttons is gray out?

    Hi, my name is Rhionna and I have a problem on my Windows XP Service pack 3. Well, last night, I scanned my PC for registry errors there were some and I fixed them, but now I can not apply visual styles. Windows and buttons in properties is grey outside, it wasn't before but today I went to a link to a website to try to repair the files in my theme after that, it was gray would be out so what do I do? :(

    Registry cleaners are dangerous programs.  I do not recommend their use for these sorts of reasons.  Your best bet at the moment is to restore your registry to a time before you had this problem using "System Restore".  One of these two methods, you should get going again.

    "How to restore Windows XP to a previous state"
      <>http://support.Microsoft.com/kb/306084 >

    If you cannot start the program of the above procedure, or if it fails to restore, then try this:
    "How to start the System Restore tool by using the option of safe mode with the command prompt in Windows XP"
      <>http://support.Microsoft.com/kb/304449 >

    HTH,
    JW

  • Problem with wheel scrolling and buttons on Microsoft mouse optical basic v2.0 in Vista

    Hello recently, I logged on to my computer and found out that my laser mouse does not shine by the sensor and the pointer didn't budge when I moved the mouse wheel works only the buttons and scroll

    Why what happened?

    wheel scrolling and buttons on my mouse works nothing else don't

    EDIT: im using a basic v2.0 mouse Microsoft Optical

    Nope it na no:(mais c'est correct, je pense que c'est un problème matériel et j'ai acheté une nouvelle souris qui fonctionne très bien)

    but thanks for your help when even :) as I'm not sure how this forum works, but I think a mod should close this question

  • How to check the links and buttons of enamel are traceable? If I send the email through Eloqua?

    I sent you an email through Eloqua. I don't know how to check the links and buttons are traceable?

    Hi Lucie,.

    There are 3 ways to check your links and buttons are traceable or not:

    1. When you mouse pass the link or button it will not display the actual URL. It will show you a few encrypted URL which will redirect you to the actual URL.

    2. connect to the eloqua account and search your email. When your email open ups click setting ICON and then click on manage links. All the links and URL of the button should be checked.

    3. If you want to check at the level of the code make sure after all the links and buttons URL "elqtrack = true" must be written.

    Hope this will help...

    Thank you

  • Definition of the label you want its width (and button)

    How can I pay for my labelto preferred size to the width of the text there? I have an label, the TextField and button all in one line in a GridPane, using FXML. The label is in (0, 0), is the TextField (0, 1) and the button is in (0, 2).

    My behavior wanted would be for the Label and Button , take just enough space to properly display text and the TextField in the Middle look after the rest of the space. I'd rather not simply understand the width of the text and to hardcode the values, as that could create problems if I change the text later, and I prefer not having to calculate the width and then set the width by default in this way, because it would probably be to write code outside the FXML file and to my knowledge calculation of the width of the text in JavaFX is a hack at best.

    Add

      
    

    within these two the tags and.

  • Menus and buttons to recall?

    I know that in the past, the menus and buttons were material extra that only can be found on a separate disc, where do download us such things now? It is the part of the creative cloud, right?

    Hi "malacca73".

    You can download the content by clicking on this link:

    http://helpx.Adobe.com/x-productkb/multi/library-functional-content-missing.html

  • How to change the font size of statictext and button is the font size in the user interface?

    Hello

    How to change the font size of statictext and button is the font size in the user interface?

    Thks.

    Goldbridge

    var w = new Window ("dialog");
    var s = w.add ("statictext", undefined, " 30 Point Static");
    var s2 = w.add ("statictext", undefined, " 100 Point Static");
    // the third argument is the font size
    s.graphics.font = ScriptUI.newFont ("Helvetica", "Bold", 30);
    s2.graphics.font = ScriptUI.newFont ("Helvetica", "Bold", 100);
    
    w.show ();
    

    See the example above.

    See also Peter Karhels Guide to the user interface. Very recommended.

    http://www.kahrel.plus.com/InDesign/ScriptUI-1-9.PDF

  • New issues of Viewer with WHO and buttons

    Hello

    I had a publication almost ready to go, has worked very well and uploaded to the cloud. Then I updated the tools, builder on mac and Viewer on iPad with all latest updates (including the update January 26 and Jan. 17 Folio tools etc.) and all WHO and buttons, I had started "misbehaving." I have re-uploaded all on cloud again and I got these errors:

    -Some buttons have become "untappable" (they work fine on the Desktop Viewer)

    -J' have pop MSO box with the text which is triggered by a button - text will not appear on the iPad, but it shows on desktop viewer correctly. If I saw it, it shows too much on iPad

    -With the previous observer, the video would come before any object when it is played, including the ESM. Now, it seems to put the video in the face and cover all your buttons "play" etc.

    Can you tell me if these are planned on the workflow changes or just a mistake on the viewer of the iPad and planning be fixed?

    Cheers, Tony

    Tony, I see this is your first post.

    PLEASE read the other threads published recently. In short, it is a bug very serious (IMO) in the viewer of content on the iPad.

    If you have not used the new features in the new tools you can restore version 17.

    Bob

  • HIGHLIGHTS HD Blu - ray DVD project - built at-SD and BUTTON TEXT

    I use Encore CS4 on a Mac Pro running 10.6.5. I drafted a Blu - ray and built my menu inside Photoshop CS4. The menu is 1920 x 1080 and has several buttons text. The buttons are consisting of a layer group ' (+) button name ' with a text on the inside layer. Initially, I selected the option 'Create text subpicture' for each button on the inside yet. I tried later to create inside each button subpicture layers defined in photoshop by creating "(= 1) button subpicture" layers within each group of 'name of the button (+)'.

    I have set up my games color and in the preview again and engraved on a Blu - ray disc button highlights look crisp and clear. I then try to generate output of DVD on a DVD format disc. My highlights of the menu are very irregular and the edges of the text seem to be cut off (I see the color of the normal state).

    I made sure to disable antialiasing on all my text buttons. I also expect a lot of reminder of the downscaling ability? If I resize my menu from 1920 x 1080 to 720 x 480 and replace it BY NTSC widescreen in Photoshop and then start with a new DVD project in everything seems fine. I hope not having to rebuild the chapter menus and button routing every time I create a project both BD and DVD.

    The buttons of my chapter menus work fine. Don't know what the difference with the exception of a different color welcomes you. I compared the menus in photoshop and all settings appear to be the same.

    The downscaling of the menus again from HD to SD quality is absolutely horrible. That's why I always build separate projects for Blu - ray and DVD, despite the ability of the program to output DVD and Blu - ray for a single project. You will get much better quality by reduction of scale your menus in Photoshop.

    My company creates motion menu to recall model kits, and we create a separate button for each format highlights (HD, SD, PAL) in Photoshop for our products, simply because of the unacceptable quality of the downscaling of the still.

  • Text input and button who stretches without reason in accordion

    Take a look at this http://beta.goodsense.com.

    Click on "search catalog.

    Can someone tell me why the textinput and button are stretched like that? They look good in their individual containers, but when I put them in the accordion, they stretch like that... Note that if you type some text in, the first letter does not begin at the far left.


    Component of the search box:

    "" < mx:HBox xmlns:mx = ' http://www.adobe.com/2006/mxml " height ="100% "verticalAlign ="top"horizontalAlign ="left"width ="100% ">
    < mx:TextInput width = "190" id = "searchBox" text = "{_defaultText}" editable = "true" focusIn = "{onFocus ()}" Focusout/focusouthandler() = "{onFocusOut ()}" / > "
    < mx:Button "691" = x y = "132" label = "Go" id = "searchBtn" click = "{getSearchResults ()}" / >
    < / mx:HBox >

    Element of the accordion:
    "" < mx:Accordion xmlns:mx = ' http://www.adobe.com/2006/mxml " width ="265"height ="360"creationComplete =" init () "xmlns:ns1 =" goodsense.Components. * ">"
    < ns1:FilterTherapeuticClass id = "tClassFilter" / >
    < ns1:ProductGroupfilter id = "prodGroupFilter" enabled = "false" / >
    < ns1:SearchBox id = "searchBox" label = "catalog search" paddingTop = paddingLeft = "5" "5" width = "100%" / >
    < ns1:CompareToFilter id = "compareToFilter" / >
    < / mx:Accordion >

    I thought about it. My CSS has a property called "textindent = 25" that I didn't think would affect his children. The textindent aimed for the header, so I added this line to the header css instead.

    Accordion {}
    borderStyle: none;
    borderThickness: 2;
    headerHeight: 26;
    backgroundAlpha: 0.09;
    textIndent: 25;
    openDuration: 523;
    fillAlphas: 0, 0, 0, 0;
    backgroundColor: #ffffff;
    borderColor: #ff9933;
    dropShadowEnabled: true;
    shadowDirection: right.
    headerStyleName: 'myaccordionHeader ';
    }
    {.myaccordionHeader}
    color: #ff9933;
    textIndent: 25;
    fontFamily: Tahoma;
    fontWeight: bold;
    }

  • Region HTML - element, TextBox and Button on the same line

    Hello

    I have a search page:
    POINT region HTML with a search box and a button (created in the section of button).


    How can I align the search box and the key? (on the same line)
    I see that the choice for the button to align at the top or on the button of the section. If the button is under or above the search box.

    Or maybye is possible to hide the searbox and button and create a table html for alignment?


    I work with Apex 3.1.2.00.02
    Region: HTML
    Theme: Dark blue:
    Model: region of report

    Thank you

    Roseline

    Roseline,

    Create a new button and select the Create button as an element and not in the position of the region.

    Option buttons behave differently to the buttons of the Position of the region.
    If you are wanting to use the button 'Submit' page, you need to change the button to target is a URL and add javascript:doSubmit('YOUR_REQUEST_VALUE');

    Gus...

    AWARDS: Don't forget to mark messages USEFUL or CORRECT on the forum, not only for my answers, but for everyone!
    ;-)

Maybe you are looking for

  • Portege M200 - WLan disappears and cannot be reconnected

    Hey guys,. I have a toshiba portege M200 computer laptop with Windows XP Professional and SP2. If I turn the WLAN adapt the WLAN network appears once and I can connect and use it without problem. If I disable and enable the wireless network adapter o

  • dx2300, beep at startup

    I bought a computer format used DX2300 microtour. It worked wonderfully to home sellers. We have removed the son/cables and I took it home. When I reassembled everything I have no action on the (dual) monitors, no lghts on the wireless mouse or keybo

  • USB 6008 digital output signal

    I am VERY new to LabView and have been racking my brain trying to get digital output of my USB-6008.  All I want is to be able to get a signal of + 5 V of my digital output when I click on a button.  This signal opens a valve on a system I see so whe

  • 32-bit faster than 64-bit

    I ran a program for the acquisition of data on LabVIEW 2011 32 bit and used 5-6% CPU according to the Task Manager. I ran the same program on LabVIEW 2013 64 bit and it uses processor 8-9% according to the Task Manager. I thought that the 64 bit vers

  • Files of Skype, unable to put files

    * O.T. > Skype files I sent a friend a file on Skype and he had problems with his 9 Windows tries to put a file in its folder, but he could not find Windows File Explorer Please THIS PROBLEM FIX!