Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. package com.company;
  2. import java.awt.FlowLayout;
  3. import javax.swing.*;
  4. public class LabelFrame extends JFrame {
  5. private JLabel label1;
  6. private JLabel label2;
  7. private JLabel label3;
  8. public LabelFrame() {
  9. super("Testing JLabel");
  10. setLayout(new FlowLayout());
  11. label1 = new JLabel("Label with text");
  12. label1.setToolTipText("This is label1");
  13. add(label1);
  14.  
  15. Icon bug = new ImageIcon(getClass().getResource("bug1.png"));
  16. label2 = new JLabel("Label with text and icon",bug,SwingConstants.LEFT);
  17. label2.setToolTipText("This is label2");
  18. add(label2);
  19.  
  20. label3 = new JLabel();
  21. label3.setText("Label with icon and text at bottom");
  22. label3.setIcon(bug);
  23. label3.setHorizontalTextPosition(SwingConstants.CENTER);
  24. label3.setVerticalTextPosition(SwingConstants.BOTTOM);
  25. add(label3);
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement