Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-26-2008, 07:59 AM
Member
 
Join Date: Mar 2008
Posts: 1
Rep Power: 0
pmcastillo is on a distinguished road
Default 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:

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 nothing happens, I made some breakpoints and follow-through what is happening. And this is the code that is concerned with the "refresh" button:

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 );
        }

    }
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:

Code:
        refreshButton.setAction(actionMap.get("refresh")); // NOI18N
        refreshButton.setName("refreshButton"); // NOI18N
And I have no idea, how to call it. I'm really new to Java, I wish you could help me.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
refresh JPanel olesja AWT / Swing 1 04-16-2008 03:58 PM
Refresh Button p_dev_anand Java Blogs 1 01-07-2008 10:25 AM
New to JSF, simple problem with Eclispe and Tomcat nibeck JavaServer Pages (JSP) and JSTL 0 12-16-2007 05:53 PM
simple problem - code wont compile dirtycash New To Java 1 11-20-2007 05:49 PM
problem with a simple java code boy22 New To Java 2 08-03-2007 02:46 AM


All times are GMT +2. The time now is 04:34 PM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org