Advertisement
nex036ara

panel_akcije

Nov 6th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.70 KB | None | 0 0
  1. package gui;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Dimension;
  5. import java.awt.FlowLayout;
  6. import java.awt.Toolkit;
  7. import java.awt.event.MouseEvent;
  8. import java.awt.event.MouseListener;
  9.  
  10. import javax.swing.JButton;
  11. import javax.swing.JFrame;
  12. import javax.swing.JPanel;
  13. import javax.swing.JTextArea;
  14.  
  15. public class FrameInterface extends JFrame {
  16.      
  17.    
  18.     static JTextArea textArea = new JTextArea("",1,7);
  19.    
  20.    
  21.     public FrameInterface() {
  22.         Toolkit kit = Toolkit.getDefaultToolkit();
  23.             Dimension screenSize = kit.getScreenSize();
  24.             int screenHeight = screenSize.height;
  25.             int screenWidth = screenSize.width;
  26.  
  27.             setSize(screenWidth / 2, screenHeight / 2);
  28.             setTitle("Interface");
  29.             setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  30.             setLocationRelativeTo(null);
  31.  
  32.            
  33.            
  34.             JPanel pan=new JPanel(new FlowLayout(FlowLayout.LEFT,20,20));
  35.            
  36.             MouseListener m;
  37.             m=new MyMouseListener11();
  38.            
  39.             JButton btn1=new JButton("Izracunaj sumu");
  40.             btn1.addMouseListener(m);
  41.            
  42.                
  43.             pan.add(btn1);
  44.             pan.add(textArea);
  45.             add(pan,BorderLayout.CENTER);
  46.        
  47.  
  48.       }
  49.  
  50.    
  51.    
  52.    
  53.    
  54. static class MyMouseListener11 implements MouseListener{
  55.  
  56.        
  57.         public static String s;
  58.        
  59.         public void mouseClicked(MouseEvent arg0) {
  60.             int a,b,c; a=5; b=5;
  61.             c=a+b;
  62.             s = String.valueOf(c);
  63.             textArea.setText("result: "+s);
  64.        
  65.         }
  66.  
  67.         public void mouseEntered(MouseEvent arg0) {}
  68.  
  69.         public void mouseExited(MouseEvent arg0) {}
  70.  
  71.         public void mousePressed(MouseEvent arg0) {}
  72.  
  73.         public void mouseReleased(MouseEvent arg0) {}
  74.     }
  75.    
  76.    
  77.  
  78.        
  79.        
  80.    
  81.    
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement