
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

679 Views
Use the createLineBorder() method to ad line border to JLabel −Border border = BorderFactory.createLineBorder(Color.ORANGE); label.setBorder(border);Above, we have set the line border to color orange.The following is an example to add line border to JLabel −Examplepackage my; import java.awt.Color; import java.awt.Font; import javax.swing.*; import javax.swing.border.Border; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Demo"); JLabel label; label = new JLabel("Demo Label!", JLabel.RIGHT); label.setFont(new Font("Verdana", Font.PLAIN, 13)); Border border = BorderFactory.createLineBorder(Color.ORANGE); label.setBorder(border); frame.add(label); ... Read More

8K+ Views
JLabel Left AlignedThe following is an example to set left alignment for JLabel −Exampleimport java.awt.Font; import javax.swing.*; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Label Demo"); JLabel label; label = new JLabel("Left aligned!", JLabel.LEFT); label.setFont(new Font("Verdana", Font.PLAIN, 13)); frame.add(label); frame.setSize(500, 300); frame.setVisible(true); } }OutputJLabel Center AlignedThe following is an example to set center alignment for JLabel −Exampleimport java.awt.Font; import javax.swing.*; public class SwingDemo { public static void main(String args[]) ... Read More

1K+ Views
To hold multiline of text, set HTML under JLabel −JLabel = new JLabel("" + "Line1Line2",JLabel.LEFT);The above will create multiline text in the JLabel −Line1 Line2The following is an example to create JLabel to hold multiline of text −Exampleimport java.awt.Font; import javax.swing.*; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Label Example"); JLabel label; label = new JLabel("" + "Line1 Line2",JLabel.LEFT); label.setBounds(100, 100, 100, 30); label.setFont(new Font("Verdana", Font.PLAIN, 13)); frame.add(label); frame.setSize(500,300); frame.setLayout(null); frame.setVisible(true); } }Output

995 Views
To change text font, you can use the setFont() method of JLabel −label.setFont(new Font("Verdana", Font.PLAIN, 12));The following is an example to change text font for JLabel with HTML −Exampleimport java.awt.Font; import javax.swing.*; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Label Example"); JLabel label; label = new JLabel("" + "ABC"); label.setBounds(50, 50, 100, 30); label.setFont(new Font("Verdana", Font.PLAIN, 12)); frame.add(label); frame.setSize(500,300); frame.setLayout(null); frame.setVisible(true); } }Output

3K+ Views
In this article, we will learn to change JLabel text after creation in Java. We'll cover two scenarios: changing the label text immediately after creation and updating it in response to a button click. Different approaches to change JLabel text after creation Below are the different approaches to change JLabel text after the creation − Using setText() Method Using a button click Update JLabel text using setText() method Following are the steps to update JLabel text immediately after creation − First we will import JFrame, JLabel, and ... Read More

14K+ Views
To change JLabel font, use the setFont() method −JLabel lable = label.setFont(new Font("Verdana", Font.PLAIN, 18));Examplepackage my; import java.awt.Font; import javax.swing.*; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Label Example"); JLabel label; label = new JLabel("First Label"); label.setBounds(50, 50, 100, 30); label.setFont(new Font("Verdana", Font.PLAIN, 18)); frame.add(label); frame.setSize(300,300); frame.setLayout(null); frame.setVisible(true); } }Output

2K+ Views
The following is an example to draw a line on a JFrame −Examplepackage my; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Line2D; import javax.swing.JFrame; import javax.swing.JPanel; public class SwingDemo extends JFrame { public SwingDemo() { JPanel panel = new JPanel(); getContentPane().add(panel); setSize(550, 300); } public void paint(Graphics gp) { super.paint(gp); Graphics2D graphics = (Graphics2D) gp; Line2D line = new Line2D.Float(200, 150, 150, 220); graphics.draw(line); } public static void main(String[] args) { SwingDemo demo = new SwingDemo(); demo.setVisible(true); } }Output

512 Views
Python's interactive mode works on the principle of REPL (Read - Evaluate - Print - Loop). The code module in Python's standard library provides classes nd convenience functions to set up REPL environment from within Python script.Following two classes are defined in code module:InteractiveInterpreter: This class deals with parsing and interpreter state (the user’s namespace)InteractiveConsole: Closely emulate the behavior of the interactive Python interpreter.Two convenience functions in the module are:interact(): Convenience function to run a read-eval-print loop.compile_command(): This function is useful for programs that want to emulate Python’s interpreter main loop (the REPL).Interactive Interpreter methodsrunsource(): Compile and run some source ... Read More

743 Views
When you want to add to the module search path for a specific package and work with resources included in a package, you need to use pkgutil module from Python library. It includes functions for changing the import rules for Python packages. It is also possible to load non-code resources from files distributed within a package.extend_path(path, name)Extend the search path for the modules which comprise a package. Intended use is to place the following code in a package’s __init__.pyimport pkgutil __path__ = pkgutil.extend_path(__path__, __name__)extend_path() scans sys.path for directories that include a subdirectory named for the package given as the second ... Read More

684 Views
The poolib module from Python's standard library defines POP3 and POP3_SSL classes. POP3 class encapsulates a connection to a POP3 server and implements the protocol as defined in RFC 1939. POP3_SSL classsupports POP3 servers that use SSL as an underlying protocol layer.POP3 protocolis obsolescent as its implementation quality of POP3 servers is quite poor. If your mailserver supports IMAP, it is recommended to use the imaplib.IMAP4 class.Both classes have following methods defined −getwelcome()Returns the greeting string sent by the POP3 server.user(username)Send user command, response should indicate that a password is required.pass_(password)Send password.Stat()Get mailbox status. The result contains 2 integers: (message ... Read More