Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.awt.FlowLayout;
- import javax.swing.*;
- public class LabelFrame extends JFrame {
- private JLabel label1;
- private JLabel label2;
- private JLabel label3;
- public LabelFrame() {
- super("Testing JLabel");
- setLayout(new FlowLayout());
- label1 = new JLabel("Label with text");
- label1.setToolTipText("This is label1");
- add(label1);
- Icon bug = new ImageIcon(getClass().getResource("bug1.png"));
- label2 = new JLabel("Label with text and icon",bug,SwingConstants.LEFT);
- label2.setToolTipText("This is label2");
- add(label2);
- label3 = new JLabel();
- label3.setText("Label with icon and text at bottom");
- label3.setIcon(bug);
- label3.setHorizontalTextPosition(SwingConstants.CENTER);
- label3.setVerticalTextPosition(SwingConstants.BOTTOM);
- add(label3);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement