List of usage examples for javax.swing JLabel JLabel
public JLabel(Icon image)
JLabel
instance with the specified image. From source file:MainClass.java
public static void main(String[] args) { JFrame f = new JFrame(); final JPanel p1 = new JPanel(); p1.add(new JLabel("GlassPane Example")); JButton show = new JButton("Show"); p1.add(show);/*from ww w .j av a 2 s .com*/ p1.add(new JButton("No-op")); f.getContentPane().add(p1); final JPanel glass = (JPanel) f.getGlassPane(); glass.setVisible(true); glass.setLayout(new GridBagLayout()); JButton glassButton = new JButton("Hide"); glass.add(glassButton); f.setSize(150, 80); f.setVisible(true); show.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { glass.setVisible(true); p1.repaint(); } }); glassButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { glass.setVisible(false); p1.repaint(); } }); }
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("Hello"); label.setOpaque(true);/*from w w w . j a v a2 s .c om*/ label.setBackground(Color.red); JPanel bottomPanel = new JPanel(new BorderLayout()); bottomPanel.add(label, BorderLayout.LINE_END); JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(bottomPanel, BorderLayout.PAGE_END); mainPanel.setPreferredSize(new Dimension(400, 400)); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(mainPanel); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { EtchedBorder etchedBorder = (EtchedBorder) BorderFactory.createEtchedBorder(); JLabel component = new JLabel("label"); component.setBorder(etchedBorder);//from w ww. ja v a 2s . co m }
From source file:Main.java
public static void main(String[] argv) { BevelBorder loweredBevelBorder = (BevelBorder) BorderFactory.createLoweredBevelBorder(); JLabel component = new JLabel("label"); component.setBorder(loweredBevelBorder); }
From source file:Main.java
public static void main(String[] argv) { BevelBorder raisedBevelBorder = (BevelBorder) BorderFactory.createRaisedBevelBorder(); JLabel component = new JLabel("label"); component.setBorder(raisedBevelBorder); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JLabel label = new JLabel("Label Text"); final String propertyName = "text"; label.setTransferHandler(new TransferHandler(propertyName)); label.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent evt) { JComponent comp = (JComponent) evt.getSource(); TransferHandler th = comp.getTransferHandler(); th.exportAsDrag(comp, evt, TransferHandler.COPY); }/*w w w . ja v a2 s . co m*/ }); }
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("java2s.com"); JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(label);/*from ww w . j a v a2 s.co m*/ JPanel buttons = new JPanel(new GridLayout(0, 1)); for (int index = 0; index < 10; index++) { buttons.add(new JButton(String.valueOf(index))); } JPanel right = new JPanel(new BorderLayout()); right.add(buttons, BorderLayout.NORTH); frame.add(right, BorderLayout.EAST); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextField textfield = new JTextField(25); // Create label and associate with text field JLabel label = new JLabel("Text Label"); label.setDisplayedMnemonic(KeyEvent.VK_L); label.setLabelFor(textfield);/*from w w w .j a v a2s . co m*/ }
From source file:Main.java
public static void main(String[] argv) { LineBorder lineBorder = (LineBorder) BorderFactory.createLineBorder(Color.black); JLabel component = new JLabel("label"); component.setBorder(lineBorder);/* w ww .j a v a2s . c om*/ }
From source file:Main.java
public static void main(String[] args) { String html = "<html><body>" + "<h1>Header</h1>" + "<img src='http://www.java2s.com/style/download.png' " + "width='160' height='120'>"; JLabel label = new JLabel("Point at me!"); label.setToolTipText(html);/*from ww w . j a va 2 s.com*/ JOptionPane.showMessageDialog(null, label); }