Raja has Published 760 Articles

How can we implement an editable JLabel in Java?

raja

raja

Updated on 10-Feb-2020 06:32:53

298 Views

JLabelA JLabel class can extend JComponent class and an object of JLabel provides text instructions or information on a GUI.A JLabel can display a single line of read-only text, an image or both text and image.The important methods of a JLabel are setText(), setIcon(), setBackground(), setOpaque(), setHorizontalAlignment(), setVerticalAlignment() and etc.A ... Read More

How can we draw a rounded rectangle using the Graphics object in Java?

raja

raja

Updated on 10-Feb-2020 06:31:44

4K+ Views

Graphics ClassIn Java, the drawing takes place via a Graphics object, this is an instance of the java.awt.Graphics class.Each Graphics object has its own coordinate system and all the methods of Graphics including those for drawing Strings, lines, rectangles, circles, polygons and etc.We can get access to the Graphics object through the paint(Graphics g) ... Read More

How can we implement a JLabel text with different color and font in Java?

raja

raja

Updated on 10-Feb-2020 06:28:29

2K+ Views

JLabelA JLabel class can extend JComponent class and an object of JLabel provides text instructions or information on a GUI.A JLabel can display a single line of read-only text, an image or both text and an image.A JLabel can also display a single line of text with different colors and fonts using Some Text ... Read More

What are the differences between a JTextField and a JFormattedTextField in Java?

raja

raja

Updated on 10-Feb-2020 06:27:23

1K+ Views

A JTextField can be used for plain text whereas a JFormattedTextField is a class that can extend JTextField and it can be used to set any format to the text that it contains phone numbers, e-mails, dates and etc.JTextFieldA JTextFeld is one of the most important components that allow the user to type an input ... Read More

How can we implement cut, copy and paste functionality of JTextField in Java?

raja

raja

Updated on 10-Feb-2020 06:20:50

2K+ Views

A JTextField is a subclass of JTextComponent class that allows the editing of a single line of text. We can implement the functionality of cut, copy and paste in a JTextField component by using cut(), copy() and paste() methods. These are pre-defined methods in a JTextFeild class.Syntaxpublic void cut() public void copy() public ... Read More

How can we set a border to JCheckBox in Java?

raja

raja

Updated on 10-Feb-2020 06:19:45

397 Views

A JCheckBox is a component that can extend JToggleButton and an object of JCheckBox represents an option that can be checked or unchecked. If there are two or more options then any combination of these options can be selected at the same time. We can set a border to the JCheckBox component by using ... 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

What is the importance of the Container class in Java?

raja

raja

Updated on 07-Feb-2020 12:50:43

8K+ Views

ContainerA Container class can be described as a special component that can hold the gathering of the components.There are two types of Swing Containers, they are top-level containers and low-level containers.Top-Level containers are heavyweight containers such as JFrame, JApplet, JWindow, and JDialog.Low-Level containers are lightweight containers such as JPanel.The most commonly used containers ... Read More

What are the differences between an event listener interface and an event adapter class in Java?

raja

raja

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

4K+ Views

An EventListener interface defines the methods that must be implemented by an event handler for a particular kind of an event whereas an Event Adapter class provides a default implementation of an EventListener interface.Event ListenerThe Event Listeners are the backbone of every component to handle the events.Every method of a particular EventListener will have a single parameter ... Read More

What are the differences between a JTextPane and a JEditorPane in Java?

raja

raja

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

1K+ Views

A JTextPane is an extension of JEditorPane which provides word processing features like fonts, text styles, colors and etc. If we need to do heavy-duty text processing we can use this class whereas a JEditorPane supports display/editing of HTML and RTF content and can be extended by creating our own EditorKit.JTextPaneA JTextPane is a subclass of JEditorPane.A ... Read More

Advertisements