SWing worker

Hi all,
I am new to swing programming,
please explain me the swing worker with an example program,
any help of code or tutorial is greatly appreciated.
thanks in advance,
karthik.

The Java™ Tutorials: [Worker Threads and SwingWorker|http://java.sun.com/docs/books/tutorial/uiswing/concurrency/worker.html]
db

Similar Messages

  • Using the swing worker to populate the data in to jtablle

    Hello, i am developing my 1st application in java swings , i have developed it but when i run a module which fetchces the data from the mysql and display it in jtable my swing gui got blank for some initial time, i was thinking for some progress bar type thing but when i came acroos google i found that i can use swing worker to load my GUI on time and in the back ground i can do the task of fetching the data from the data base and populating the Jtable, but i had done a lot of try but not succeded to implement the swing worker . Please help me to implement the swing worker :( . i am using the abstractTableModal to populating the jtable it is working fine but swing worker is not there .
    Scenerio is like this i have base frame on which i got 1 or more btton one of those button is Clients when i click on it a Jdialog box appears with the jtable . Pleae tell me how to implement the swing worker class between this. Pleaseeeeeeeeeeeeeeeeeeeeee :( I am help less now .

    Fahim i want to display some photograph in to a swing application after fetching these photo graph from the database table , i dont know what swing component will be better for it and i m designing this in netbeans , so please assist me with that , how to go now and please note that it is dynamic so component should be like that :(. i m trying to create a photo album where i upload the multiple photograph first then i would like to show them each photograph will a text box when some one write some text in that text box and press enter i would like to save that text with that photo graph , I AM DONE WITH THE PHOTO UPLOADING TASK BUT DONT KNOW HOW TO DO THE REST LIKE DISPLAYING THE PHOTOGRAPH WITH THAT TEXT BOX .
    Edited by: kamal.java on Apr 27, 2012 8:59 AM

  • Creator Freeze Often -- SWING Worker thread also

    I'm developping an app with creator. And I have many freezes in several minutes long as some people mentioned before.
    I'm running win XP on an opeteron 244(1.8G) x2 , with 2G memory. I've updated creator to the latest updates, but it doesn't seem to be better.
    The things I found is that when I edit Session Bean , Creator takes especially long time to come up.
    At that time, SWING worker thread of Creator IDE also stopping, No update of display , I only look window frame.
    You know the SWING has a Single thread model ,so if some logic uses SWING worker's thread long time, all displying process will be stopped.
    Below is the stacktrace just after a few seconds when Creator freeze by editing Session Bean.
    I use the stacktrace tool at http://tmitevski.users.mcs2.netarray.com/trace.do
    Full thread dump Java HotSpot(TM) Client VM (1.5.0_04-b05 mixed mode):
    "StackTrace Remote Thread" prio=5 tid=0x48b10418 nid=0x368 waiting on condition [0x00000000..0x4e85fbac]
    "Inactive RequestProcessor thread [Was:TimedWeakReference/org.netbeans.modules.projectapi.TimedWeakReference]" daemon prio=2 tid=0x48cc9e78 nid=0x634 in Object.wait() [0x4e89f000..0x4e89fbe8]
         at java.lang.Object.wait(Native Method)
         at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:692)
         - locked <0x1eeb8620> (a java.lang.Object)
    "Inactive RequestProcessor thread [Was:Default RequestProcessor/org.netbeans.modules.editor.NbEditorUI$2]" daemon prio=2 tid=0x48d00d18 nid=0x814 in Object.wait() [0x4e79f000..0x4e79fce8]
         at java.lang.Object.wait(Native Method)
         at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:692)
         - locked <0x1eeb8690> (a java.lang.Object)
    "Inactive RequestProcessor thread [Was:Java Children Provider/org.netbeans.modules.java.ui.nodes.elements.SourceChildren$4]" daemon prio=2 tid=0x48ce0d98 nid=0xd8c in Object.wait() [0x4e65f000..0x4e65fae8]
         at java.lang.Object.wait(Native Method)
         at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:692)
         - locked <0x1edbfe00> (a java.lang.Object)
    "Inactive RequestProcessor thread [Was:Suggestions Broker/org.netbeans.modules.tasklist.suggestions.SuggestionsBroker$2]" daemon prio=2 tid=0x473e1c80 nid=0x9fc in Object.wait() [0x4b84f000..0x4b84fbe8]
         at java.lang.Object.wait(Native Method)
         at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:692)
         - locked <0x1ed09d38> (a java.lang.Object)
    "Timer-48" prio=7 tid=0x492d4748 nid=0x930 in Object.wait() [0x4e43f000..0x4e43fa68]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:474)
         at java.util.TimerThread.mainLoop(Timer.java:483)
         - locked <0x1eb90290> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "Timer-46" prio=7 tid=0x4831ede8 nid=0xff0 in Object.wait() [0x4e71f000..0x4e71fae8]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:474)
         at java.util.TimerThread.mainLoop(Timer.java:483)
         - locked <0x1ea9f428> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "Timer-44" prio=7 tid=0x48b26ab0 nid=0xc50 in Object.wait() [0x4e81f000..0x4e81fb68]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:474)
         at java.util.TimerThread.mainLoop(Timer.java:483)
         - locked <0x1dc0d688> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "Timer-42" prio=7 tid=0x50f3bb68 nid=0x8f0 in Object.wait() [0x4e7df000..0x4e7dfa68]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:474)
         at java.util.TimerThread.mainLoop(Timer.java:483)
         - locked <0x1db078b8> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "Timer-40" prio=7 tid=0x48bbde20 nid=0xf0c in Object.wait() [0x4e75f000..0x4e75f9e8]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:474)
         at java.util.TimerThread.mainLoop(Timer.java:483)
         - locked <0x1d85d2b8> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "Timer-38" prio=7 tid=0x50e67840 nid=0x8a4 in Object.wait() [0x4e6df000..0x4e6dfae8]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:474)
         at java.util.TimerThread.mainLoop(Timer.java:483)
         - locked <0x1d7bc160> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "Timer-36" prio=7 tid=0x48ba3f50 nid=0xf58 in Object.wait() [0x4e5df000..0x4e5dfd68]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:474)
         at java.util.TimerThread.mainLoop(Timer.java:483)
         - locked <0x1d7bc1d8> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "Timer-34" prio=7 tid=0x48abb270 nid=0xee8 in Object.wait() [0x4e53f000..0x4e53fb68]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:474)
         at java.util.TimerThread.mainLoop(Timer.java:483)
         - locked <0x1d339d68> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "Timer-32" prio=7 tid=0x47a6e050 nid=0xe98 in Object.wait() [0x4e69f000..0x4e69fa68]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:474)
         at java.util.TimerThread.mainLoop(Timer.java:483)
         - locked <0x1b93e2e8> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "Timer-30" prio=7 tid=0x4925bd38 nid=0x9a8 in Object.wait() [0x4e4bf000..0x4e4bfa68]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:474)
         at java.util.TimerThread.mainLoop(Timer.java:483)
         - locked <0x1b3022f0> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "Timer-28" prio=7 tid=0x4930aae8 nid=0x620 in Object.wait() [0x4b70f000..0x4b70fae8]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:474)
         at java.util.TimerThread.mainLoop(Timer.java:483)
         - locked <0x1af19770> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "Timer-26" prio=7 tid=0x485620c8 nid=0x120 in Object.wait() [0x4e59f000..0x4e59fb68]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:474)
         at java.util.TimerThread.mainLoop(Timer.java:483)
         - locked <0x1978f0f8> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "Timer-24" prio=7 tid=0x46d7e9e8 nid=0xaf8 in Object.wait() [0x4e61f000..0x4e61fbe8]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:474)
         at java.util.TimerThread.mainLoop(Timer.java:483)
         - locked <0x196f19e8> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "VCS Command Tasks Starter Loop" daemon prio=2 tid=0x48aeed00 nid=0x96c in Object.wait() [0x4e4ff000..0x4e4ffbe8]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x18841770> (a org.netbeans.modules.vcscore.commands.CommandProcessor)
         at java.lang.Object.wait(Object.java:474)
         at org.netbeans.modules.vcscore.commands.CommandProcessor.executorStarterLoop(CommandProcessor.java:757)
         - locked <0x18841770> (a org.netbeans.modules.vcscore.commands.CommandProcessor)
         at org.netbeans.modules.vcscore.commands.CommandProcessor.access$700(CommandProcessor.java:65)
         at org.netbeans.modules.vcscore.commands.CommandProcessor$5.run(CommandProcessor.java:776)
         at java.lang.Thread.run(Thread.java:595)
    "Timer-16" prio=7 tid=0x46fa81a8 nid=0x69c in Object.wait() [0x4e3ff000..0x4e3ffd68]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:474)
         at java.util.TimerThread.mainLoop(Timer.java:483)
         - locked <0x151bf408> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "Timer-12" prio=7 tid=0x479eacf0 nid=0x2ec in Object.wait() [0x4b4df000..0x4b4dfce8]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:474)
         at java.util.TimerThread.mainLoop(Timer.java:483)
         - locked <0x1499b4e8> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "URLdisplayer" prio=7 tid=0x4865de20 nid=0xe2c in Object.wait() [0x4727f000..0x4727fd68]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x12a02bb0> (a org.netbeans.modules.extbrowser.NbDdeBrowserImpl$URLDisplayer)
         at java.lang.Object.wait(Object.java:474)
         at org.netbeans.modules.extbrowser.NbDdeBrowserImpl$URLDisplayer.getNextTask(NbDdeBrowserImpl.java:223)
         - locked <0x12a02bb0> (a org.netbeans.modules.extbrowser.NbDdeBrowserImpl$URLDisplayer)
         at org.netbeans.modules.extbrowser.NbDdeBrowserImpl$URLDisplayer.run(NbDdeBrowserImpl.java:235)
         at java.lang.Thread.run(Thread.java:595)
    "Text-Layout" prio=2 tid=0x475967e8 nid=0xa68 in Object.wait() [0x4b68f000..0x4b68fae8]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x129e8cd0> (a org.netbeans.editor.view.spi.ViewLayoutQueue)
         at java.lang.Object.wait(Object.java:474)
         at org.netbeans.editor.view.spi.ViewLayoutQueue.waitForTask(ViewLayoutQueue.java:128)
         - locked <0x129e8cd0> (a org.netbeans.editor.view.spi.ViewLayoutQueue)
         at org.netbeans.editor.view.spi.ViewLayoutQueue$LayoutThread.run(ViewLayoutQueue.java:182)
    "MDR event dispatcher" daemon prio=2 tid=0x47b8b450 nid=0x9c8 in Object.wait() [0x4b88f000..0x4b88fa68]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:474)
         at org.netbeans.mdr.util.EventNotifier$EventsDelivery.run(EventNotifier.java:257)
         - locked <0x087d1b10> (a java.util.LinkedList)
         at java.lang.Thread.run(Thread.java:595)
    "DestroyJavaVM" prio=5 tid=0x00038890 nid=0x4e4 waiting on condition [0x00000000..0x0007fae8]
    "TimerQueue" daemon prio=5 tid=0x46da6908 nid=0x768 in Object.wait() [0x4716f000..0x4716fb68]
         at java.lang.Object.wait(Native Method)
         at javax.swing.TimerQueue.run(TimerQueue.java:233)
         - locked <0x07b22b68> (a javax.swing.TimerQueue)
         at java.lang.Thread.run(Thread.java:595)
    "AWT-EventQueue-1" prio=7 tid=0x46ea8478 nid=0x990 runnable [0x4820e000..0x4820fbe8]
         at java.net.Inet4AddressImpl.getHostByAddr(Native Method)
         at java.net.InetAddress$1.getHostByAddr(InetAddress.java:842)
         at java.net.InetAddress.getHostFromNameService(InetAddress.java:532)
         at java.net.InetAddress.getHostName(InetAddress.java:475)
         at java.net.InetAddress.getHostName(InetAddress.java:447)
         at java.net.InetSocketAddress.getHostName(InetSocketAddress.java:210)
         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:341)
         at java.net.Socket.connect(Socket.java:507)
         at java.net.Socket.connect(Socket.java:457)
         at java.net.Socket.<init>(Socket.java:365)
         at java.net.Socket.<init>(Socket.java:207)
         at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:142)
         at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:280)
         at com.mysql.jdbc.Connection.createNewIO(Connection.java:1774)
         at com.mysql.jdbc.Connection.<init>(Connection.java:437)
         at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:268)
         at com.sun.rave.sql.DesignTimeDataSource.getConnection(DesignTimeDataSource.java:238)
         at com.sun.rave.sql.DesignTimeDataSource.getConnection(DesignTimeDataSource.java:214)
         at com.sun.sql.rowset.JdbcRowSetXImpl.connect(JdbcRowSetXImpl.java:410)
         at com.sun.sql.rowset.JdbcRowSetXImpl.prepare(JdbcRowSetXImpl.java:532)
         at com.sun.sql.rowset.JdbcRowSetXImpl.execute(JdbcRowSetXImpl.java:349)
         at caico.jsf.svc.itemSvc.<init>(itemSvc.java:81)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
         at java.lang.Class.newInstance0(Class.java:350)
         at java.lang.Class.newInstance(Class.java:303)
         at com.sun.rave.insync.beans.BeansUnit.instantiateBean(BeansUnit.java:884)
         at com.sun.rave.insync.live.LiveUnit.ressurectDesignBean(LiveUnit.java:339)
         at com.sun.rave.insync.live.LiveUnit.resurrect(LiveUnit.java:406)
         at com.sun.rave.insync.live.LiveUnit.sync(LiveUnit.java:294)
         at com.sun.rave.insync.live.LiveUnitWrapper.sync(LiveUnitWrapper.java:115)
         at com.sun.rave.insync.models.FacesModel.syncImpl(FacesModel.java:899)
         at com.sun.rave.insync.Model.sync(Model.java:207)
         at com.sun.rave.insync.Model.sync(Model.java:173)
         at com.sun.rave.insync.ModelSet$WindowManagerPropertyRegistry.processNodes(ModelSet.java:107)
         at com.sun.rave.insync.ModelSet$WindowManagerPropertyRegistry.propertyChange(ModelSet.java:125)
         at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:333)
         at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:270)
         at org.netbeans.core.windows.RegistryImpl.doFirePropertyChange(RegistryImpl.java:249)
         at org.netbeans.core.windows.RegistryImpl.tryFireChanges(RegistryImpl.java:222)
         at org.netbeans.core.windows.RegistryImpl.selectedNodesChanged(RegistryImpl.java:186)
         at org.netbeans.core.windows.RegistryImpl.topComponentActivated(RegistryImpl.java:138)
         at org.netbeans.core.windows.WindowManagerImpl.notifyRegistryTopComponentActivated(WindowManagerImpl.java:893)
         at org.netbeans.core.windows.Central.setActiveMode(Central.java:182)
         at org.netbeans.core.windows.Central.userActivatedMode(Central.java:1451)
         at org.netbeans.core.windows.view.DefaultView.userActivatedModeView(DefaultView.java:591)
         at org.netbeans.core.windows.view.ui.TabbedHandler$ActivationManager.handleActivation(TabbedHandler.java:477)
         at org.netbeans.core.windows.view.ui.TabbedHandler$ActivationManager.eventDispatched(TabbedHandler.java:425)
         at java.awt.Toolkit$SelectiveAWTEventListener.eventDispatched(Toolkit.java:2206)
         at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2100)
         at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2099)
         at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2099)
         at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2099)
         at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2099)
         at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2099)
         at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2099)
         at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2099)
         at java.awt.Toolkit.notifyAWTEventListeners(Toolkit.java:2058)
         at java.awt.Component.dispatchEventImpl(Component.java:3867)
         at java.awt.Container.dispatchEventImpl(Container.java:2024)
         at java.awt.Component.dispatchEvent(Component.java:3803)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3889)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
         at java.awt.Container.dispatchEventImpl(Container.java:2010)
         at java.awt.Window.dispatchEventImpl(Window.java:1774)
         at java.awt.Component.dispatchEvent(Component.java:3803)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    "Creator Error Handler Listener" prio=5 tid=0x4665f3d8 nid=0xf70 runnable [0x481cf000..0x481cfce8]
         at java.net.PlainSocketImpl.socketAccept(Native Method)
         at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
         - locked <0x0793baf0> (a java.net.SocksSocketImpl)
         at java.net.ServerSocket.implAccept(ServerSocket.java:450)
         at java.net.ServerSocket.accept(ServerSocket.java:421)
         at com.sun.rave.errorhandler.DebugServerThread.run(DebugServerThread.java:81)
    "Java2D Disposer" daemon prio=10 tid=0x467d6760 nid=0xa08 in Object.wait() [0x46c8f000..0x46c8fce8]
         at java.lang.Object.wait(Native Method)
         at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
         - locked <0x07451380> (a java.lang.ref.ReferenceQueue$Lock)
         at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
         at sun.java2d.Disposer.run(Disposer.java:107)
         at java.lang.Thread.run(Thread.java:595)
    "Active Reference Queue Daemon" daemon prio=2 tid=0x467bb638 nid=0xb70 in Object.wait() [0x46c4f000..0x46c4fd68]
         at java.lang.Object.wait(Native Method)
         at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
         - locked <0x07451408> (a java.lang.ref.ReferenceQueue$Lock)
         at org.openide.util.Utilities$ActiveQueue.run(Utilities.java:2465)
         at java.lang.Thread.run(Thread.java:595)
    "Timer-0" daemon prio=5 tid=0x4678f2f0 nid=0xaf0 in Object.wait() [0x46c0f000..0x46c0f9e8]
         at java.lang.Object.wait(Native Method)
         at java.util.TimerThread.mainLoop(Timer.java:509)
         - locked <0x07451498> (a java.util.TaskQueue)
         at java.util.TimerThread.run(Timer.java:462)
    "AWT-Windows" daemon prio=7 tid=0x467a54a0 nid=0x790 runnable [0x46a6f000..0x46a6fa68]
         at sun.awt.windows.WToolkit.eventLoop(Native Method)
         at sun.awt.windows.WToolkit.run(WToolkit.java:269)
         at java.lang.Thread.run(Thread.java:595)
    "AWT-Shutdown" prio=5 tid=0x467a5008 nid=0xafc in Object.wait() [0x46a2f000..0x46a2fae8]
         at java.lang.Object.wait(Native Method)
         - waiting on <0x07451568> (a java.lang.Object)
         at java.lang.Object.wait(Object.java:474)
         at sun.awt.AWTAutoShutdown.run(AWTAutoShutdown.java:259)
         - locked <0x07451568> (a java.lang.Object)
         at java.lang.Thread.run(Thread.java:595)
    "CLI Requests Server" daemon prio=5 tid=0x4676b380 nid=0xa64 runnable [0x4693f000..0x4693fbe8]
         at java.net.PlainSocketImpl.socketAccept(Native Method)
         at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
         - locked <0x07451720> (a java.net.SocksSocketImpl)
         at java.net.ServerSocket.implAccept(ServerSocket.java:450)
         at java.net.ServerSocket.accept(ServerSocket.java:421)
         at org.netbeans.CLIHandler$Server.run(CLIHandler.java:758)
    "Low Memory Detector" daemon prio=5 tid=0x00ab83b8 nid=0xee0 runnable [0x00000000..0x00000000]
    "CompilerThread0" daemon prio=10 tid=0x00ab7020 nid=0x9c4 waiting on condition [0x00000000..0x465cfa4c]
    "Signal Dispatcher" daemon prio=10 tid=0x00ab6470 nid=0x31c runnable [0x00000000..0x00000000]
    "Finalizer" daemon prio=9 tid=0x00aa95e0 nid=0x85c in Object.wait() [0x4654f000..0x4654fa68]
         at java.lang.Object.wait(Native Method)
         at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
         - locked <0x074519c0> (a java.lang.ref.ReferenceQueue$Lock)
         at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
         at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
    "Reference Handler" daemon prio=10 tid=0x00aa8150 nid=0xf1c in Object.wait() [0x4650f000..0x4650fae8]
         at java.lang.Object.wait(Native Method)
         at java.lang.Object.wait(Object.java:474)
         at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
         - locked <0x07451590> (a java.lang.ref.Reference$Lock)
    "VM Thread" prio=10 tid=0x00aa5780 nid=0x808 runnable
    "VM Periodic Task Thread" prio=10 tid=0x00ab9858 nid=0x1b0 waiting on condition

    Use a SwingUtilities.invokeLater(...) to invoke the main GUI. This will allow the button to repaint itself before the main GUI is invoked.

  • Swing Worker in JAVA 5

    Hi ,
    I want to add a progress bar in my applet while uploading the file on the server in JAVA 5.
    I want to use Swing Worker for it . Do anybody have some code of implemetation of SwingWorker on JAVA 5 for progressbar?

    Could you possibly download Java 6, get the source code for the SwingWorker class and use it? Regardless, most of what you use it for can be created with other constructs.

  • NullPointerException in BasicTableUI - Table updated in Swing worker thread

    I am getting following exception while updating a table :-
    java.lang.NullPointerException
    at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1141)
    at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1051)
    at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:974)
    at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
    at javax.swing.JComponent.paintComponent(JComponent.java:541)
    at javax.swing.JComponent.paint(JComponent.java:808)
    at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4771)
    at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4724)
    at javax.swing.JComponent._paintImmediately(JComponent.java:4668)
    at javax.swing.JComponent.paintImmediately(JComponent.java:4477)
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
    at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run (SystemEventQueueUtilities.java:117)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:448)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy (EventDispatchThread.java:197)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy
    (EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
    Since swing is not thread safe the table is updated in a swing worker thread. This should ensure that all gui updates are scheduled in the main event dispatching thread. Following is that code :-
    SwingWorker sw = new SwingWorker() {
    public Object construct()
    try{
    _myTable.updateUI();
    return null;
    }catch(Exception e){
    return null;
    public void finished(){
    sw.start();
    Inspite of doing these i am getting these exceptions.

    try using javax.swing.SwingUtilities.invokeLater(Runnable doRun)

  • Can we call Swing Utitlies.Invoke Later from Swing worker

    Hi
    I know The worker thread is to run as a seperate thread for time consuming process.i.e non GUI stuff.
    But my question is Can we call invokeLater from SwingWorker
    Thanks
    Rahul

    codingMonkey wrote:
    rahulm_32003 wrote:
    Hi
    yes it is correct.But my question to know whether can we call InvokeLater from Swing worker.What happens if we do like that.Does it make any problem IN GUI
    ThanksTry it.Of course you can try to do that. But why do you want to? Why do you insist on doing something silly?
    Post an example SwingWorker where this makes sense to do.

  • Swing worker question -- two lines performing a similar task concurrently

    Hi,
    I've been playing around with swingworker.
    The code below has a window with two buttons and two text areas.
    When you click a button, the text area will count out 10000 random numbers, and print "done." when it's finished.
    Each of the buttons works when pressed separately (one is running while the other is idle) But I can't push one, then the other and have the tasks run independantly.
    One stops and abruptly finishes while the other pauses.
    Sorry to post a lot of code, I'm going through the tutorials, I've looked at the example from the tutorial pretty extensivley, but that is only running one task.
    thanks.
    bp
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import javax.swing.border.Border;
    import javax.swing.BorderFactory;
    import java.awt.Insets;
    import javax.swing.*;
    import javax.swing.SwingWorker;
    public class TestGui2 extends JFrame{
          JButton button1;
          JButton button2;
          JTextArea tArea1;
          JTextArea tArea2;
          Border border;
          public void buildGui(){
                JPanel mainPanel = new JPanel();
                mainPanel.setLayout(new GridBagLayout());
                GridBagConstraints mpc = new GridBagConstraints();
                mpc.insets = new Insets(3, 10, 3, 10);
             border = BorderFactory.createLoweredBevelBorder();
                JLabel titleLabel = new JLabel("<html><h1><font face=\"Courier\">GridBagLayout Test Gui</font></h1></html>");
                mpc.weightx=0.5;
                mpc.fill = GridBagConstraints.CENTER;
                mpc.gridx=1;
                mpc.gridy=0;
                mainPanel.add(titleLabel, mpc);
                button1 = new JButton("run job1");
             button1.addActionListener(new Button1Listener());
                mpc.weightx=0.5;
                mpc.fill = GridBagConstraints.EAST;
                mpc.gridx=0;
                mpc.gridy=1;
                mainPanel.add(button1, mpc);
                tArea1 = new JTextArea("sample text");
             tArea1.setBorder(border);
                mpc.weightx=0.5;
                mpc.fill = GridBagConstraints.HORIZONTAL;
                mpc.gridx=1;
                mpc.gridy=1;
                mainPanel.add(tArea1, mpc);
                button2 = new JButton("run job2");
             button2.addActionListener(new Button2Listener());
                mpc.weightx=0.5;
                mpc.fill = GridBagConstraints.EAST;
                mpc.gridx=0;
                mpc.gridy=2;
                mainPanel.add(button2, mpc);
                tArea2 = new JTextArea("sample text");
             tArea2.setBorder(border);
                mpc.weightx=0.5;
                mpc.fill = GridBagConstraints.HORIZONTAL;
                mpc.gridx=1;
                mpc.gridy=2;
                mainPanel.add(tArea2, mpc);
                // frame settings
                add(mainPanel);
                setSize(700,450);
                setTitle("TestGui2");
                setDefaultCloseOperation(EXIT_ON_CLOSE);
                setVisible(true);
         // inner classes   
         class Button1Listener implements ActionListener{
              public void actionPerformed(ActionEvent e) {
              BigJobWorker worker = new BigJobWorker();
              worker.execute();
         class Button2Listener implements ActionListener{
              public void actionPerformed(ActionEvent e) {
                   BigJobWorker2 worker2 = new BigJobWorker2();
                   worker2.execute();
         //SwingWorker class
          class BigJobWorker2 extends SwingWorker<Void, Void>{
              protected Void doInBackground(){
                   try{
                        for(int i=0; i<10000;i++){
                        int num2 = (int)(Math.random() * 100);
                        Integer integerNum2 = num2;
                        tArea2.setText("iteration: " + i + " " + integerNum2.toString());
                        //ReallyBigJob rbj = new ReallyBigJob();
                        //tArea1.setText(rbj.doBigJob().toString());
                        tArea2.setText("done.");
                   } catch (Exception e3){
                   e3.printStackTrace();
              return null;
         private class BigJobWorker extends SwingWorker<Void, Void>{
              protected Void doInBackground(){
                   try{
                        for(int i=0; i<10000;i++){
                        int num = (int)(Math.random() * 100);
                        Integer integerNum = num;
                        tArea1.setText("iteration: " + i + " " + integerNum.toString());
                        //ReallyBigJob rbj = new ReallyBigJob();
                        //tArea1.setText(rbj.doBigJob().toString());
                        tArea1.setText("done.");
                   } catch (Exception e2){
                   e2.printStackTrace();
              return null;
          public static void main(String[] args) {
                 javax.swing.SwingUtilities.invokeLater(new Runnable() {
                      public void run() {
                            TestGui2 test = new TestGui2();
                            test.buildGui();
    BTW, I realize this code isn't as OOO as it could be (2 SwingWorker classes that do the same thing, 2 listeners that do the same thing) But I wanted to isoloate the problem first.
    thanks.
    Also, it's not impossible the program is working properly, it just finishes before the textArea can be updated.
    Edited by: badperson on Feb 28, 2008 8:24 AM
    Edited by: badperson on Feb 28, 2008 8:57 AM

    Hi,
    I reworked the code, and it now sort of works What I had wanted was to watch each window increment at the same rate, independant of each other. This will show a number in the window intemittenly, but not in a smooth continuous flow.
          class BigJobWorker2 extends SwingWorker<Void, String>{
              @Override
              protected Void doInBackground(){
                   try{
                        for(int i=0; i<100000;i++){
                        int num2 = (int)(Math.random() * 100);
                        Integer integerNum2 = num2;
                        //tArea2.setText("iteration: " + i + " " + integerNum2.toString());
                        publish("iteration: " + i + " " + integerNum2.toString());
                        //ReallyBigJob rbj = new ReallyBigJob();
                        //tArea1.setText(rbj.doBigJob().toString());
                        publish("done.");
                   } catch (Exception e3){
                   e3.printStackTrace();
                   tArea2.setText("EXCEPTION:");
              return null;
         // override process method
         @Override
            protected void process(List<String> messages) {
         Iterator i = messages.iterator();
              while (i.hasNext()){
              String message = (String)i.next();
              tArea2.setText(message);               
         } // end BigJobWorker2thanks,
    badperson

  • Swing Worker Problems

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class QuoteClientApplet extends JApplet
    implements ActionListener {
    private static boolean DEBUG = false;
    private InetAddress address;
    private JTextField portField;
    private JLabel display;
    private JButton sendButton;
    private JProgressBar progressBar;
    private DatagramSocket socket;
    private String host;
    private static final int MAX_NUM_CHARS = 256;
    private static final int TIMEOUT = 500; //time out after 1/2 a second
    private static String sendButtonText = "OK";
    private QuoteGetter quoteGetter;
    public void init() {
    //Initialize networking stuff.
    host = getCodeBase().getHost();
    try {
    address = InetAddress.getByName(host);
    } catch (UnknownHostException e) {
    System.err.println("Couldn't get Internet address: Unknown host");
    // What should we do?
    try {
    socket = new DatagramSocket();
    socket.setSoTimeout(TIMEOUT);
    } catch (IOException e) {
    System.err.println("Couldn't create new DatagramSocket");
    return;
    //Set up the UI.
    //Execute a job on the event-dispatching thread:
    //creating this applet's GUI.
    try {
    SwingUtilities.invokeAndWait(new Runnable() {
    public void run() {
    createGUI();
    } catch (Exception e) {
    System.err.println("createGUI didn't successfully complete");
    private void createGUI() {
    JPanel contentPane = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    int numColumns = 3;
    JLabel l1 = new JLabel("Quote of the Moment:", JLabel.CENTER);
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.SOUTH;
    c.gridwidth = numColumns;
    contentPane.add(l1, c);
    display = new JLabel("(no quote received yet)", JLabel.CENTER);
    display.setForeground(Color.gray);
    c.gridy = 1;
    c.gridwidth = numColumns;
    c.anchor = GridBagConstraints.CENTER;
    c.weighty = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    contentPane.add(display, c);
    JLabel l2 = new JLabel("Enter the port (on host " + host
    + ") to send the request to:",
    JLabel.RIGHT);
    c.gridy = 2;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.SOUTH;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    contentPane.add(l2, c);
    portField = new JTextField(6);
    c.gridx = 1;
    c.weightx = 1.0;
    c.insets = new Insets(0,5,0,0);
    c.fill = GridBagConstraints.HORIZONTAL;
    contentPane.add(portField, c);
    sendButton = new JButton(sendButtonText);
    c.gridx = 2;
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    contentPane.add(sendButton, c);
    progressBar = new JProgressBar();
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = numColumns;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5,0,5,0);
    contentPane.add(progressBar, c);
    portField.addActionListener(this);
    sendButton.addActionListener(this);
    //Finish setting up the content pane and its border.
    contentPane.setBorder(BorderFactory.createCompoundBorder(
    BorderFactory.createLineBorder(Color.black),
    BorderFactory.createEmptyBorder(5,20,5,10)));
    setContentPane(contentPane);
    private class QuoteGetter extends
    org.jdesktop.swingworker.SwingWorker<String, String> {
    int port;
    InetAddress address;
    public QuoteGetter(int port, InetAddress address) {
    this.port = port;
    this.address = address;
    @Override
    public String doInBackground() {
    DatagramPacket packet;
    byte[] sendBuf = new byte[MAX_NUM_CHARS];
    packet = new DatagramPacket(sendBuf, MAX_NUM_CHARS, address, port);
    try { // send request
    if (DEBUG) {
    System.out.println("Applet about to send packet to address "
    + address + " at port " + port);
    socket.send(packet);
    if (DEBUG) {
    System.out.println("Applet sent packet.");
    } catch (IOException e) {
    System.err.println("Applet socket.send failed:\n"
    + e.getStackTrace());
    return null;
    packet = new DatagramPacket(sendBuf, MAX_NUM_CHARS);
    try { // get response
    if (DEBUG) {
    System.out.println("Applet about to call socket.receive().");
    socket.receive(packet);
    if (DEBUG) {
    System.out.println("Applet returned from socket.receive().");
    } catch (SocketTimeoutException e) {
    System.err.println("Applet socket.receive timed out.");
    //Should let the user know in the UI.s
    return null;
    } catch (IOException e) {
    System.err.println("Applet socket.receive failed:\n"
    + e.getStackTrace());
    return null;
    String received = new String(packet.getData());
    StringBuffer data = new StringBuffer(received);
    //Hack alert! Assuming the last character is garbage, rid
    //this string of all garbage characters.
    int firstGarbage = data.indexOf(Character.toString(
    received.charAt(MAX_NUM_CHARS - 1)));
    if (firstGarbage > -1) {
    data.delete(firstGarbage, MAX_NUM_CHARS);
    return data.toString();
    //Once the socket has been read, display what it sent.
    protected void done() {
    if (DEBUG) {
    System.out.println("SwingWorker is done.");
    progressBar.setIndeterminate(false);
    try {
    String s = get();
    if (DEBUG) {
    System.out.println("get() returned \"" + s + "\"");
    if (s != null) {                   
    //Display the text.
    display.setForeground(Color.gray);
    display.setText(s);
    } else {
    display.setForeground(Color.red);
    display.setText("Read failed (see console for details).");
    } catch (Exception ignore) { }
    //invoked on the event-dispatching thread
    private void doIt(int port) {
    //Listen to the port on a background thread to avoid
    //tying up the GUI.
    quoteGetter = new QuoteGetter(port, address);
    quoteGetter.execute();
    display.setForeground(Color.gray);
    display.setText("Reading port #" + port);
    public void actionPerformed(ActionEvent event) {
    try {
    int port = Integer.parseInt(portField.getText());
    progressBar.setIndeterminate(true);
    doIt(port);
    } catch (NumberFormatException e) {
    //No integer entered.
    display.setForeground(Color.red);
    display.setText("Please enter a number in the text field below.");
    public void destroy() {
    //destroy the DatagramSocket?
    if (socket != null) {
    socket.close();
    //Set up the UI.
    //Execute a job on the event-dispatching thread:
    //creating this applet's GUI.
    try {
    SwingUtilities.invokeAndWait(new Runnable() {
    public void run() {
    getContentPane().removeAll();
    } catch (Exception e) { }
    This code is from:
    http://java.sun.com/docs/books/tutorial/deployment/applet/clientExample.html
    and I get the error (when I compile):
    package org.jdesktop.swingworker does not exist
    Now, I've reinstalled the latest jdk and jde, and yet I still get this problem. I've taken a class on java, however, it didn't cover anything like this, so I'm a bit confused. Please help :(

    Why do you have this in your code?
    private class QuoteGetter extends
    org.jdesktop.swingworker.SwingWorker<String, String> {The class you probably need is javax.swing.SwingWorker and its import is covered by your package import statementimport javax.swing.*;To post code, use the code tags -- [code]Your Code[/code]will display asYour CodeOr use the code button above the editing area and paste your code between the {code}{code} tags it generates.
    db

  • Dj native swing work in 10.8 but not work on 10.7.5

    hallo..
    this a problem..
    first i build java program on eclipse use swt-3.8M5-cocoa-macosx-x86
    in mac 10.8.. it's work fine..
    but when i try to run in 10.7.5 this not working..
    and i build again in 10.7.5 it's work fine..
    how can i handle this problem...
    the message error show
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/eclipse/swt/SWT
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.initialize_(SWTNativeInt erface.java:208)
    at chrriis.dj.nativeswing.swtimpl.NativeInterface.initialize(NativeInterface.java: 71)
    at chrriis.dj.nativeswing.swtimpl.core.SWTNativeInterface.open_(SWTNativeInterface .java:332)
    at chrriis.dj.nativeswing.swtimpl.NativeInterface.open(NativeInterface.java:100)
    it's the path problem or something else???
    thanks...

    The last Java update disabled Java plug-in and removed Java Preferences.app from your Utilities folder. This is because Apple is no longer supporting Java, if you need it follow these instructions...
    You can re-enable Java 6 by following this support article
    http://support.apple.com/kb/HT5559
    Or, you can update to Oracle's Java 7 here
    http://www.java.com/en/download/mac_download.jsp?locale=en

  • How to use Swing Worker

    Hello,
    I have an exe file which is to be called from my program and it runs as seperate thread. The main purpose of this exe file is to create two files within the application directory. Next my program check to see if these files exists if these file exists then the program display that the files have been created to the user..
    Now my problems
    The part of program which checks to see if the exe has created the file should runs in while loop as a seperate thread.
    The part of program which displays that the file is being generated should also runs as another thread.
    Please any body could code/pseudo-code the above for me, I would really be thank full and appreciate. I have tried to do the above, but in vain because some times the GUI interface does not get updated or some times the file does get created and the program loops forever.
    Please help
    Josh

    I just use SwingUtilities.invokeLater(..). Something like:
    SwingUtilities.invokeLater(new Runnable()
         public void run()
              someTextField.setText("some new text");
    });

  • JNLP - Swing application compiled in jdk1.5 not working in jdk1.6

    I have one swing application, compiled in jdk 1.5 and deployed in JNLP with jdk 1.5. When client machine try to access the application and having jre 1.5 then it works fine. but if client machine having jre 1.6 or version greater than 1.5 then application does not work properly.
    Please help me, i got stuck and not able to solve the problem.
    this is my JNLP
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="http://10.1.1.145:8080/uttimesheet" href="launch.jnlp">
    <information>
    <title>TimeSheet Portal</title>
    <vendor>Geometric Global</vendor>
    <description>A simple java desktop application based on Swing Application Framework</description>
    <description kind="short">TimeSheet Portal</description>
    <homepage href="http://appframework.dev.java.net"/>
    </information>
    <security>
    <all-permissions/>
    </security>
    <resources>
    <j2se version="1.5+" />
    <jar href="UTTimeSheet.jar" main="true" download="eager"/>
    <jar href="lib/antlr-2.7.5H3.jar" download="eager"/>
    <jar href="lib/appframework-1.0.3.jar" download="eager"/>
    <jar href="lib/asm.jar" download="eager"/>
    <jar href="lib/cglib-2.1.jar" download="eager"/>
    <jar href="lib/commons-collections-2.1.1.jar" download="eager"/>
    <jar href="lib/commons-logging-1.0.4.jar" download="eager"/>
    <jar href="lib/dom4j-1.6.jar" download="eager"/>
    <jar href="lib/hibernate3.jar" download="eager"/>
    <jar href="lib/jta.jar" download="eager"/>
    <jar href="lib/log4j-1.2.9.jar" download="eager"/>
    <jar href="lib/poi-3.0.2.jar" download="eager"/>
    <jar href="lib/postgresql-8.3-603.jdbc3.jar" download="eager"/>
    <jar href="lib/swing-layout-1.0.3.jar" download="eager"/>
    <jar href="lib/swing-worker-1.1.jar" download="eager"/>
    <jar href="lib/swingx-0.9.2.jar" download="eager"/>
    </resources>
    <application-desc main-class="timesheetproject.TimeSheetProjectApp">
    </application-desc>
    </jnlp>
    Thanks in Advance.

    Thanks Luca for your time,
    we have deployed application in tomcat and changed the home page of tomcat to our application home page(html page). and url is http://10.1.1.145:8080/
    Application home page contain link to jnlp. so whenever user click on link (in home page) then jnlp will execute and launch the swing application.
    do you need some more clarification?
    below is the home page(html).
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Launch TimeSheet Portal via JNLP</title>
    </head>
    <body>
         <center>
              <br>
              <img src="images/Geo-logo.JPG" />          
              <br>
              <hr width="70%" />
              <br>
              <table width="70%">
                   <tr><td> </td></tr>
                   <tr>
                        <td colspan="2" align="center">
                             <align="center">
                                  <h2>Welcome to TimeSheet Portal.</h3>
                             </align>
                        </td>
                   </tr>
                   <tr><td> </td></tr>
                   <tr><td> </td></tr>
                   <tr>
                        <td align="center">
                             <align="center">
                                  <h3><u>Live Sites:</u></h3>
                             </align>
                        </td>
                        <td align="center">
                             <align="center">
                                  <h3><u>Demo Sites:</u></h3>
                             </align>
                        </td>
                   </tr>
                   <tr>
                        <td width="50%" align="center">
                             <img src="images/launchPortal.png" onmouseover="this.src='images/launchPortalMouseOver.png';" onmouseout="this.src='images/launchPortal.png';" border="0"/>          
                             <br><br>
                             <img src="images/launchAdminPortal.png" onmouseover="this.src='images/launchAdminPortalMouseOver.png';" onmouseout="this.src='images/launchAdminPortal.png';" border="0"/>          
                        </td>
                        <td width="50%" align="center">
                             <img src="images/demoPortal.png" onmouseover="this.src='images/demoPortalMouseOver.png';" onmouseout="this.src='images/demoPortal.png';" border="0"/>
                             <br><br>
                             <img src="images/demoAdminPortal.png" onmouseover="this.src='images/demoAdminPortalMouseOver.png';" onmouseout="this.src='images/demoAdminPortal.png';" border="0"/>
                        </td>
                   </tr>
                   <tr><td> </td></tr>
                   <tr><td> </td></tr>
         </table>
         <table width="70%">
              <tr><td> </td></tr>
              <tr><td> </td></tr>
              <tr><td align="center">
                   FAQ   |  
                   Help   |  
                   Why Timesheet   |  
                   Report a bug   |  
                   Contact Us   |  
    Subtask Mapping   
              </td></tr>
         </table>
         <br><br><br><br>
         <table width="70%" bgcolor="#C0C0C0" style="vertical-align: bottom">
              <tr>
                   <td colspan="2" align="center" style="vertical-align: bottom" bgcolor="#C0C0C0">
                        ©<font size="1.5" face="Verdana"> 2008 Geometric Ltd. All rights reserved.<br>
                             Best optimized for a resolution of 1024 and above. JRE 1.5 is a pre-requisite                          for using these applications.
                        </font>
                   </td>
              </tr>
         </table>
         </center>
    </body>
    </html>
    Thanks.

  • Loading large files in Java Swing GUI

    Hello Everyone!
    I am trying to load large files(more then 70 MB of xml text) in a Java Swing GUI. I tried several approaches,
    1)Byte based loading whith a loop similar to
    pane.setText("");
                 InputStream file_reader = new BufferedInputStream(new FileInputStream
                           (file));
                 int BUFFER_SIZE = 4096;
                 byte[] buffer = new byte[BUFFER_SIZE];
                 int bytesRead;
                 String line;
                 while ((bytesRead = file_reader.read(buffer, 0, BUFFER_SIZE)) != -1)
                      line = new String(buffer, 0, bytesRead);
                      pane.append(line);
                 }But this is gives me unacceptable response times for large files and runs out of Java Heap memory.
    2) I read in several places that I could load only small chunks of the file at a time and when the user scrolls upwards or downwards the next/previous chunk is loaded , to achieve this I am guessing extensive manipulation for the ScrollBar in the JScrollPane will be needed or adding an external JScrollBar perhaps? Can anyone provide sample code for that approach? (Putting in mind that I am writting code for an editor so I will be needing to interact via clicks and mouse wheel roatation and keyboard buttons and so on...)
    If anyone can help me, post sample code or point me to useful links that deal with this issue or with writting code for editors in general I would be very grateful.
    Thank you in advance.

    Hi,
    I'm replying to your question from another thread.
    To handle large files I used the new IO libary. I'm trying to remember off the top of my head but the classes involved were the RandomAccessFile, FileChannel and MappedByteBuffer. The MappedByteBuffer was the best way for me to read and write to the file.
    When opening the file I had to scan through the contents of the file using a swing worker thread and progress monitor. Whilst doing this I indexed the file into managable chunks. I also created a cache to further optimise file access.
    In all it worked really well and I was suprised by the performance of the new IO libraries. I remember loading 1GB files and whilst having to wait a few seconds to perform the indexing you wouldn't know that the data for the JList was being retrieved from a file whilst the application was running.
    Good Luck,
    Martin.

  • Can't understand why my DefaultListCellRenderer doesn't work

    Hello i know that from the subject title it seems that this is the wrong category to post but because i need to load thumbnails in list and i resize them i didn't know where to post sorry if it is the wrong plase and also sorry for my bad english.
    I am making a programm that get's from the user some image paths , then makes thumbnails and then shows the thumbnails with a status and the name of the image. My list has HORIZONTAL_WRAP layout orientation and because i want to show the name the status and the thumbnail in the list i made a DefaultListCellRenderer. The problem is that when i add elements in the list it appears nothing but when i press with the mouse somewhere int the list the listImagesValueChanged is invoked and the data are passed correctly. I made an class named ImageThubInfo to save the name and the thumbnail for eatch image, also i am using a swing worker to create the thubnails and pass them along with all other information in ImageThubInfo and then store all ImageThubInfo objects to a list. When the worker thread is done it tries to add those elements to the list here is my code
    import java.awt.image.BufferedImage;
    import javax.swing.ImageIcon;
    import javax.swing.JOptionPane;
    * ImageThubInfo stores information for each image
    * @author maxsap
    public class ImageThubInfo  {
        public ImageThubInfo() {
        public ImageThubInfo(String status, String name, int width, int height, long size) {
            this(status, name, width, height, size, null);
        public ImageThubInfo(String status, String name, int width, int height, long size,BufferedImage thumbnail) {
            this.status = status;
            setName(name);
            this.width = width;
            this.height = height;
            this.size = size;
            this.thumbnail = thumbnail;
        public void setStatus(String status) {
            this.status = status;
        public String getStatus() {
            return status;
        public void setName(String name) {
            int indexOf = name.indexOf(".");
            this.name = name.substring(0, indexOf);
            JOptionPane.showMessageDialog(null, this.name);
        public String getName() {
            return name;
        public void setWidth(int width) {
            this.width = width;
        public int getWidth() {
            return width;
        public void setHeight(int heigth) {
            this.height = height;
        public int getHeight() {
            return height;
        public void setSize(long size) {
            this.size = size;
        public float getSize() {
            return size;
        public void setThumbnail(ImageIcon BufferedImage) {
            this.thumbnail = thumbnail;
        public BufferedImage getThumbnail() {
            return thumbnail;
        private String status;
        private String name;
        private int width;
        private int height;
        private long size;
        private BufferedImage thumbnail;
    }this is my DefaultListCellRenderer class
    import java.awt.Component;
    import java.awt.image.BufferedImage;
    import javax.swing.DefaultListCellRenderer;
    import javax.swing.ImageIcon;
    import javax.swing.JList;
    * @author maxsap
    public class ImageThubInfoRenderer extends DefaultListCellRenderer {
        public ImageThubInfoRenderer(){}
          @Override
        public Component getListCellRendererComponent(JList list,
                Object value,
                int index,
                boolean isSelected,
                boolean cellHasFocus) {
             super.getListCellRendererComponent(list,value,index,isSelected,
                                                                cellHasFocus);
            ImageThubInfo info = (ImageThubInfo) value;
            String name = info.getName();
            String state = info.getStatus();
            BufferedImage thumbnail = (BufferedImage)info.getThumbnail();
            setIcon(new ImageIcon(thumbnail));
            setText(name+" Current State: "+state);
            if (isSelected) {
                setBackground(list.getSelectionBackground());
                setForeground(list.getSelectionForeground());
            } else {
                setBackground(list.getBackground());
                setForeground(list.getForeground());
            return this;
    }and this is my swing worker class
    public class ThumbLoader extends SwingWorker<List<ImageThubInfo>, BufferedImage> {
          private DefaultListModel model;
          private int total;
          private File [] files;
          private List<ImageThubInfo> imageList;
          protected ThumbLoader(DefaultListModel model,File []files){
                this.model = model;
                this.files= files;
          @Override
          protected List<ImageThubInfo> doInBackground() throws Exception {
                imageList = new LinkedList<ImageThubInfo>();
                 for (int i = 0; i < files.length; i++) {
                    ImageIcon icon;
                    icon = createImageIcon(files.toString());
    if(icon != null){
    ImageIcon thumbnailIcon = new ImageIcon(getScaledImage(icon.getImage(), 100, 100,files[i]));
    return imageList;
    protected ImageIcon createImageIcon(String path) {
    if (path != null) {
    return new ImageIcon(path);
    } else {
    System.err.println("Couldn't find file: " + path);
    return null;
    private Image getScaledImage(Image srcImg, int w, int h, File file){
    BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = resizedImg.createGraphics();
    g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    g2.drawImage(srcImg, 0, 0, w, h, null);
    ImageThubInfo tubInfo = new ImageThubInfo("Waiting",file.getName(),srcImg.getHeight(null),srcImg.getHeight(null),300,resizedImg);
    imageList.add(tubInfo);
    JOptionPane.showMessageDialog(null, new ImageIcon(resizedImg));
    g2.dispose();
    return resizedImg;
    }protected void done() {
    setProgress(100);
    try {
    //JOptionPane.showMessageDialog(null, imageList.size());
    List<ImageThubInfo> imageList = this.get();
    for(int i=0; i< imageList.size(); i++){
    JOptionPane.showMessageDialog(null, new ImageIcon(imageList.get(i).getThumbnail()));
    model.addElement(imageList.get(i));
    } catch (InterruptedException ex) {
    Logger.getLogger(ThumbLoader.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ExecutionException ex) {
    Logger.getLogger(ThumbLoader.class.getName()).log(Level.SEVERE, null, ex);
    JOptionPane.showMessageDialog(null, "DONE");
    }}can anyone tell me what i am doing wrong???? please help because i really can't understand what i am doing wrong.
    thenks in advance                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Works okay now. Many changes to ThumbLoader:
    import java.awt.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.util.concurrent.*;
    import java.util.logging.*;
    import java.util.List;
    import java.util.LinkedList;
    import javax.swing.DefaultListCellRenderer;
    import javax.swing.*;
    public class ThumbLoader extends SwingWorker<List<ImageThubInfo>, Void> {
        private DefaultListModel model;
        private int total;
        private File[] files;
        private List<ImageThubInfo> imageList;
        protected ThumbLoader(DefaultListModel model, File[] files){
            this.model = model;
            this.files = files;
        @Override
        protected List<ImageThubInfo> doInBackground() throws Exception {
            imageList = new LinkedList<ImageThubInfo>();
            for (int i = 0; i < files.length; i++) {
                BufferedImage image = null;
                try {
                    image = javax.imageio.ImageIO.read(files);
    } catch(IOException e) {
    System.out.println("read error for " + files[i].getPath() +
    ": " + e.getMessage());
    if(image != null){
    BufferedImage scaled = getScaledImage(image, 100, 100);
    ImageThubInfo tubInfo = new ImageThubInfo("Waiting",
    files[i].getName(),
    image.getHeight(),
    image.getHeight(),
    300, scaled);
    imageList.add(tubInfo);
    return imageList;
    private BufferedImage getScaledImage(BufferedImage srcImg, int w, int h){
    BufferedImage resizedImg = new BufferedImage(w, h,
    BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = resizedImg.createGraphics();
    g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
    RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    g2.drawImage(srcImg, 0, 0, w, h, null);
    g2.dispose();
    // JOptionPane.showMessageDialog(null, new ImageIcon(resizedImg));
    return resizedImg;
    protected void done() {
    setProgress(100);
    try {
    //JOptionPane.showMessageDialog(null, imageList.size());
    // List<ImageThubInfo> imageList = this.get();
    imageList = get();
    for(int i=0; i< imageList.size(); i++){
    // JOptionPane.showMessageDialog(null, new ImageIcon(
    // imageList.get(i).getThumbnail()));
    model.addElement(imageList.get(i));
    } catch (InterruptedException ex) {
    // Logger.getLogger(ThumbLoader.class.getName()).log(Level.SEVERE,
    // null, ex);
    System.out.println("InterruptedException: " + ex.getMessage());
    } catch (ExecutionException ex) {
    // Logger.getLogger(ThumbLoader.class.getName()).log(Level.SEVERE,
    // null, ex);
    System.out.println("ExecutionException: " + ex.getMessage());
    // JOptionPane.showMessageDialog(null, "DONE");
    import java.awt.*;
    import java.io.*;
    import java.net.*;
    import javax.swing.*;
    public class Test {
        private JScrollPane getContent() {
            File[] files = getFiles();
            DefaultListModel model = new DefaultListModel();
            JList list = new JList(model);
            list.setCellRenderer(new ImageThubInfoRenderer());
            SwingWorker worker = new ThumbLoader(model, files);
            worker.execute();
            return new JScrollPane(list);
        private File[] getFiles() {
            String prefix = "images/geek/geek";
            String[] ids = { "-c---", "--g--", "---h-", "----t" };
            String ext = ".gif";
            File[] files = new File[ids.length];
            for(int i = 0; i < ids.length; i++) {
                String path = prefix + ids[i] + ext;
                URL url = getClass().getResource(path);
                try {
                    files[i] = new File(url.toURI());
                } catch(URISyntaxException e) {
                    System.out.println("everything is busted!");
            return files;
        public static void main(String[] args) {
            Test test = new Test();
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(test.getContent());
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    }geek images from [Geek Images|http://java.sun.com/docs/books/tutorial/uiswing/examples/components/index.html]

  • Background Worker

    I 'm using NetBeans ide version 6.1, i created the sample desktop application for a project that am doing. My question is related to the background worker action that you can create automatically. I found out how to add an action on a button, and now i want to make a generic background worker that i can pass objects such as my jdbc queries and execute it. I want also to be able to to use tha animation / progress bar also.

    Check out swing worker
    http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html

  • Swing app in JDK6 continues to rendering slow in Windows Terminal Server

    Hi,
    Because Swing apps create interfaces internally and not using default OS APIs,
    when running into a Windows Terminal Server client, there is no way to optimize
    rendering. Windows Terminal Server and Linux FreeNX use a mechanism to send
    to client only commands to render the windows. But, because the way Swing works,
    not totally integrated to OS APIs, it's not possible for terminal servers to do this,
    and these servers render Swing like images, something like VNC do, very slower than.
    I have tested native apps and AWT apps, and the difference is very significant,
    something like 50-70% faster.
    Is there some project in Swing APIs or java.net open-sources to better this?

    We are also seeing this issue with a Compiere implementation. With 10 distributed sites across the US, our client wanted to use Windows Terminal Services to simplify the client desktop management of the Swing application.
    But performance is terrible...and screen painting issues a real problem. We are also on JDK5 still, so I'm discouraged to see that JDK6 doesn't appear to offer much improvement?
    Is there any project afoot to address this issue for installations using terminal services?
    Thanks,
    Peter

Maybe you are looking for

  • Can I install Windows 7 on a Dell Inspiron 1300 B130?

    I don't see any Vista drivers on the Dell site so I'm guessing this isn't possible but has anyone tried? Did you get it to work? If you did, please tell me how. Thanks.

  • Create EJB and call it from ABAP

    Hi all, I have written a stand-alone-Java application, which should be converted into a web application, which has no gui. This application should be triggered by a abap-program. Following questions, do I have to write a servlet and a ejb or is it po

  • App object run order

    Is there any way to set the order in which app objects are run on the workstation other than using the "Wait on Force Run" and "Determine Force Run Order" options? Thanks...

  • DECIMAL PLACE UN UNIT OF MEASURE

    Dear Friends is ther any way to maintain decimal place during alternate  unit of measure.  FOr Ex 1  bar = 23.34 Kg. without rounding 100 bar = 2334 kg. i already maintained decimal in CUNI. still not able to maintain decimal. Thanks and Regards Madh

  • Debug error

    Please help me debug this code. Thank you. /* college java class */ import containers.Input; public class college      static Student s[] =new Student[100];      static int index;      public static void initialiseObjects()           for(index=0;inde