Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. /*
  2. Arthur Polon Lemos - Info 3B
  3. */
  4. package labelframe;
  5.  
  6. import java.awt.FlowLayout;
  7. import java.awt.event.ActionListener;
  8. import java.awt.event.ActionEvent;
  9. import javax.swing.JFrame;
  10. import javax.swing.JLabel;
  11. import javax.swing.SwingConstants;
  12. import javax.swing.JButton;
  13. import javax.swing.Icon;
  14. import javax.swing.ImageIcon;
  15. import javax.swing.JOptionPane;
  16.  
  17. public class LabelFrame extends JFrame{
  18. private JLabel label1;
  19. private JLabel label2;
  20. private JLabel label3;
  21. public LabelFrame(){
  22. super("Testing JLabel");
  23. setLayout (new FlowLayout ());
  24. label1 = new JLabel("Label with text");
  25. label1.setToolTipText ("This is Label 1");
  26. add(label1);
  27.  
  28. Icon bug = new ImageIcon(getClass().getResource("bug1.png"));
  29. label2 = new JLabel("Label with text and icon", bug , SwingConstants.LEFT);
  30. label2.setToolTipText("This is label2");
  31. add(label2);
  32.  
  33. label3 = new JLabel ();
  34. label3.setText("Label with icon and text at bottom");
  35. label3.setIcon (bug);
  36. label3.setHorizontalTextPosition(SwingConstants.BOTTOM);
  37. label3.setToolTipText("this is label 3");
  38. add(label3);
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement