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[]) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Box rowOne = new Box(BoxLayout.Y_AXIS);
    rowOne.add(new JLabel("Username"));
    rowOne.add(new JTextField());
    Component rowTwo = Box.createVerticalStrut(2);

    f.add(rowOne, BorderLayout.NORTH);
    f.add(rowTwo, BorderLayout.SOUTH);
    f.setSize(300, 200);/*from  ww w. j a  va 2 s.  c o m*/
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    Image image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
    JPanel gui = new JPanel(new BorderLayout());

    JLabel clouds = new JLabel(new ImageIcon(new BufferedImage(250, 100, BufferedImage.TYPE_INT_RGB)));
    gui.add(clouds);//from   w  w w  .  j av a2  s  .  co m

    JOptionPane.showConfirmDialog(null, gui, "Title", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE, new ImageIcon(image));
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    final String html = "<html><body>" + "<img src='" + "http://www.java2s.com/style/download.png"
            + "' width=160 height=120> " + "<img src='" + "http://www.java2s.com/style/download.png"
            + "' width=160 height=120>" + "<p>Message!";

    JLabel hover = new JLabel("Point at me!");
    hover.setToolTipText(html);/*from ww w .jav a 2s.c  om*/
    JOptionPane.showMessageDialog(null, hover);

}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel(new BorderLayout());
    JLabel label = new JLabel("Name: ");
    label.setDisplayedMnemonic(KeyEvent.VK_N);
    JTextField textField = new JTextField();
    textField.setHorizontalAlignment(JTextField.CENTER);

    label.setLabelFor(textField);/*from   w ww. jav  a  2 s  .  com*/
    panel.add(label, BorderLayout.WEST);
    panel.add(textField, BorderLayout.CENTER);
    frame.add(panel, BorderLayout.NORTH);
    frame.setSize(250, 150);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    JTabbedPane tp = new JTabbedPane();
    tp.addTab("Dates", new JPanel());
    tp.addTab("Deliveries", new JPanel());
    tp.addTab("Exports", new JPanel());

    tp.setTabComponentAt(0, new JLabel("Dates"));
    tp.setTabComponentAt(1, new JLabel("Deliveries"));
    tp.setTabComponentAt(2, new JLabel("Exports"));

    JFrame frame = new JFrame("Testing");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());
    frame.add(tp);//from  w w w .  ja v a 2  s .c  om
    frame.pack();
    frame.setVisible(true);
}

From source file:ProxyTester.java

public static void main(String[] args) {
    JTabbedPane tabbedPane = new JTabbedPane();
    for (String name : imageNames) {
        JLabel label = new JLabel(new ImageProxy(name));
        tabbedPane.add(name, label);// w  ww . java 2 s . c  o  m
    }

    JFrame frame = new JFrame();
    frame.add(tabbedPane);

    frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) {
    JFrame f = new JFrame("JPasswordField Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Box rowOne = Box.createHorizontalBox();
    rowOne.add(new JLabel("Username"));
    rowOne.add(new JTextField());
    Box rowTwo = Box.createHorizontalBox();
    rowTwo.add(new JLabel("Password"));
    rowTwo.add(new JPasswordField());
    f.add(rowOne, BorderLayout.NORTH);
    f.add(rowTwo, BorderLayout.SOUTH);
    f.setSize(300, 200);/*from   w ww .  j a  va2 s .  co  m*/
    f.setVisible(true);
}

From source file:Main.java

public static void main(String arg[]) {
    JFrame frame = new JFrame();
    frame.setLayout(new BorderLayout());

    JPanel gb = new JPanel(new GridBagLayout());
    JLabel content = new JLabel("Some text");

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.weighty = 1;/*from  w w  w.  jav a  2 s  . c  o m*/

    gb.add(content, gbc); // gbc is containing the GridBagConstraints
    frame.add(gb, BorderLayout.CENTER);

    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setUndecorated(true);/*from  w w w . j av  a 2s .  c om*/
    JPanel panel = new JPanel();
    panel.add(new JLabel("Stackoverflow!"));
    panel.add(new JButton(new AbstractAction("Close") {
        @Override
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    }));
    f.add(panel);
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame f = new JFrame("JPasswordField Sample");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Box rowOne = Box.createHorizontalBox();
    rowOne.add(new JLabel("Username"));
    rowOne.add(new JTextField());
    Box rowTwo = Box.createHorizontalBox();
    rowTwo.add(new JLabel("Password"));
    JPasswordField jpassword = new JPasswordField();

    rowTwo.add(jpassword);/*from w  w w.  j a  va 2 s . co m*/
    f.add(rowOne, BorderLayout.NORTH);
    f.add(rowTwo, BorderLayout.SOUTH);
    f.setSize(300, 200);
    f.setVisible(true);

    System.out.println(jpassword.echoCharIsSet());

}