Mitko_jos

lab03_IA

Nov 13th, 2013
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.50 KB | None | 0 0
  1.  
  2. //Predhodno Stavi ja Compjuter.java klasata
  3.  
  4. JFrame frm;
  5.     JPanel pn2;
  6.     JLabel lb21;
  7.     JPanel pn22;
  8.     JList list;
  9.     JTextField f1;
  10.     JTextField f2;
  11.     JTextField f3;
  12.     JTextField f4;
  13.     JTextField f5;
  14.     JLabel l1;
  15.     JLabel l2;
  16.     JLabel l3;
  17.     JLabel l4;
  18.     JLabel l5;
  19.    
  20.    
  21.    
  22.    
  23.     public JavaApplication32()
  24.     {
  25.         frm= new JFrame("Computer catalogue");
  26.        frm.setLayout(new GridLayout(1,2,10,10));
  27.        frm.setSize(700,800);
  28.        frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  29.        
  30.        
  31.       Computer[] pcs=Computer.getComputers();
  32.       list=new JList(pcs);
  33.       list.setBorder(new TitledBorder("Computer List: "));
  34.       list.addListSelectionListener(new ListSelectionListener() {
  35.  
  36.             @Override
  37.             public void valueChanged(ListSelectionEvent e) {
  38.                 Computer pc=(Computer) list.getSelectedValue();
  39.         ImageIcon ic=new ImageIcon(pc.getSlika());
  40.         Image im=ic.getImage();
  41.         im=im.getScaledInstance(200,200,Image.SCALE_SMOOTH);
  42.        
  43.         ic=new ImageIcon(im);
  44.         lb21.setIcon(ic);
  45.         f1.setText(pc.getMarka());
  46.         f2.setText(pc.getModel());
  47.         f3.setText(pc.getCpu());
  48.         f4.setText(pc.getRam());
  49.         f5.setText(pc.getCena());
  50.             }
  51.  
  52.            
  53.         });
  54.      
  55.       pn2=new JPanel(new GridLayout(2,1));
  56.      
  57.       pn22=new JPanel(new GridLayout(10,1));
  58.       l1=new JLabel("Brand: ");
  59.       l2=new JLabel("Model: ");
  60.       l3=new JLabel("CPU: ");
  61.       l4=new JLabel("RAM: ");
  62.       l5=new JLabel("Price: ");
  63.       f1=new JTextField();
  64.       f2=new JTextField();
  65.       f3=new JTextField();
  66.       f4=new JTextField();
  67.       f5=new JTextField();
  68.       pn22.add(l1);
  69.       pn22.add(f1);
  70.       pn22.add(l2);
  71.       pn22.add(f2);
  72.       pn22.add(l3);
  73.       pn22.add(f3);
  74.       pn22.add(l4);
  75.       pn22.add(f4);
  76.       pn22.add(l5);
  77.       pn22.add(f5);
  78.      
  79.       lb21=new JLabel();
  80.      
  81.      
  82.      
  83.      
  84.  
  85.        
  86.        
  87.        pn2.add(lb21);
  88.        pn2.add(pn22);
  89.        frm.getContentPane().add(list);
  90.        frm.getContentPane().add(pn2);
  91.        
  92.        frm.setVisible(true);
  93.        
  94.        
  95.        
  96.        
  97.        
  98.     }
  99.    
  100.    
  101.    
  102.    
  103.    
  104.    
  105.    
  106.    
  107.    
  108.    
  109.    
  110.    
  111.    
  112.    
  113.     public static void main(String[] args) {
  114.         // TODO code application logic here
  115.        
  116.         JavaApplication32 ramka=new JavaApplication32();
  117.        
  118.        
  119.      
  120.     }
Advertisement
Add Comment
Please, Sign In to add comment