Performance technique on Swing application

Can some one tell me whats the performance technique i should have to follow on any Swing application or Database centric Swing application?
If i have huge amount of data which is coming from database and that data displaying in table format in Swing application. So, what performance technique i have to follow to improve the performance of Swing application?

Encephalopathic wrote:
good guess. What do you think? Loading the images in the painting methods?That is a common mistake. To the OP, some common errors when overriding paintComponent include:
1. Loading an image each time paintComponent() is called. Just load it once, cache it, and only draw it in paintComponent, this saves you from the IO of loading the image on repaints.
2. Doing application logic/complex operations in paintComponent. paintComponent should be kept fast, only do painting operations, keep long-running tasks, IO, etc. out of it.
3. To a lesser extent, doing lots of complex painting on a repaint call, maybe lots of transforms, translucency, xor-ing, whatever. For most common painting (at least in my work, YMMV), this isn't a problem, but if it is you should consider drawing all "static" stuff to a buffer (such as a BufferedImage) and just painting the BufferedImage, as opposed to drawing all the static stuff each paintComponent call.
The idea is just to keep the painting logic as fast as possible, to avoid slow repaints as you're seeing. Sometimes people don't realize that paintComponent() will be called every time your component needs to be even partially repainted (minimized/maximized window, partially hidden by another window then revealed again, stretched by window resizing, etc.). That's why things like IO are out of the question.
Of course, I'm babbling now. This may not even be your problem, or you may already know all this stuff. If so, just ignore this post!

Similar Messages

  • Performance issue on swing application

    Hi,
    I have one swing application and i am facing one performance issue after minimizing the applicaton. The same application is taking 2-5 seconds to redraw the screen again when i am trying to maximize it. Is there any way to improve this redraw delay ?..Is there any way to tweak the Event Dispatcher thread and by this we can overcome correct me if i am wrong? .
    Is there anybody facing such kind of issue please help me...
    Thanks in Advance,
    Anish.

    Encephalopathic wrote:
    good guess. What do you think? Loading the images in the painting methods?That is a common mistake. To the OP, some common errors when overriding paintComponent include:
    1. Loading an image each time paintComponent() is called. Just load it once, cache it, and only draw it in paintComponent, this saves you from the IO of loading the image on repaints.
    2. Doing application logic/complex operations in paintComponent. paintComponent should be kept fast, only do painting operations, keep long-running tasks, IO, etc. out of it.
    3. To a lesser extent, doing lots of complex painting on a repaint call, maybe lots of transforms, translucency, xor-ing, whatever. For most common painting (at least in my work, YMMV), this isn't a problem, but if it is you should consider drawing all "static" stuff to a buffer (such as a BufferedImage) and just painting the BufferedImage, as opposed to drawing all the static stuff each paintComponent call.
    The idea is just to keep the painting logic as fast as possible, to avoid slow repaints as you're seeing. Sometimes people don't realize that paintComponent() will be called every time your component needs to be even partially repainted (minimized/maximized window, partially hidden by another window then revealed again, stretched by window resizing, etc.). That's why things like IO are out of the question.
    Of course, I'm babbling now. This may not even be your problem, or you may already know all this stuff. If so, just ignore this post!

  • Calculate standalone time of a swing application.

    I have developed a swing application and i want to know, how can i calculate for how long the application was ideol and user just switched the application on and after that walk away and application is running onthe system and remain ideol. Now, after a certain period of ideol time i want to perform certain task. so, my problem is i am unable to get that ideol time of the application.
    if anyone knows how to calculte that pls let me know.
    thanks.

    Check out camickr's [Application Inactivity|http://tips4java.wordpress.com/2008/10/24/application-inactivity/] class.
    db

  • Oracle Jdeveloper 11g R1 has a Bug?-- Swing Application Deploy Error

    Oracle Jdeveloper 11g R1 (11.1.1.2.0) (build 5536)
    1. Create an empty swing application.
    File-->New-->Applications-->Java Desktop Application
    New-->Swing/AWT-->Frame
    2. Project properties--->Deployment: Create new JAR Deployment Profile: test
    3. Edit Deployment Profile: test
    File Groups --->new--->Create File Group (Type: Dependency Analysis) :da
    4. Error: Cannot enter "da"---->contributors , No display (such as "Libraris")
    5. If deploy it (test), I get an Unexpected Error.
    Error Messages:
    Title: StackOverflowError in o.ji.xml.JDevXmlIntergrationUtilsImpl:18
    Performing action Report a Bug...[ from oracle.jdevimpl.uieditor.UIEditorImpl ]
    Invoking command: [ from oracle.jdevimpl.uieditor.UIEditorImpl ]
    Performing action New...[ from oracle.jdevimpl.uieditor.UIEditorImpl ]
    Performing action Show Overview
    Performing action New...[ from oracle.ide.navigator.ProjectNavigatorWindow ]
    Invoking command: Class Generation[ from oracle.ide.navigator.ProjectNavigatorWindow ]
    Performing action Project Properties...[ from oracle.ide.navigator.ProjectNavigatorWindow ]
    Performing action New...[ from oracle.ide.navigator.ProjectNavigatorWindow ]
    Performing action New...[ from oracle.ide.navigator.ProjectNavigatorWindow ]
    Performing action New...[ from oracle.ide.navigator.ProjectNavigatorWindow ]
    Performing action Project Properties...[ from oracle.ide.navigator.ProjectNavigatorWindow ]
    Invoking command: [ from oracle.ide.navigator.ProjectNavigatorWindow ]
    Uncaught exception
    java.lang.StackOverflowError
    o.ji.xml.JDevXmlIntegrationUtilsImpl.canBeSelected0(JDevXmlIntegrationUtilsImpl.java:18)
    o.ji.xml.JDevXmlIntegrationUtilsImpl.canBeSelected0(JDevXmlIntegrationUtilsImpl.java:18)
    o.ji.xml.JDevXmlIntegrationUtilsImpl.canBeSelected0(JDevXmlIntegrationUtilsImpl.java:18) ......
    When I use Oracle Jdeveloper 10g (10.1.3.4.0) , I can use it to set Libraris.
    I have a swing application need these operation.
    Does anyone can tell me what's the reason?
    Thanks.
    I had tried Oracle JDeveloper 11g R1 (11.1.1.1.0)(Build 5407).
    It is OK.
    Maybe I need to download Oracle JDeveloper 11g (11.1.1.2.0) again.
    Edited by: [email protected] on 2010-2-24 下午4:58
    Edited by: [email protected] on 2010-2-25 下午5:47

    I am encountering the same bug / problem right now.
    Anybody from Oracle who has a workaround for this BUG?
    We are migrating to JDev 11.1.1.2.0 for a client and this bug is still there!
    Any help from the JDev team is highly appreciated!

  • How to connect ms access in swing application  JDeveloper

    hi guys,
    How do I do to connect MSAccess database in a swing application in JDeveloper?

    Just wondering, you asked how to connect to MS Access from a swing app being developed on JDev...
    Are you using ADF ? Or just using JDev to develop a plain vanilla java swing app ?
    If not using ADF :
    You could try the JDBC ODBC bridge. http://download.oracle.com/javase/6/docs/technotes/guides/jdbc/bridge.html
    Might be better than half baked JDBC type 4 drivers for Access.
    If using ADF, I'm assuming you have an ADF model project and an ADF swing project. If you can manage to use the JDBC-ODBC bridge, you should be able to configure a DataSource for your model project as javax.sql.DataSource and javax.sql.ConnectionPoolDataSource are now supported though the bridge.
    Please keep in mind the warnings on http://download.oracle.com/javase/6/docs/technotes/guides/jdbc/bridge.html, especially the limited scalability and performance.

  • How to embed/perform a Java Swing form into webased Swing form

    How to embed/perform a Java Swing form into webased Swing form or any alternative.
    Suppose i have 2 or more swing forms which are desktop applications but i want those forms to be now webbased..so how can i do this.Will i need to change the swing coding or will have to keep the swing design same.what can be the best Solution.

    You can launch your existing desktop app via the web using [Java Web Start|http://java.sun.com/javase/technologies/desktop/javawebstart/index.jsp]

  • Invoke an awt event from outside the swing application

    Is it possible to invoke an awt event triggered from outside the swing app? I am trying to implement a use case where i have to open a new tab in an already running swing app when a user clicks on a browser link.

    I have a desktop application that was invoked via webstart. The java webstart process started when the user clicked on a link that downloaded the swing application and now it runs in the clients JVM. Each browser click downloades and launches the application that performs a certain function. Now lets say, the user clicks on another link, then i don't want another java application to be launched. I want the same application that executes the function in lets say a new tab.
    Its kind of like you click on a link that somebody sent you in an outlook email. When you click on it and if firefox is already running, the link opens up in a new tab on an already running firefox browser. If firefox was not running, it starts a new firefox process.
    Hope this makes sense

  • Performance issue Java Swing under Windows 7

    Hello,
    we have MDI Java Swing application running under Window7. We got a big problem with performance in MDI Windows using AERO.
    Exist any way for Java to tell Win7 that it should not use Aero??
    Thank you,
    David.
    Edited by: 969767 on 6.11.2012 3:33

    If you try to open properties dialog for application (or app shortcut) there you can see "Compatibility" tab and there is check box "Disable visual themes". If we disable this theme our java swing app is very better performance under Windows 7. We need to disable visual theme via java code, if it is possible...
    Thanks.

  • Best setup for a swing application

    Hello,
    I have developed an Swing application for a EPOS machine.
    The machine has around 512 ram.
    What's the best setup for me in terms of performance, for example, which JVM to use etc.....
    Cheers
    Bobby

    bsbiran wrote:
    Hi,
    Well the app require alot of images and I parts of it do run 'slow'
    ...I'm currently going through a book about Swing and read that many times the "slowness" of a Swing-application can be credited to the programmer for not using the API efficiently/correctly (letting the app repaint too much, or repainting large parts that don't need repainting at all, to name just two things). So, I don't know how much of a Swing-guru you are, but it might be better to read a few decent Swing tutorials or pick up a good Swing book.

  • Is there free java chat, which i can embed in my Swing application

    Hello all,
    I have a Swing application and i want to embed java chat into it.
    Can you recommend me free chat for which i can see and modofy client and server sources.
    Regards,
    Chavdar

    No.

  • How to give Common Background color for all JPanels in My Swing application

    Hi All,
    I am developing a swing application using The Swing Application Framework(SAF)(JSR 296). I this application i have multiple JPanel's embedded in a JTabbedPane. In this way i have three JTabbedPane embedded in a JFrame.
    Now is there any way to set a common background color for the all the JPanel's available in the application??
    I have tried using UIManager.put("Panel.background",new Color.PINK);. But it did not work.
    Also let me know if SAF has some inbuilt method or way to do this.
    Your inputs are valuable.
    Thanks in Advance,
    Nishanth.C

    It is not the fault of NetBeans' GUI builder, JPanels are opaque by default, I mean whether you use Netbeans or not.Thank you!
    I stand corrected (which is short for +"I jumped red-eyed on my feet and rushed to create an SSCCE to demonstrate that JPanels are... mmm... oh well, they are opaque by default... ;-[]"+)
    NetBeans's definitely innocent then, and indeed using it would be an advantage (ctrl-click all JPanels in a form and edit the common opaque property to false) over manually coding
    To handle this it would be better idea to make a subclass of JPanel and override isOpaque() to return false. Then use this 'Trasparent Panel' for all the panels where ever transparency is required.I beg to differ. From a design standpoint, I'd find it terrible (in the pejorative sense of the word) to design a subclass to inconsistently override a getter whereas the standard API already exposes the property (both get and set) for what it's meant: specify whether the panel is opaque.
    Leveraging this subclass would mean changing all lines where a would-be-transparent JPanel is currently instantiated, and instantiate the subclass instead.
    If you're editing all such lines anyway, you might as well change the explicit new JPanel() for a call to a factory method createTransparentJPanel(); this latter could, at the programmer's discretion, implement transparency whichever way makes the programmer's life easier (subclass if he pleases, although that makes me shudder, or simply call thePanel.setOpaque(false) before returning the panel). That way the "transparency" code is centralized in a single easy to maintain location.
    I had to read the code for that latter's UI classes to find out the keys to use (+Panel.background+, Label.foreground, etc.), as I happened to not find this info in an authoritative document - I see that you seem to know thoses keys, may I ask you where you got them from?
    One of best utilities I got from this forum, written by camickr makes getting these keys and their values very easy. You can get it from his blog [(->link)|http://tips4java.wordpress.com/2008/10/09/uimanager-defaults/]
    Definitely. I bit a pair of knucles off when discovered it monthes after cumbersomely traversing the BasicL&F code...
    Still, it is a matter-of-fact approach (and this time I don't mean that to sound pejorative), that works if you can test the result for a given JDK version and L&F, but doesn't guarantee that these keys are there to stand - an observation, but not a specification.
    Thanks TBM for highlighting this blog entry, that's the best keys list device I have found so far, but the questions still holds as to what specifies the keys.
    Edited by: jduprez on Feb 15, 2010 10:07 AM

  • How to get mouse wheel action in my swing application?

    Hi
    In my mouse, i am having mousewheel to support scrolling.With the help of the wheel, i can scroll the pages in IE browser or any other appliction.
    In swing application ,i have scroll bar inside a JFrame.I want to have mousewheel action in my swing application to support scrolling.
    any idea ???
    Thanks

    As far as I know,there is no facility for detecting mouse scrolling wheel in JDK 1.3.
    Check it in the later releases of JDK.

  • I want to implement thems functionality in  my swing application

    Hi All...
    I want to implement the themes object in my swing application,How ,where to start and move that functionality,If anybody use this functionality in your program experience can u share with me.
    Than to Advance
    ARjun...

    Hi Kuldeep Chitrakar
    I can do that in web intelligence. dont want that
    I am replicating some of the sample report of SQL Servers in BusinessObjects XI R3.1.
    One of the SQL Sever's report is of product catalogue type that gives complete information like name, category, description along with the products image etc... for each of the products.
    I am trying to replicate the above said SQL Server report in Business objects XI R3.1. I am facing problem in bringing the image in to my BO report. The image resides in a table and its datatype is of varbinary(max). I don't know the exact matching while creating an object in the uiverse designer.
    Here is the url link http://errorsbusinessobjectsxir3.blogspot.com/2010/10/business-objects-image-errors.html
    Regards
    Prasad

  • Can not launch swing application from Java Web Start 1.6.0_37

    I have a dynamic generated jnlp file from a serlvet. When I used Java Web Start to start the swing application, it failed. The exception showed
    com.sun.deploy.net.FailedDownloadException: Unable to load resource: http://xxxx.xx.com:9080/dilpipweb/Test-1.0-SNAPSHOT.jar
         at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
         at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source)
         at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
         at java.util.concurrent.FutureTask.run(Unknown Source)
         at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    I used janela to validate the generated jnlp file. It was valid. I also checked the tomcat access log, it showed that the Test-1.0-SNAPSHOT.jar file was accessed correctly (with a 200 return code).
    Can anyone help me what was the problem?
    Thanks,

    Hi.
    I got a different problem. My Corba application works in JRE 1.6, but doesn't works in JRE 1.5.X. I got an unexpected error and my console shows:
    getSubjectX500Principal NoSuchMethodError: java.lang NoSuchMethodError
    #### Java Web Start Error:
    #### null
    Can you help me?

  • Java Swing application problem in Windows vista

    When we execute the Swing application in windows vista environment.
    The look and feel of the swing components are displayed improperly.
    Do we need to put any specific look and feel for windows vista environment or any specific hardware configuration is required to setup windows vista environment.
    Please give some inputs to solve the problem.
    We have tried with the following sample code to run in windows vista.
    * Vista.java
    * Created on December 5, 2006, 5:39 PM
    public class Vista extends javax.swing.JFrame {
    /** Creates new form Vista */
    public Vista() {
    initComponents();
    pack();
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
    jButton1 = new javax.swing.JButton();
    jToggleButton1 = new javax.swing.JToggleButton();
    jPanel1 = new javax.swing.JPanel();
    jCheckBox1 = new javax.swing.JCheckBox();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTextArea1 = new javax.swing.JTextArea();
    jTextField1 = new javax.swing.JTextField();
    getContentPane().setLayout(null);
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    jButton1.setText("Button 1");
    getContentPane().add(jButton1);
    jButton1.setBounds(20, 20, 170, 30);
    jToggleButton1.setText("Togle btn");
    getContentPane().add(jToggleButton1);
    jToggleButton1.setBounds(100, 80, 90, 20);
    jPanel1.setLayout(null);
    jCheckBox1.setText("jCheckBox1");
    jCheckBox1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    jCheckBox1.setMargin(new java.awt.Insets(0, 0, 0, 0));
    jPanel1.add(jCheckBox1);
    jCheckBox1.setBounds(10, 40, 130, 13);
    getContentPane().add(jPanel1);
    jPanel1.setBounds(10, 150, 200, 130);
    jTextArea1.setColumns(20);
    jTextArea1.setRows(5);
    jScrollPane1.setViewportView(jTextArea1);
    getContentPane().add(jScrollPane1);
    jScrollPane1.setBounds(210, 150, 164, 94);
    jTextField1.setText("jTextField1");
    getContentPane().add(jTextField1);
    jTextField1.setBounds(240, 30, 140, 30);
    pack();
    }// </editor-fold>//GEN-END:initComponents
    * @param args the command line arguments
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new Vista().setVisible(true);
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JToggleButton jToggleButton1;
    // End of variables declaration//GEN-END:variables
    }

    When we execute the Swing application in windows
    vista environment.
    The look and feel of the swing components are
    displayed improperly.Improperly means what? You must be aware that Vista's native L&F certainly isn't supported yet.

Maybe you are looking for

  • Sorry ...this is for all, please help me...copy controls

    That is okay, but how to identify which are the Sdocs and Delivery docs the company is using???? what should in the header and item be set...thats what i wanted to know....

  • My CD/DVD Drive Only Works When I Jam the CD/DVD in hard..?

    My CD/DVD drive only works when I stuff the CD/DVD in the drive EXTRA hard. If I just try to put in with normal force (that at one time worked) it spins the disc around, makes a spinning noise, and then ejects it. I'm taking it to the Apple Store soo

  • Firefox aborts its http request silently within 60 seconds

    duplicate of [/questions/1047223] *Summary Firefox aborts its http request within almost 60 seconds(period till timeout varies) and tells nothing to users. This happened with both of Nginx and Apache. *Environment Client browser: Firefox 35.0.1 Clien

  • Error message: not authorized to play them on your computer

    Error message: Some of the music in the itunes library weren't copied to the ipod because you are not authorized to play them on this computer. I have a Toshiba computer, Vista and I don't even know where to begin. Help anyone. Thanks.

  • Repeating Same Label on Sheet from one Data Row

    Post Author: mhamill CA Forum: Formula I need to print 18 labels on a sheet 3 columns x 6 rows of the SAME LABEL based on a single data record, I've got the label size all set but can only find a way to produce 1 label if I only have 1 record in the