Raja has Published 469 Articles

How many types of selection modes for a JList in Java?

raja

raja

Updated on 10-Feb-2020 07:01:22

811 Views

A JList is a component that can extend JComponent class used to display a list of objects that allows the user to select one or more items.There are three types of selection modes for a JList in JavaListSelectionModel.SINGLE_SELECTION: Only one list index can be selected at a time.ListSelectionModel.SINGLE_INTERVAL_SELECTION: Only one contiguous interval ... Read More

How can we implement a scrollable JPanel in Java?

raja

raja

Updated on 10-Feb-2020 06:35:13

4K+ Views

JPanelA JPanel is a subclass of JComponent (a subclass of a Container class). Therefore, JPanel is also a Container.A JPanel is an empty area that can be used either to layout other components including other panels.In a JPanel, we can add fields, labels, buttons, checkboxes,  and images also.The Layout Managers such ... Read More

How can we implement editable JComboBox in Java?

raja

raja

Updated on 10-Feb-2020 06:34:10

1K+ Views

JComboBoxA JComboBox can extend JComponent class and it is a combination of a text field and a drop-down list from which the user can choose a value.If the text field portion of the control is editable, the user can enter a value in the field or edit a value retrieved from ... Read More

How to implement a program to count the number in Java?

raja

raja

Updated on 10-Feb-2020 06:17:01

1K+ Views

The program uses a JLabel to hold a count label, a JTextField component to hold the number count, JButton component to create add, remove and reset buttons. When we click the add button, the count in the JTextField will get incremented by '1' and by clicking the remove button the count will be decremented by '1'. If we click ... Read More

How can we add new tabs to JTabbedPane from a JMenu in Java?

raja

raja

Updated on 07-Feb-2020 11:42:24

341 Views

JTabbedPaneA JTabbedPane is a component can extend JComponent class and it can provide easy access to more than one panel.Each tab is associated with a single component that can be displayed when the tab is selected.A JTabbedPane can generate a ChangeListener interface when a tab is selected.The important methods of ... Read More

How many types of JDialog boxes can be created in Java?

raja

raja

Updated on 07-Feb-2020 11:11:20

177 Views

A JDialog is a subclass of Dialog class and it does not hold minimize and maximize buttons at the top right corner of the window. We can create two types of JDialog boxes.in JavaModal DialogNon-Modal DialogModal JDialogIn Java, When a modal dialog window is active, all the user inputs are directed to it and ... Read More

How can we implement line wrap and word wrap text inside a JTextArea in Java?

raja

raja

Updated on 07-Feb-2020 11:06:02

1K+ Views

A JTextArea is a multi-line text component to display text or allow the user to enter the text and it will generate a CaretListener interface when we are trying to implement the functionality of the JTextArea component. A JTextArea class inherits the JTextComponent class in Java.In the below example, we can implement a JTextArea class with ... Read More

What is the importance of the GridBagConstraints class in Java?

raja

raja

Updated on 07-Feb-2020 10:57:12

3K+ Views

A GridBagLayout is a very flexible layout manager that allows us to position the components relative to one another using constraints. Each GridBagLayout uses a dynamic rectangular grid of cells with each component occupying one or more cells called its display area. Each component managed by a GridBagLayout is associated with a GridBagConstraints instance ... Read More

What is the importance of SwingUtilities class in Java?

raja

raja

Updated on 07-Feb-2020 07:31:53

2K+ Views

In Java, after swing components displayed on the screen, they can be operated by only one thread called Event Handling Thread. We can write our code in a separate block and can give this block reference to Event Handling thread. The SwingUtilities class has two important static methods, invokeAndWait() and invokeLater() to use ... Read More

What are the differences between JFrame and JDialog in Java?

raja

raja

Updated on 07-Feb-2020 06:54:28

2K+ Views

JFrameThe components added to the frame are referred to as its contents, these are managed by the contentPane. To add a component to a JFrame, we must use its contentPane instead.A JFrame contains a window with title, border, (optional) menu bar and user-specified components.A JFrame can be moved, resized, iconified and it is not a subclass ... Read More

Advertisements