List of usage examples for javax.swing JLabel JLabel
public JLabel(Icon image)
JLabel
instance with the specified image. From source file:Main.java
public static JPasswordField addLabeledPwdField(JComponent c, String label, int length, boolean wrap) { JLabel l = new JLabel(label); c.add(l, "align left"); JPasswordField pwd = new JPasswordField(length); if (wrap) {/*from w ww.j ava2s. com*/ c.add(pwd, "align left, wrap"); } else { c.add(pwd, "align left"); } return pwd; }
From source file:TabSample.java
static void addIt(JTabbedPane tabbedPane, String text) { JLabel label = new JLabel(text); JButton button = new JButton(text); JPanel panel = new JPanel(); panel.add(label);//from w ww. j a v a2 s. c om panel.add(button); tabbedPane.addTab(text, panel); tabbedPane.setTabComponentAt(tabbedPane.getTabCount() - 1, new JTextField(text)); }
From source file:Main.java
public static JLabel toSwingImage(final BufferedImage image) { JLabel label = new JLabel(new ImageIcon(image)); label.setAlignmentX(JComponent.CENTER_ALIGNMENT); return label; }
From source file:Main.java
public static Component getButtonLayout(int num) { JPanel p = new JPanel(new BorderLayout(3, 3)); p.add(new JLabel("Label " + num), BorderLayout.NORTH); JPanel b = new JPanel(new GridLayout(1, 0, 25, 5)); for (int ii = 1; ii < 4; ii++) { b.add(new JButton("Button " + ii)); }/*from w w w. j a va 2 s. c o m*/ p.add(b, BorderLayout.CENTER); return p; }
From source file:BoxLayoutDemo.java
private static JComponent createComponent(String s) { JLabel l = new JLabel(s); l.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, Color.DARK_GRAY)); l.setHorizontalAlignment(JLabel.CENTER); l.setAlignmentX(Component.CENTER_ALIGNMENT); //use middle of row return l;//from w ww .j ava 2s . c o m }
From source file:Main.java
private static JPanel createPanel() { JPanel panel = new JPanel(); final JLabel label = new JLabel(new Date().toString()); panel.add(label);/*from ww w .j a v a 2 s .c o m*/ panel.addAncestorListener(new AncestorListener() { @Override public void ancestorAdded(AncestorEvent event) { // start animation label.setText(new Date().toString()); } @Override public void ancestorRemoved(AncestorEvent event) { // stop animation } @Override public void ancestorMoved(AncestorEvent event) { } }); return panel; }
From source file:Main.java
public static JFrame getImageJFrame(BufferedImage image) { ImageIcon icon = new ImageIcon(); icon.setImage(image);/* w ww.j a v a2 s .c o m*/ JFrame frame = new JFrame(); frame.add(new JLabel(icon)); frame.pack(); return frame; }
From source file:Main.java
/** * @return a JPanel containing a label with the specified String as its text, and the component. *//*from ww w .j a v a 2 s.co m*/ public static JPanel labelComponent(JComponent c, String s) { JPanel panel = new JPanel(); panel.add(new JLabel(s)); panel.add(c); return panel; }
From source file:Main.java
private static JPanel createLogin() { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); JLabel label = new JLabel("login panel."); label.setFont(label.getFont().deriveFont(Font.ITALIC, 24f)); label.setAlignmentX(0.5f);/* w w w. j a v a 2 s .c om*/ label.setBorder(new EmptyBorder(0, 20, 0, 20)); p.add(Box.createVerticalStrut(36)); p.add(label); p.add(Box.createVerticalStrut(144)); return p; }
From source file:Main.java
/** * Returns a "warning"-colored panel with given message. * /* w w w .ja v a 2 s .com*/ * @param context * @param message * @return */ public static JPanel constructWarningPanel(String message) { JPanel p = new JPanel(); JLabel l = new JLabel(message); // "magical" color p.setBackground(new Color(240, 40, 70)); p.add(l); return p; }