Found 113 Articles for AWT

What are the differences between GridLayout and GridBagLayout in Java?

raja
Updated on 07-Feb-2020 06:09:22

5K+ Views

A GridLayout puts all the components in a rectangular grid and is divided into equal-sized rectangles and each component is placed inside a rectangle whereas GridBagLayout is a flexible layout manager that aligns the components vertically and horizontally without requiring that the components be of the same size. Each GridBagLayout object maintains a dynamic, rectangular grid of cells with each component occupying one or more cells called Component display area.GridLayoutA GridLayout arranges the components in a rectangular grid. It arranges component in the cells and each cell has the same size. Components are placed in columns and rows. GridLayout(int rows, int columns) takes two parameters that are a column and ... Read More

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