Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Predhodno Stavi ja Compjuter.java klasata
- JFrame frm;
- JPanel pn2;
- JLabel lb21;
- JPanel pn22;
- JList list;
- JTextField f1;
- JTextField f2;
- JTextField f3;
- JTextField f4;
- JTextField f5;
- JLabel l1;
- JLabel l2;
- JLabel l3;
- JLabel l4;
- JLabel l5;
- public JavaApplication32()
- {
- frm= new JFrame("Computer catalogue");
- frm.setLayout(new GridLayout(1,2,10,10));
- frm.setSize(700,800);
- frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- Computer[] pcs=Computer.getComputers();
- list=new JList(pcs);
- list.setBorder(new TitledBorder("Computer List: "));
- list.addListSelectionListener(new ListSelectionListener() {
- @Override
- public void valueChanged(ListSelectionEvent e) {
- Computer pc=(Computer) list.getSelectedValue();
- ImageIcon ic=new ImageIcon(pc.getSlika());
- Image im=ic.getImage();
- im=im.getScaledInstance(200,200,Image.SCALE_SMOOTH);
- ic=new ImageIcon(im);
- lb21.setIcon(ic);
- f1.setText(pc.getMarka());
- f2.setText(pc.getModel());
- f3.setText(pc.getCpu());
- f4.setText(pc.getRam());
- f5.setText(pc.getCena());
- }
- });
- pn2=new JPanel(new GridLayout(2,1));
- pn22=new JPanel(new GridLayout(10,1));
- l1=new JLabel("Brand: ");
- l2=new JLabel("Model: ");
- l3=new JLabel("CPU: ");
- l4=new JLabel("RAM: ");
- l5=new JLabel("Price: ");
- f1=new JTextField();
- f2=new JTextField();
- f3=new JTextField();
- f4=new JTextField();
- f5=new JTextField();
- pn22.add(l1);
- pn22.add(f1);
- pn22.add(l2);
- pn22.add(f2);
- pn22.add(l3);
- pn22.add(f3);
- pn22.add(l4);
- pn22.add(f4);
- pn22.add(l5);
- pn22.add(f5);
- lb21=new JLabel();
- pn2.add(lb21);
- pn2.add(pn22);
- frm.getContentPane().add(list);
- frm.getContentPane().add(pn2);
- frm.setVisible(true);
- }
- public static void main(String[] args) {
- // TODO code application logic here
- JavaApplication32 ramka=new JavaApplication32();
- }
Advertisement
Add Comment
Please, Sign In to add comment