Differences

This shows you the differences between two versions of the page.

Link to this comparison view

poo:breviare:breviar-10 [2018/11/27 17:31]
matei.teodorescu
poo:breviare:breviar-10 [2020/12/10 13:47] (current)
carmen.odubasteanu
Line 1: Line 1:
 ====== Breviar ====== ====== Breviar ======
-===== Laborator 10 - Interfete =====+===== Laborator 10 - Interfete ​grafice ​=====
  
   * Responsabil:​ [[mihai.nan.cti@gmail.com|Mihai Nan]]   * Responsabil:​ [[mihai.nan.cti@gmail.com|Mihai Nan]]
Line 40: Line 40:
         super(text);​         super(text);​
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);​         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);​
-        setMinimumSize(new Dimension (3 0 02 0 0));+        setMinimumSize(new Dimension (300200));
         getContentPane().setBackground (Color.blue);​         getContentPane().setBackground (Color.blue);​
         setLayout(new SpringLayout());​         setLayout(new SpringLayout());​
Line 79: Line 79:
         super(text);​         super(text);​
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);​         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);​
-        setMinimumSize(new Dimension(3 0 02 0 0));+        setMinimumSize(new Dimension(300200));
         getContentPane().setBackground(Color.blue);​         getContentPane().setBackground(Color.blue);​
         setLayout(new SpringLayout());​         setLayout(new SpringLayout());​
Line 95: Line 95:
    ​@Override    ​@Override
    ​public void actionPerformed(ActionEvent e){    ​public void actionPerformed(ActionEvent e){
-       JButton button = (JButton)e.getSource();​ +    
-       ​if (button.getText().equals("​Apasa"​)){+   /​* ​   
 +    ​JButton button = (JButton)e.getSource();​ 
 +    if (button.getText().equals("​Apasa"​)) ​// valabil daca aveam mai multe butoane ascultate de acest ascultator 
 +    */
        ​System.out.println("​Butonul a fost apasat ! " ) ;        ​System.out.println("​Butonul a fost apasat ! " ) ;
-       } 
    }    }
 } }
Line 116: Line 118:
  
     public Text (String text){     public Text (String text){
-    ​super(text);​ +        ​super(text);​ 
-    setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);​ +        setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);​ 
-    setMinimumSize(new Dimension(3 0 02 0 0)); +        setMinimumSize(new Dimension(300200)); 
-    getContentPane().setBackground(Color.blue);​ +        getContentPane().setBackground(Color.blue);​ 
-    setLayout(new FlowLayout());​ +        setLayout(new FlowLayout());​ 
-    button = new JButton ("​Apasa"​);​ +        button = new JButton ("​Apasa"​);​ 
-    button.addActionListener(this);​ +        button.addActionListener(this);​ 
-    add(button);​ +        add(button);​ 
-    user = new JTextField(15);​ +        user = new JTextField(15);​ 
-    add(user);​ +        add(user);​ 
-    pass = new JPasswordField(15);​ +        pass = new JPasswordField(15);​ 
-    add(pass);​ +        add(pass);​ 
-    show(); +        show(); 
-    pack();+        pack();
     }     }
  
Line 138: Line 140:
     @Override     @Override
     public void actionPerformed(ActionEvent e){     public void actionPerformed(ActionEvent e){
 +        /*   
         JButton button = (JButton)e.getSource();​         JButton button = (JButton)e.getSource();​
-        if (button.getText().equals("​Apasa"​)){ +        if (button.getText().equals("​Apasa"​)) ​// valabil daca aveam mai multe butoane ascultate de acest ascultator 
-            System.out.println(user.getText() + pass.getText());​ +       */ 
-        }+        ​System.out.println(user.getText() + pass.getText());​
     }     }
 } }
Line 167: Line 170:
 <code java> <code java>
  
-c l a s s Text e x t e n d s JFrame { +class Text extends ​JFrame{ 
-2 p r i v a t e JTextArea ​te x tA re a +    ​private ​JTextArea ​textArea  
-3 p r i v a t e J S c r oll P a n e s c r o l l +    ​private JScrollPane scroll
-4 + 
-5 p u bli c Text ( S t ri n g t e x t ) { +    ​public ​Text (String text){ 
-6 supe r t e x t ) ; +        super(text); 
-7 s e t D e f a ul t Cl o s eO p e r a ti o n ( JFrame .EXIT_ON_CLOSE) ; +        ​setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);​ 
-setMinimumSize (new Dimension ( 3 0 0 2 0 0 ) ) ; +        setMinimumSize(new Dimension(300200)); 
-getContentPane ( ) . setBackground ( C ol o r bl u e ) ; +        getContentPane().setBackground(Color.blue); 
-10 se tL a y ou t (new FlowLayout ( ) ) ; +        ​setLayout(new FlowLayout());​ 
-11 te x tA re a = new JTextArea ( 2 0 0 1 0 0 ) ; +        ​textArea ​= new JTextArea(200100); 
-12 te x tA re a . setLineWrap ( t r u e ) ; +        ​textArea.setLineWrap(true); 
-13 te x tA re a . setWrapStyleWord ( t r u e ) ; +        ​textArea.setWrapStyleWord(true); 
-14 te x tA re a se tF on t (new Font ( "​Tahoma"​ , 2 , 1 2 ) ) ; +        ​textArea.setFont(new Font("​Tahoma",​ 2, 1 2)); 
-15 s c r o l l = new J S c r oll P a n e te x tA re a ) ; +        ​scroll ​= new JScrollPane(textArea); 
-16 add ( s c r o l l ) ; +        add(scroll); 
-17 show ( ) ; +        show(); 
-18 pack ( ) ; +        pack(); 
-19 +    
-20 + 
-21 p u bli c s t a t i c v oid main ( S t ri n g a r g s [ ] ) { +     public static void main (String args[]) { 
-22 Text b = new Text ( " ​L ab o r a t o r POO" ) ; +        Text b = new Text("LaboratorPOO"); 
-23 +    
-24 }+}
  
 </​code>​ </​code>​
poo/breviare/breviar-10.1543332678.txt.gz · Last modified: 2018/11/27 17:31 by matei.teodorescu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0