Advertisement
lieutenant74

tester with buttons

Aug 30th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.39 KB | None | 0 0
  1. package Phone;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Color;
  5. import java.awt.FlowLayout;
  6. import java.awt.Font;
  7. import java.awt.event.ActionEvent;
  8. import java.io.IOException;
  9.  
  10. import javax.swing.AbstractAction;
  11. import javax.swing.BorderFactory;
  12. import javax.swing.JButton;
  13. import javax.swing.JFrame;
  14. import javax.swing.JOptionPane;
  15. import javax.swing.JPanel;
  16. import java.awt.Component;
  17.  
  18. public class Tester extends JFrame {
  19.    
  20.     public  Tester()  
  21.     {
  22.                
  23.         setTitle("main");
  24.         setSize(800,800);
  25.        
  26.         MyAction myAct = new MyAction("Print a new Customer");
  27.         JButton btn1 = new JButton(myAct);
  28.         btn1.setFont(new Font("Arial",Font.BOLD,40));
  29.        
  30.         JButton btn2 = new JButton(myAct);
  31.         JButton btn3 = new JButton(myAct);
  32.        
  33.         setLayout(new BorderLayout());
  34.         add(btn1, BorderLayout.CENTER);
  35.         add(btn2, BorderLayout.EAST);
  36.         add(btn3, BorderLayout.WEST);
  37.     }
  38.    
  39.     public static void main(String[] args) {
  40.         new Tester().setVisible(true);
  41.        
  42.  
  43.     }
  44.     public class MyAction extends AbstractAction {
  45.  
  46.         public MyAction(String str){
  47.             super(str);
  48.         }
  49.        
  50.         public void actionPerformed(ActionEvent arg0){
  51.             JOptionPane.SELECTION_VALUES_PROPERTY.valueOf(NAME);
  52.            
  53.             try{
  54.                 Phone p = new Phone ("d:\\cust.txt","0508848987", "jackov jojo", (int) Math.ceil(Math.random() * 1000));
  55.                 }catch (StackOverflowError | IOException e) {
  56.                     e.initCause(null);
  57.                 }
  58.         }
  59. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement