Tutorialspoint
Drag to reposition
Contributed Answers (169)
Filter

How can we set the shortcut key to a JButton in Java?

Answered 7h 0m ago, 0 Views

A JButton is a subclass of AbstractButton and it can be used for adding platform-independent buttons to a Java Swing application. A JButon can generate an ActionListener interface when the button is pressed or clicked, it can also generate the MouseListener and KeyListener interfaces. We can also set the short cut keys for a JButton using the setMnemonic() meth.....

How to change each column width of a JTable in Java?

Answered 7h 50m ago, 0 Views

A JTable is a subclass of JComponent for displaying complex data structures.A JTable can follow the Model View Controller (MVC) design pattern for displaying the data in rows and columns.The DefaultTableModel class can extend AbstractTableModel and it can be used to add the rows and columns to a JTable dynamically.The DefaultTableCellRenderer cla.....

How to display a bold text inside the JTextArea in Java?

Answered 13h 7m ago, 0 Views

A JTextArea class can extend JTextComponent and allow a user to enter multiple lines of text inside it. A JTextArea can generate a CaretListener interface, which can listen to caret update events. We can set a font to a text inside the JTextArea by using setFont() method. ,

What is the importance of JSeparator class in Java?

Answered 14h 57m ago, 0 Views

A JSeparator is a horizontal or vertical line or an empty space that separates the components.A JSeparator class is used to draw a line to separate the components in a Layout.The easiest way to add a separator to a menu or toolbar is to call the addSeparator() method provided by the classes JMenu, JPopupMenu and JToolBar.The important methods of JSepa.....

What is the importance of JViewport class in Java?

Answered 15h 47m ago, 0 Views

A JViewport class defines the basic scrolling model and it is designed to support both logical scrolling and pixel-based scrolling.The viewport's child called the view is scrolled by calling JViewport.setViewPosition() method.A JViewport class supports logical scrolling, that is a kind of scrolling in which view coordinates are not pixels.To support a logical scroll.....

What are the differences between paint() method and repaint() method in Java?

Answered 18h 5m ago, 0 Views

paint(): This method holds instructions to paint this component. In Java Swing, we can change the paintComponent() method instead of paint() method as paint calls paintBorder(), paintComponent() and paintChildren() methods. We cannot call this method directly instead we can call repaint().repaint(): This method cannot be overridden. It controls the update() -> paint() cycle. We.....

How can we catch a double click and enter key events for a JList in Java?

Answered 1d 7h ago, 0 Views

A JList can extend JComponent class that allows the user to choose either a single or multiple selections. A JList can generate a ListSelectiionListener interface and it includes one abstract method valueChanged(). A JList can also generate a MouseListener interface to catch a double click event in the list and generates a KeyListener interface to catch an.....

What are the differences between a Font and a FontMetrics in Java?

Answered 1d 11h ago, 0 Views

A Font class is used to set the screen fonts and it maps the characters of the language to their respective glyphs whereas a FontMetrics class defines a font metrics object, which encapsulates information about the rendering of a particular font on a particular screen. A Font class can be used to create an instance of a Font object to set the font for drawing text, label.....

How can we set the background color to a JPanel in Java?

Answered 1d 15h ago, 0 Views

A JPanel is a container 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, table, list, tree and etc. to a JPanel. We can set a background color to JPanel by using the setBackground() method. ,

How many types of selection modes for a JList in Java?

Answered 1d 18h ago, 0 Views

A JList is a component that can extend JComponent class used to display a list of objects that allows the user to select one or more items. There are three types of selection modes for a JList in Java ListSelectionModel.SINGLE_SELECTION: Only one list index can be selected at a time.ListSelectionModel.SINGLE_INTERVAL_SELECTION: Only one contiguous interval can be selected at a time.Lis.....

1 2 3 4 5 6 7 ... 17 Next
loader
Advertisements
Contribution

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.