Guest User

Untitled

a guest
Feb 18th, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. mport java.awt.event.ActionEvent;
  2. import java.awt.event.ActionListener;
  3.  
  4. import javax.swing.*;
  5.  
  6.  
  7. public class midtermWindow extends JFrame{
  8.  
  9.     private int WINDOW_WIDTH = 275;
  10.     private int WINDOW_HEIGHT = 100;
  11.    
  12.     private JPanel panel;
  13.     private JButton enterB;
  14.     private JLabel inputL;
  15.     private JTextField inputTF;
  16.    
  17.    
  18.     public midtermWindow()
  19.     {
  20.         setTitle("Midterm");
  21.         setSize(WINDOW_WIDTH,WINDOW_HEIGHT);
  22.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  23.         buildPanel();
  24.         add(panel);
  25.        
  26.         setVisible(true);
  27.     }
  28.    
  29.     private void buildPanel()
  30.     {
  31.    
  32.         JLabel inputL = new JLabel("Please enter earnings from sales: ");
  33.         JTextField inputTF = new JTextField(10);
  34.         JButton enterB = new JButton ("Enter");
  35.         enterB.addActionListener(new buttonActionListener ());
  36.         panel = new JPanel();
  37.        
  38.        
  39.         panel.add(inputL);
  40.         panel.add(inputTF);
  41.         panel.add(enterB);
  42.        
  43.     }
  44.    
  45.     private class buttonActionListener implements ActionListener
  46.     {
  47.  
  48.          
  49.  
  50.         @Override
  51.         public void actionPerformed(ActionEvent e) {
  52.            
  53.             double salesInput;
  54.             String input;
  55.            
  56.             input = inputTF.getText();
  57.  
  58.             JOptionPane.showMessageDialog(null, "This Works");
  59.            
  60.         }
  61.        
  62.        
  63.     }
  64.    
  65.    
  66.    
  67. }
Add Comment
Please, Sign In to add comment