Found 112 Articles for AWT

Is Swing thread-safe in Java?

raja
Updated on 07-Feb-2020 06:16:23

1K+ Views

No, Java Swing components are not thread-safe in Java.Why Swing Components are not thread-safeOne of the main reason for Java Swing is not thread-safe is to simplify the task of extending its components.Another reason for the Java Swing is not thread-safe due to the overhead involved in obtaining and releasing locks and restoring the state.Some of the Java Swing component methods will support multi-threaded access like repaint(), revalidate(), and invalidate() methods of JComponent class.Event Dispatch Thread (EDT)The Java Swing components can only be accessed from the Event Dispatch Thread (EDT) once a component is available for painting onscreen. The EDT thread is the thread that ... Read More

What is Double-buffering in Java?

raja
Updated on 30-Jul-2019 22:30:26

2K+ Views

Double-buffering is the process of drawing graphics into an off-screen image buffer and then copying the contents of the buffer to the screen all at once.For the complex graphics, using double-buffering can reduce flickering issues.Java Swing automatically supports double-buffering for all of its components.Double-buffering is memory intensive, its use is only justified for components that are repainted very frequently or have particularly complex graphics to display.If a container uses double-buffering, any double-buffered children it has shared the off-screen buffer of the container, the required off-screen buffer is never larger than the on-screen size of the application.To enable double buffering, simply ... Read More

Advertisements