Advertisement
Guest User

TestBackground

a guest
Apr 21st, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. package testbackground;
  2.  
  3. import java.awt.EventQueue;
  4. import java.awt.FlowLayout;
  5. import javax.swing.ImageIcon;
  6. import javax.swing.JButton;
  7. import javax.swing.JFrame;
  8. import javax.swing.JLabel;
  9. import javax.swing.JPanel;
  10.  
  11.  
  12. public class TestBackground extends JFrame {
  13.  
  14.     public TestBackground() {
  15.         setTitle("TestBackground");
  16.         setSize(800, 600);
  17.         setResizable(false);
  18.        
  19.         JLabel contentPane = new JLabel(new ImageIcon("background.jpg"));
  20.         setContentPane( contentPane );
  21.        
  22.        
  23.         JPanel panel = new JPanel();
  24.         panel.add(new JButton("Prueba"));
  25.         panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
  26.         add(panel);
  27.         setLayout(new FlowLayout());
  28.  
  29.        
  30.         setLocationRelativeTo(null);
  31.         setDefaultCloseOperation(EXIT_ON_CLOSE);
  32.     }
  33.    
  34.    
  35.     public static void main(String[] args) {
  36.         EventQueue.invokeLater(new Runnable() {
  37.        
  38.             @Override
  39.             public void run() {
  40.                 TestBackground app = new TestBackground();
  41.                 app.setVisible(true);
  42.             }
  43.         });
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement