Raja has Published 760 Articles

How can we implement right click menu using JPopupMenu in Java?

raja

raja

Updated on 07-Feb-2020 11:44:00

1K+ Views

A JPopupMenu appears anywhere on the screen when a right mouse button is clicked.JPopupMenuA popup menu is a free-floating menu which associates with an underlying component called the invoker.Most of the time, a popup menu is linked to a specific component to display context-sensitive choices.In order to create a popup ... 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

257 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 to select one item at a time from JCheckBox in Java?

raja

raja

Updated on 07-Feb-2020 11:41:15

1K+ Views

JCheckBoxA JCheckBox can extend JToggleButton and it can be a small box that is either checked or unchecked.When we click on a JCheckBox, it changes from checked to unchecked or vice versa automatically.A JCheckBox can generate an ActionListener or an ItemListener whenever the checkbox is changed.An isSelected() method is used to ... Read More

How can we limit the number of characters inside a JTextField in Java?

raja

raja

Updated on 07-Feb-2020 11:17:14

4K+ Views

A JTextFeld is one of the most important components that allow the user to an input text value in a single line format. We can restrict the number of characters that the user can enter into a JTextField can be achieved by using a PlainDocument class.In the below example, we can implement the logic ... Read More

How can we implement a JToggleButton in Java?

raja

raja

Updated on 07-Feb-2020 11:13:52

732 Views

JToggleButtonA JToggleButton is an extension of AbstractButton and it can be used to represent buttons that can be toggled ON and OFF.When JToggleButton is pressed for the first time, it remains pressed and it can be released only when it is pressed for the second time.A JToggleButton generates an ActionEvent each time it is pressed.A JToggleButton can ... Read More

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

raja

raja

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

115 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

What are the differences between a JScrollBar and a JScrollPane in Java?

raja

raja

Updated on 07-Feb-2020 11:09:46

2K+ Views

A JScrollBar is a component and it doesn't handle its own events whereas a JScrollPane is a Container and it handles its own events and performs its own scrolling. A JScrollBar cannot have a JScrollPane whereas a JScrollPane can have a JScrollBar.JScrollBarThe object of the JScrollBar class is used to add horizontal and vertical scrollbar which allow the user to select ... 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

715 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

How can we implement different borders using the BorderFactory in Java?

raja

raja

Updated on 07-Feb-2020 11:04:23

2K+ Views

The BorderFactory is a Factory class which provides different types of borders in Java.Types of BordersBevelBorder: This border draws raised or lowered beveled edges.EmptyBorder:  It doesn’t do any drawing, but does take up space.EtchedBorder: A Lowered etched border gives an appearance of a rectangle and a Raised etched border looks like a surface of the screen.LineBorder: ... Read More

How can we implement the paintComponent() method of a JPanel in Java?

raja

raja

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

6K+ Views

A JPanel is a lightweight container and it is an invisible component in Java. A JPanel's default layout is FlowLayout. After the JPanel has been created, other components can be added to the JPanel object by calling its add() method inherited from the Container class.paintComponent()This method is needed to draw something on JPanel other than drawing the ... Read More

Advertisements