Advertisement
raisul82

Swing JFrame2

Mar 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1.  
  2. import java.awt.Color;
  3. import javax.swing.ImageIcon;
  4. import javax.swing.JFrame;
  5. import java.awt.Container;
  6. import javax.swing.JLabel;
  7.  
  8.  
  9. public class Frame extends JFrame{
  10. private ImageIcon icon;//for setting icon creating a ImageIcon object
  11. private Container c;
  12. private JLabel label;
  13.  
  14. Frame()
  15. {
  16. setVisible(true);
  17. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  18. setBounds(200,50,300,500);
  19. setTitle("Title");
  20. iconMethod();
  21. }
  22.  
  23. public void iconMethod()
  24. {
  25. c=this.getContentPane();
  26. c.setLayout(null);
  27. c.setBackground(Color.PINK);
  28. label=new JLabel();
  29. label.setText("Enter Your Name : ");
  30. label.setBounds(50,20,150,50);
  31. c.add(label);
  32. icon=new ImageIcon(getClass().getResource("illustrator.png"));//icon setting
  33. this.setIconImage(icon.getImage()); //icon getting
  34.  
  35. }
  36.  
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement