can anyone help me out.
Java Swing GUI's opens really slower than C# forms...is there anything to be done in the code.
and in Applets tooo is is really slower even if you just minimise n maximise the browser...in Applications the components are not seen unless u resize the form...anyone please....as m working on a Java Project for my company and it is a simple...Swing/JDBC Application

Dani AI

Generated

Two likely causes for the behavior described by are blocking the Event Dispatch Thread (EDT) with synchronous work (database calls, heavy I/O), and incorrect validation/painting of Swing containers. was on the right track about where to look. The checklist below gives practical fixes and quick tests.

Create and update UI on the EDT, but run database/authentication in a background thread. Use SwingUtilities.invokeLater to build the GUI and SwingWorker (or your own background thread) to perform DB work so the UI stays responsive. Example pattern:

SwingUtilities.invokeLater(new Runnable() {
    public void run() {
        createAndShowGUI(); // frame.pack(); frame.setVisible(true);
    }
});

new SwingWorker<Boolean,Void>() {
    protected Boolean doInBackground() throws Exception {
        return authenticate(username, password); // heavy work off EDT
    }
    protected void done() {
        boolean ok = get(); // update UI on EDT
        statusLabel.setText(ok ? "OK" : "Failed");
    }
}.execute();

If components only appear after resizing, call the proper validation methods after changing the UI: container.revalidate() and container.repaint() (or frame.validate() / frame.pack() for top-level windows). For custom painting, override paintComponent(Graphics) and always call super.paintComponent(g) so Swing’s double buffering and clipping work correctly.

If this is an applet, note there can be extra startup, security and plugin overhead; consider delivering as a signed standalone jar or Java Web Start (or migrate to modern deployment) to avoid browser-plugin delays. For more detail on correct threading, painting, and performance tuning, see Oracle’s Swing concurrency and performance guides: Swing Concurrency Tutorial and Swing Performance Tips.

Recommended Answers

All 2 Replies

Swing has better performance than AWT. The only problem is Swing draws it's own components which can cause some 'glitching' especially with larger applications that you may have to scroll. In reality, Java's VM is almost the same as the .NET engine, so there really shouldn't be that much of a speed difference. I'd say maybe look some more at your coding..... Are you trying to load a bunch of stuff from a database at RT?

its just a database authentication mdi....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.