Advertisement
Guest User

Untitled

a guest
Jul 9th, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.88 KB | None | 0 0
  1. import java.awt.EventQueue;
  2. import javax.swing.JOptionPane;
  3. import javax.swing.JFrame;
  4. import javax.swing.JButton;
  5. import java.awt.event.ActionListener;
  6. import java.awt.event.ActionEvent;
  7. import java.awt.Button;
  8. import javax.swing.JProgressBar;
  9.  
  10. public class main {
  11.  
  12.     private JFrame frame;
  13.  
  14.     /**
  15.      * Launch the application.
  16.      */
  17.     public static void main(String[] args) {
  18.         EventQueue.invokeLater(new Runnable() {
  19.             public void run() {
  20.                 try {
  21.                     main window = new main();
  22.                     window.frame.setVisible(true);
  23.                 } catch (Exception e) {
  24.                     e.printStackTrace();
  25.                 }
  26.             }
  27.         });
  28.     }
  29.  
  30.     /**
  31.      * Create the application.
  32.      */
  33.     public main() {
  34.         initialize();
  35.     }
  36.  
  37.     /**
  38.      * Initialize the contents of the frame.
  39.      */
  40.     private void initialize() {
  41.         frame = new JFrame();
  42.         frame.setBounds(100, 100, 450, 300);
  43.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  44.         frame.getContentPane().setLayout(null);
  45.        
  46.         JButton allButton = new JButton("Klick Mich!");
  47.         allButton.addActionListener(new ActionListener() {
  48.             public void actionPerformed(ActionEvent arg0) {
  49.                 progress1.setValue(50);
  50.                 main.infoBox("Hallo Welt!", "Hallo Welt!");
  51.                
  52.                
  53.             }
  54.         });
  55.         allButton.setBounds(10, 11, 418, 111);
  56.         frame.getContentPane().add(allButton);
  57.        
  58.         Button button = new Button("Beenden!");
  59.         button.addActionListener(new ActionListener() {
  60.             public void actionPerformed(ActionEvent e) {
  61.                 System.exit(0);
  62.             }
  63.         });
  64.         button.setBounds(10, 153, 418, 96);
  65.         frame.getContentPane().add(button);
  66.        
  67.         JProgressBar progress1 = new JProgressBar();
  68.         progress1.setStringPainted(true);
  69.         progress1.setBounds(20, 124, 408, 23);
  70.         frame.getContentPane().add(progress1);
  71.     }
  72.      public static void infoBox(String infoMessage, String titleBar)
  73.         {
  74.          
  75.          
  76.          JOptionPane.showMessageDialog(null, infoMessage, titleBar, JOptionPane.INFORMATION_MESSAGE);
  77.         }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement