Results 1 to 5 of 5
Thread: Eclipse
Hybrid View
-
17th May 2009 15:17 #1
Eclipse
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
public class Invoice extends JFrame implements ActionListener {
private Invoice invoice;
private JLabel cenaL,imeL,kolichestvoL,obshtoL,koshnica L;
private JPanel panel1,panel2;
private JTextField imeT,kolichestvoT,obshtoT;
private JTextArea koshnicaA;
private JButton izchisli,dobavi;
private JTextField cenaT;
public Invoice(){
super("FAKTURA");
invoice=new Invoice();
setDefaultCloseOperation(JFrame.EXIT_ON_ CLOSE);
Container container=getContentPane();
panel1=new JPanel();
GridLayout layoutPanel1 = new GridLayout(4, 2);
panel1.setLayout(layoutPanel1);
cenaL=new JLabel("Cena");
imeL=new JLabel("Ime");
kolichestvoL=new JLabel("Kolichestvo");
obshtoL=new JLabel("Obshto");
koshnicaL=new JLabel("Koshnica");
cenaT=new JTextField(10);
imeT=new JTextField(10);
kolichestvoT=new JTextField(10);
obshtoT=new JTextField(10);
koshnicaA=new JTextArea(10,2);
panel1.add(imeL);
panel1.add(imeT);
panel1.add(cenaL);
panel1.add(cenaL);
panel1.add(kolichestvoL);
panel1.add(kolichestvoT);
panel1.add(obshtoL);
panel1.add(obshtoT);
panel1.add(koshnicaL);
panel1.add(koshnicaA);
container.add(panel1, BorderLayout.PAGE_START);
container.add(koshnicaA, BorderLayout.CENTER);
panel2=new JPanel();
izchisli=new JButton("Izchisli");
dobavi=new JButton("Dobavi");
panel2.add(izchisli);
panel2.add(dobavi);
container.add(panel2, BorderLayout.PAGE_END);
izchisli.addActionListener(this);
dobavi.addActionListener(this);
imeT.addActionListener(this);
kolichestvoT.addActionListener(this);
setSize(300,300);
setVisible(true);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==dobavi){
try{
invoice.addProdukt(Integer.parseInt(imeT .getText(),cenaT.getText()));
koshnicaA.append("Produkta e dobaven");
}catch(Exception ex) {
koshnicaA.append("Greshka pri vyvejdane");
.....
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable(){
public void run(){
new Invoice();
}
});
}
}
, , , "" , .
!
-
18th May 2009 18:39 #2
Join Date: Sep:2005
Location: Sofia
Posts: 18,517
. . -
EventQueue- . .Code:
float, actionPerformed(...) , , . " ". ?Last edited by vvvlado; 18th May 2009 at 18:46.
-
18th May 2009 20:05 #3
-
19th May 2009 14:34 #4
Join Date: Sep:2005
Location: Sofia
Posts: 18,517
Listener- . , , .
, .
http://java.sun.com/javase/6/docs/ap...yListener.htmlLast edited by vvvlado; 19th May 2009 at 14:45.
-
19th May 2009 23:36 #5




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in