You are on page 1of 6

Document

Action Caret Change Listener, Item


List
Window
Componen
Other Types of
Listene Listen Listene Undoable Listen Selection Listene
t
Listeners
r
er
r
Edit
er
Listener r
Listener
button
check box
color
chooser
combo box
dialog
editor pane

hyperlink

file chooser
formatted
text field
frame
internal
frame
list
menu
menu item

internal frame
list data
menu
menu key
menu drag mouse

option
pane
password
field
popup
menu

popup menu

progress
bar
radio
button
slider
spinner
tabbed
pane
table

table model
table column
model
cell editor

text area

text field

text pane

hyperlink

toggle
button
tree expansion
tree will expand
tree model
tree selection

tree
viewport
(used by
scrollpane)

7 BUTONAT
import
import
import
import
import

java.awt.*;
java.awt.event.*;
javax.swing.*;
javax.swing.event.*;
javax.swing.border.TitledBorder;

public class SevenButtons extends JFrame implements ActionListener{


JButton btn1=new JButton("Butoni1");
JButton btn2=new JButton("Butoni2");
JButton btn3=new JButton("Butoni3");
JPanel panel1=new JPanel();
JButton btn4=new JButton("Butoni4");
JButton btn5=new JButton("Butoni5");
JButton btn6=new JButton("Butoni6");
JButton btn7=new JButton("Butoni7");
JPanel panel2=new JPanel();
JLabel lbl1=new JLabel("Butoni qe u shtyp");
JTextField txfiel1= new JTextField(7);
JPanel panel3=new JPanel();
SevenButtons(String title){
super(title);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel1.setLayout(new FlowLayout());
panel1.add(btn1);
panel1.add(btn2);
panel1.add(btn3);
panel1.setBorder(new TitledBorder("Butonat"));
panel2.setLayout(new GridLayout(2,2));

panel2.add(btn4);
panel2.add(btn5);
panel2.add(btn6);
panel2.add(btn7);
panel3.setLayout(new FlowLayout());
panel3.add(lbl1);
panel3.add(txfiel1);
txfiel1.setEditable(false);
setLayout(new BorderLayout());
add(panel1,BorderLayout.NORTH);
add(panel2,BorderLayout.CENTER);
add(panel3,BorderLayout.SOUTH);
btn1.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent
txfiel1.setText("Butoni 1");
}
}
);
btn2.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent
txfiel1.setText("Butoni 2");
}
}
);
btn3.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent
txfiel1.setText("Butoni 3");
}
}
);
btn4.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent
txfiel1.setText("Butoni 4");
}
}
);
btn5.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent
txfiel1.setText("Butoni 5");
}
}
);
btn6.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent
txfiel1.setText("Butoni 6");
}
}
);

evt){

evt){

evt){

evt){

evt){

evt){

btn7.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent evt){
txfiel1.setText("Butoni 7");
}
}
);
}
public static void main(String arg[]){
SevenButtons svbut=new SevenButtons("Shembull Provimi");
svbut.pack();
svbut.setVisible(true);
svbut.setResizable(false);
svbut.setLocationRelativeTo(null);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}

FONTET
import
import
import
import
import
import
import
import
import
import
import

java.awt.BorderLayout;
java.awt.FlowLayout;
java.awt.Font;
java.awt.TextField;
java.awt.event.ActionEvent;
java.awt.event.ActionListener;
java.awt.event.ItemEvent;
java.awt.event.ItemListener;
javax.swing.JFrame;
javax.swing.JRadioButton;
javax.swing.JTextField;

class StilShkrimi1 extends JFrame implements ActionListener {

/**
*
*/
private static final long serialVersionUID = 1L;
public StilShkrimi1(){
super("RadioButton Test");
setLayout(new FlowLayout());
final TextField kutiaText = new TextField("Watch the font style change");
add(kutiaText,BorderLayout.NORTH);
JRadioButton
JRadioButton
JRadioButton
JRadioButton

jrbBold = new JRadioButton("Bold");


jrbPlain = new JRadioButton("Plain");
jrbItalic = new JRadioButton("Italic");
jrbBoldItalic = new JRadioButton("Bold/Italic");

ButtonGroup butgro=new ButtonGroup();


butgro.add(jrbBold);
butgro.add(jrbPlain);
butgro.add(jrbItalic);
butgro.add(jrbBoldItalic);
final
final
final
final
14);

Font
Font
Font
Font

fontPlain = new Font("Plain", Font.PLAIN , 14);


fontBold = new Font("Bold", Font.BOLD , 14);
fontItalic = new Font("Italic", Font.ITALIC , 14);
fontBoldItalic = new Font("Bold/Italic", Font.BOLD + Font.ITALIC ,
//shtoj butonat ne frame
add(jrbPlain);
add(jrbBold);
add(jrbItalic);
add(jrbBoldItalic);
jrbBold.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent evt){
kutiaText.setFont(fontBold);
}
}
);
jrbPlain.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent evt){
kutiaText.setFont(fontPlain);
}
}
);
jrbItalic.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent evt){
kutiaText.setFont(fontItalic);
}
}
);
jrbBoldItalic.addActionListener(
new ActionListener(){

}
}

public void actionPerformed(ActionEvent evt){


kutiaText.setFont(fontBoldItalic);
}

);

public static void main(String[] args) {


// Krijoj nje frame
StilShkrimi1 frame = new StilShkrimi1();
frame.setTitle("RadioButton Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.setResizable(false);
frame.setSize(280,100);
frame.setLocationRelativeTo(null);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
}

You might also like