Raja has Published 760 Articles

When can we use the pack() method in Java?

raja

raja

Updated on 03-Jul-2020 12:33:28

4K+ Views

The pack() method is defined in Window class in Java and it sizes the frame so that all its contents are at or above their preferred sizes. An alternative to the pack() method is to establish a frame size explicitly by calling the setSize() or setBounds() methods. In general, using the pack() method ... Read More

How can we apply different borders to JButton in Java?

raja

raja

Updated on 03-Jul-2020 12:29:27

4K+ Views

A JButton is a subclass of AbstractButton class and it can be used for adding platform-independent buttons in a Java Swing application. A JButon can generate an ActionListener interface when the user clicking on a button, it can also generate MouseListener when a user can do some actions from the mouse and KeyListener when a user ... Read More

How to set a different look and feels to swing components in Java?

raja

raja

Updated on 03-Jul-2020 12:21:53

2K+ Views

The Java Swing allows us to customize the GUI by changing the look and feel(L&F). The look defines the general appearance of components and the feel defines their behavior. L&Fs are subclasses of the LookAndFeel class and each L&F is identified by its fully qualified class name. By default, the L&F ... Read More

How can we add multiple sub-panels to the main panel in Java?

raja

raja

Updated on 03-Jul-2020 12:16:44

3K+ Views

A JPanel is a subclass of JComponent class and it is an invisible component in Java. The FlowLayout is a default layout for a JPanel. We can add most of the components like buttons, text fields, labels, tables, lists, trees,  etc. to a JPanel.We can also add multiple sub-panels to the main panel using the add() method ... Read More

How can we set the border to JComboBox items in Java?

raja

raja

Updated on 03-Jul-2020 11:58:06

505 Views

A JComboBox is a subclass of JComponent class and it is a combination of a text field and a drop-down list from which the user can choose a value. A JComboBox can generate an ActionListener, ChangeListener and ItemListener interfaces when the user actions on a combo box. We can set the border to the ... Read More

How can we rotate a JLabel text in Java?

raja

raja

Updated on 03-Jul-2020 11:56:43

2K+ Views

A JLabel is a subclass of 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 explicitly generate a PropertyChangeListener interface. By default, JLabel can display a text in the horizontal ... Read More

How many ways to iterate a LinkedList in Java?

raja

raja

Updated on 03-Jul-2020 11:54:51

263 Views

A LinkedList is a data structure that contains a group of nodes connected in a sequential manner with a pointer. A LinkedList can behave as a dynamic array and it allocates space for each element separately in its own block of memory called a Node. Each node contains two fields, a "data" ... Read More

What is the default value of a local variable in Java?

raja

raja

Updated on 03-Jul-2020 11:53:32

5K+ Views

The local variables can be declared in methods, code blocks, constructors, etc in Java. When the program control enters the methods, code blocks, constructors, etc. then the local variables are created and when the program control leaves the methods, code blocks, constructors, etc. then the local variables are destroyed. The ... Read More

How can we add padding to a JTextField in Java?

raja

raja

Updated on 03-Jul-2020 11:49:59

2K+ Views

A JTextField is a subclass of JTextComponent class and it is one of the most important components that allow the user to input text value in a single-line format. A JTextField class will generate an ActionListener interface when we trying to enter some input inside it. The important methods of a JTextField class ... Read More

How to set the color to alternate rows of JTable in Java?

raja

raja

Updated on 03-Jul-2020 11:48:46

2K+ Views

A JTable is a subclass of JComponent class and it can be used to create a table with information displayed in multiple rows and columns. When a value is selected from a JTable, a TableModelEvent is generated, which is handled by implementing a TableModelListener interface.We can set the color to alternate rows of JTable by overriding ... Read More

Advertisements