Example usage for javax.swing JLabel JLabel

List of usage examples for javax.swing JLabel JLabel

Introduction

In this page you can find the example usage for javax.swing JLabel JLabel.

Prototype

public JLabel(Icon image) 

Source Link

Document

Creates a JLabel instance with the specified image.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    JLabel label = new JLabel("java2s.com");

    JPanel panel = new JPanel();
    panel.add(label);//w ww. j  a va2 s. co  m
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    JOptionPane.showMessageDialog(null, panel);

}

From source file:Main.java

public static void main(String[] args) {
    Color myColor = new Color(0XFFFFFFFF, true);

    JLabel label = new JLabel("First Name");
    label.setForeground(myColor);//w  ww  .  j a  va2 s  .c  om

    JFrame frame = new JFrame();
    frame.add(label);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBounds(20, 20, 500, 500);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    Color myColor = new Color(0.1F, 0.2F, 0.3F);

    JLabel label = new JLabel("First Name");
    label.setForeground(myColor);//from   ww w  . j a v a2s. com

    JFrame frame = new JFrame();
    frame.add(label);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBounds(20, 20, 500, 500);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    Color myBlack = new Color(0, 0, 0, 120); // Color black

    JLabel label = new JLabel("First Name");
    label.setForeground(myBlack);//from w w w.  ja  v  a 2 s . c  o  m

    JFrame frame = new JFrame();
    frame.add(label);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBounds(20, 20, 500, 500);
    frame.setVisible(true);

}

From source file:HtmlToolTipDemo.java

public static void main(String[] a) {
    JFrame mainFrame = new JFrame();

    JLabel label = new JLabel("label");

    label.setToolTipText("<html>First line<br>Second Line</html>");
    mainFrame.getContentPane().add(label);

    mainFrame.setSize(100, 100);//from w w  w  . j ava2  s  . c om

    mainFrame.setVisible(true);

}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLabel label = new JLabel("<html>bold <br> plain</html>");
    frame.add(label);//from ww  w . ja  v  a2  s  .co m

    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) throws InterruptedException {
    JFrame frame = new JFrame();
    frame.add(new JLabel("Minimize demo"));
    frame.pack();//from   www .  ja  v a2s .co  m

    // Show the frame
    frame.setVisible(true);

    // Sleep for 5 seconds, then minimize
    Thread.sleep(5000);
    frame.setState(Frame.ICONIFIED);

    // Sleep for 5 seconds, then restore
    Thread.sleep(5000);
    frame.setState(Frame.NORMAL);

    // Sleep for 5 seconds, then kill window
    Thread.sleep(5000);
    frame.setVisible(false);
    frame.dispose();

    // Terminate test
    System.exit(0);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setLayout(new BorderLayout());
    JLabel label = new JLabel("<html>" + "<img src=\"" + Main.class.getResource("/resource/path/to/image1.jpg")
            + "\">" + "<img src=\"" + Main.class.getResource("/resource/path/to/image2.jpg") + "\">"
            + "The text</html>");
    frame.add(label, BorderLayout.CENTER);
    frame.setBounds(100, 100, 200, 100);
    frame.setVisible(true);//from  w w w  . ja  v  a  2s.c o  m
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame("Hello!!");
    frame.setAlwaysOnTop(true);//  w w w. j av  a2s  . c o m
    frame.setLocationByPlatform(true);
    frame.add(new JLabel("  Always visible"));
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) {
    EmptyBorder emptyBorder = (EmptyBorder) BorderFactory.createEmptyBorder();
    JLabel component = new JLabel("label");
    component.setBorder(emptyBorder);//from  w ww .ja v  a2s .c  o m

}