Results 1 to 1 of 1
Thread: My Simple Refresh Problem
- 03-26-2008, 07:59 AM #1
Member
- Join Date
- Mar 2008
- Posts
- 1
- Rep Power
- 0
My Simple Refresh Problem
I'm using Netbeans 6.0.1. I've created a generic Java Desktop Application - Database Application from our library. Then added a little searchbar on the top. It looks like this:

My objectives is:
* The user will type something on the JTextField.
* Then the user will click the "SEARCH" button.
* Upon clicking, the query will be updated from: SELECT b FROM Books b
* Into: SELECT b FROM Books b WHERE b.title LIKE \"%" + jTextField1.getText () + "%\"
* Then call the "refresh" method (just like how the refresh booton work) to refresh the table
I tried:
But nothing happens, I made some breakpoints and follow-through what is happening. And this is the code that is concerned with the "refresh" button:Java Code:private void jButton1MouseReleased(java.awt.event.MouseEvent evt) { query = entityManager.createQuery ( "SELECT b FROM Books b WHERE b.title LIKE \"%" + jTextField1.getText () + "%\"" ); refresh(); // This ain't working }
But simply calling "refresh();" would simply ends in the "super(app);" statment. I made some quick lookup how the "refresh" button was setup, and all I could see is this:Java Code:@Action public Task refresh () { return new RefreshTask ( getApplication () ); } private class RefreshTask extends Task { RefreshTask ( org.jdesktop.application.Application app ) { super ( app ); } @Override protected Void doInBackground () { try { setProgress ( 0 , 0 , 4 ); setMessage ( "Rolling back the current changes..." ); setProgress ( 1 , 0 , 4 ); entityManager.getTransaction ().rollback (); Thread.sleep ( 1000L ); // remove for real app setProgress ( 2 , 0 , 4 ); setMessage ( "Starting a new transaction..." ); entityManager.getTransaction ().begin (); Thread.sleep ( 500L ); // remove for real app setProgress ( 3 , 0 , 4 ); setMessage ( "Fetching new data..." ); java.util.Collection data = query.getResultList (); Thread.sleep ( 1300L ); // remove for real app setProgress ( 4 , 0 , 4 ); Thread.sleep ( 150L ); // remove for real app list.clear (); list.addAll ( data ); } catch ( InterruptedException ignore ) { } return null; } @Override protected void finished () { setMessage ( "Done." ); setSaveNeeded ( false ); } }
And I have no idea, how to call it. I'm really new to Java, I wish you could help me.Java Code:refreshButton.setAction(actionMap.get("refresh")); // NOI18N refreshButton.setName("refreshButton"); // NOI18N
Similar Threads
-
refresh JPanel
By olesja in forum AWT / SwingReplies: 1Last Post: 04-16-2008, 03:58 PM -
New to JSF, simple problem with Eclispe and Tomcat
By nibeck in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 12-16-2007, 05:53 PM -
simple problem - code wont compile
By dirtycash in forum New To JavaReplies: 1Last Post: 11-20-2007, 05:49 PM -
problem with a simple java code
By boy22 in forum New To JavaReplies: 2Last Post: 08-03-2007, 02:46 AM


LinkBack URL
About LinkBacks

Bookmarks