Swing 2nd Class
Swing 2nd Class
Swing 2nd Class
Java JComboBox:
The object of Choice class is used to show popup menu of choices. Choice selected by user is shown on the top of a menu. It inherits JComponent
class.
declaration class:
public class JComboBox extends JComponent implements ItemSelectable, ListDataListener, ActionListener, Accessible
Syntax:
JComboBox cb=new JComboBox(country);
Constructors=>
Constructor Descriptions
JComboBox() Creates a JComboBox with a default data model.
JComboBox(Object[] items) Creates a JComboBox that contains the elements in the
specified array.
JComboBox(Vector<?> items) Creates a JComboBox that contains the elements in the
specified Vector.
Syntax:
JTable jt=new JTable(data,column);
Constructors:
Constructor Description
JTable() Creates a table with empty cells.
JTable(Object[][] rows, Object[] columns) Creates a table with the specified data.
JList<String> list = new JList<>(ListObject);
Constructor:
Constructor Description
Jlist() Creates a JList with an empty, read-only, model.
JList(ary[] listData) Creates a JList that displays the elements in the specified array.
JList(ListModel<ary> dataModel) Creates a JList that displays elements from the specified, non-null,
model.
package demoSwing;
import javax.swing.*;
public class JOption {
JFrame f;
JOption(){
f=new JFrame();
JOptionPane.showMessageDialog(f,"Successfully Updated.","Alert",JOptionPane.WARNING_MESSAGE);
}
public static void main(String[] args) {
new JOption();
}
}
JScrollBar s=new JScrollBar();
Constructors:
Constructor Description
JScrollBar() Creates a vertical scrollbar with the initial values.
JScrollBar(int orientation) Creates a scrollbar with the specified orientation and the initial
values.
ScrollBar(int orientation, int value, int extent, Creates a scrollbar with the specified orientation, value, extent,
int min, int max) minimum, and maximum.