
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 7442 Articles for Java

5K+ Views
In this article, we will learn to draw a rounded rectangle using the Graphics object in Java. Drawing shapes is a basic feature of Java 2D graphics programming. Though the Graphics class offers methods for drawing common rectangles, drawing rounded rectangles involves some special techniques. Graphics Class In Java, the drawing takes place via a Graphics object, which 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, etc. We can get access to the Graphics object through the paint(Graphics ... Read More

456 Views
In this article, we will learn to implement an editable JLabel in Java. An editable JLabel is a label component that can be converted to an editable text field when clicked. JLabel A JLabel class can extend the 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. Syntax The following is the syntax for JLabel initialization: JLabel label = new JLabel("Tutorials Point"); A JLabel can explicitly generate a PropertyChangeListener interface. Methods The important methods of a ... Read More

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 the drop-down list.By default, the user not allowed to edit the data in the text field portion of the JComboBox. If we want to allow the user to edit the text field, call setEditable(true) method.A JComboBox can generate an ActionListener, ChangeListener or ItemListener when the user actions on a combo box.A ... Read More

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 as FlowLayout, GridLayout, BorderLayout and other layout managers helps us to control the sizes, positions, and alignment of the components using JPanel.The important methods of a JPanel class are getAccessibleContext(), getUI(), updateUI() and paramString().We can also implement a JPanel with vertical and horizontal scrolls by adding the panel object to JScrollPane.Exampleimport java.awt.*; ... Read More

1K+ Views
In this article, we will learn to select one item at a time from a JCheckBox in Java. When creating Java Swing applications, you might have situations where you need checkboxes to behave like radio buttons, such that a box can be checked singly at any given time. JCheckBox A 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. Syntax The following is the syntax for JCheckBox initialization: JCheckBox checkBox = new JCheckBox("Option"); A JCheckBox can ... Read More

6K+ Views
You can convert a character to upper case using the toUpperCase() method of the character class.ExampleFollowing program converts alternate characters of a string to Upper Case. Live Demoimport java.util.Scanner; public class UpperCase { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter a string :"); String str = sc.nextLine(); str = str.toLowerCase(); char[] ch = str.toCharArray(); for(int i=0; i

1K+ Views
Following is the Java program to print diagonal pattern of a given matrix.Example Live Demopublic class DiagonalMatrix { public static void main(String args[]){ int a[][]={{1,2,3},{4,5,6},{7,8,9}}; int rows = a.length; int columns = a[0].length; for (int i = 0; i < rows; i++) { for (int r = i, c = 0; r >= 0 && c < columns; r--, c++){ System.out.print(a[r][c] + " "); } System.out.println(); } for (int i = 1; i < columns; i++) { for (int r = rows-1, c = i; r >= 0 && c < columns; r--, c++) { System.out.print(a[r][c] + " "); } System.out.println(); } } }Output1 4 2 7 5 3 8 6 9

3K+ Views
Following is a Java program to print the spiral form of a given matrix.Example Live Demopublic class PrintMatrixInSpiralForm { public static void main(String args[]){ int a[][]={{1,2,3},{4,5,6},{7,8,9}}; int w = 0; int x = a.length-1; int y = 0; int z = a[0].length-1; while(w

817 Views
To arrange elements of the array following pendulum arrangement.Sort the given array, create an empty array to store the result.Store the 0th element in a variable say temp.Store the element at index 1 in the sorted array in (mid+1)st position of the resultant array, and the next element int the (mid-1)st position and the next element in (mid+2)nd element and so on.Example Live Demoimport java.util.Arrays; import java.util.Scanner; public class ArrayinPendulumArrangement { public static int[] swap(int origPos, int newPos, int[] array){ origPos = 1; newPos = 4; int temp = array[origPos]; ... Read More

345 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 JTabbedPane are add(), addTab(), fireStateChanged(), createChangeListener(), setSelectedIndex(), getTabCount() and etc.Exampleimport java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class JTabbedPaneTest extends JFrame implements ActionListener { JTabbedPane tabbedPane; int ntabs = 0; public JTabbedPaneTest() { getContentPane().setLayout(new BorderLayout()); tabbedPane = new JTabbedPane(); ... Read More