This week's book giveaway is in the Design and Architecture forum.
We're giving away four copies of Communication Patterns: A Guide for Developers and Architects and have Jacqui Read on-line!
See this thread for details.
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

How to stop the Jframe execution?

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79671
381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

                                   
 
A teeny tiny vulgar attempt to get you to buy our stuff
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic