• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to stop the Jframe execution?

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Java program which has only one main which will launch the other JFrames with set.visible() command.
This program connects to MySQL database for inserting images. The inserting process is via GUI (JFrame) where the time of the image has to be typed in a JTextField.  I would like to avoid duplication in the database.
The data contain Time data and I would like to check if the given Time still exists on the table. If the Time still exists I would like to stop the data inserting and dispose of the JFrame. I tried the following code but it does not stop the process:

 

             
This part of the Jframe is inside a jButtonActionPerformed which will insert the image to the table. Can someone suggest me a solution to stop the action and dispose the JFrame if the condition is true?
I would appreciate any help!
 
Marshal
Posts: 70327
283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Beata Szabo-Takacs wrote:. . . launch the other JFrames with set.visible() command.

Why would yoiu want multiple frames? There are several better ways for multiple displays including desktop panes and dialogue windows.

This program connects to MySQL database for inserting images. The inserting process is via GUI . . .

I am afraid that doesn't sound like good design. Create an app that inserts images (or as people have discussed in the last week, references to images) without a GUI. The GUI is not your app, but simply an interface between the app and the user. Get the insertion working without a GUI fist.

. . .[code=java:firsline[28]]                                          dispose();[/code]. . .

What does that line do? What are you calling dispose() on? I can foresee threading problems because you still have to execute all that code on the event dispatch thread.
 
Beata Szabo-Takacs
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Meantime, I found a solution. I applied a boolean an I used the return function. Here is the code of JButton.ActionPerformed:

                                   
 
them good ole boys were drinking whiskey and rye singin' this'll be the day that I die. Drink tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic