5. BUTTONS :
Roll over icon :
ImageIcon icon = new
ImageIcon("sigin.png");
JButton jbt = new JButton(icon);
Jbt.setRolloverIcon(icon);
6. BUTTONS:
Roll Pressedicon :
ImageIcon icon = new
ImageIcon("sigin.png");
JButton jbt = new JButton(icon);
jbt.setPressedIcon(icon);
7. TEXT AREA
If you want to let the user enter multiple
lines of text, you have to create several
instances of JTextField. A better alternative
is to use JTextArea, which enables the user
to enter multiple lines of text.
JTextArea jtaNote = new JTextArea(5, 20);
8. TEXT FIELDS KEY LISTNERS :
// Create a text field with text "Type Name Here"
JTextField jtfName = new JTextField("Type Name Here");
jtfName .addKeyListener(this);
9. Array of Text Fields
You can create Array of Text fields by:
JTextField[][] txt = new JTextField[x][y];
for (int i = 0; i < x; i++) {
for (int j = 0; j < y; j++) {
txt[i][j] = new JTextField(10);
panel.add(txt[i][j]);
txt[i][j].setHorizontalAlignment(JTextField.CENTER);
if (i == j) {
txt[i][j].setText("1");
txt[i][j].setEditable(false);
} txt[i][j].addKeyListener(this);
}}
10. Combo box
To Create Combo box :
JComboBox operations_txt= new JComboBox(new String[]{"<=", "=", ">="});
Operation_txt. getSelectedItem();
11. Check box :
// Create a check box with text bold
JCheckBox jchkBold = new JCheckBox("Bold");
jchkBold.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (jchkBold.isSelected()) {
// your Action
}
}
});