List of usage examples for javax.swing JLabel JLabel
public JLabel(Icon image, int horizontalAlignment)
JLabel
instance with the specified image and horizontal alignment. From source file:FormattedTextFieldExample.java
public static void main(String[] args) { try {//ww w .j av a 2s. co m UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JFrame f = new JFrame("Formatted Text Field"); final FormattedTextField tf = new FormattedTextField(); FormattedTextField.FormatSpec formatSpec = new FormattedTextField.FormatSpec("(...)-...-....", "(***)-***-****"); tf.setFormatSpec(formatSpec); f.getContentPane().add(tf, "Center"); f.getContentPane().add(new JLabel("Phone Number: ", JLabel.RIGHT), "West"); tf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.out.println("Field content is <" + tf.getText() + ">"); } }); f.pack(); f.setVisible(true); }
From source file:JLabelDragSource.java
public static void main(String[] args) { try {/*from w w w . j av a 2s.co m*/ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JFrame f = new JFrame("Draggable JLabel"); JLabel label = new JLabel("Drag this text", JLabel.CENTER); label.setFont(new Font("Serif", Font.BOLD, 32)); f.getContentPane().add(label); f.pack(); f.setVisible(true); // Attach the drag source JLabelDragSource dragSource = new JLabelDragSource(label); }
From source file:Main.java
public static JLabel getLabel(String text, int w, int h, int horizontalAlignment) { JLabel label = new JLabel(text, horizontalAlignment); label.setPreferredSize(getLabelDimension(w, h)); label.setMinimumSize(getLabelDimension(w, h)); label.setFont(getFont());//w w w . java 2 s. c o m return label; }
From source file:Main.java
public static void setupNowLoadingPanel(JPanel panel) { JLabel loading = new JLabel("Loading...", SwingConstants.CENTER); panel.setLayout(new BorderLayout()); panel.add(loading, BorderLayout.CENTER); panel.revalidate();/* w w w .jav a 2s. c om*/ panel.repaint(); }
From source file:Main.java
/** * @param label/* www .ja v a 2s . c om*/ * @param labelFor * @return createt JLabel */ public static JLabel createLabelFor(String label, Component labelFor) { JLabel labelComponent = new JLabel(label, JLabel.TRAILING); labelComponent.setLabelFor(labelFor); return labelComponent; }
From source file:Main.java
public static JLabel createLabel(String text, int align) { final JLabel b = new JLabel(text, align); configureActiveComponent(b);/*from w w w .ja va 2 s . c o m*/ return b; }