List of usage examples for javax.swing JLabel JLabel
public JLabel(Icon image)
JLabel
instance with the specified image. From source file:GridBagLayoutGridHeight.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container pane = f.getContentPane(); pane.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); pane.add(new JLabel("First row, first column"), gbc); pane.add(new JLabel("First row, second column"), gbc); gbc.gridheight = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.VERTICAL; pane.add(new JLabel("First row, third column"), gbc); gbc.gridx = 0;//w w w . j av a 2 s . c o m gbc.gridheight = 1; gbc.fill = GridBagConstraints.NONE; pane.add(new JButton("Second row"), gbc); pane.add(new JButton("Third row"), gbc); f.setSize(600, 300); f.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("JSpinner Dates"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpinnerModel model1 = new SpinnerDateModel(); JSpinner spinner1 = new JSpinner(model1); JLabel label1 = new JLabel("All"); JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(label1, BorderLayout.WEST); panel1.add(spinner1, BorderLayout.CENTER); frame.add(panel1, BorderLayout.NORTH); frame.setSize(200, 90);// w ww . ja va 2 s .c o m frame.setVisible(true); }
From source file:MainClass.java
public static void main(final String args[]) { JFrame frame = new JFrame("JSpinner Dates"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpinnerModel model1 = new SpinnerListModel(); JSpinner spinner1 = new JSpinner(model1); JLabel label1 = new JLabel("None"); JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(label1, BorderLayout.WEST); panel1.add(spinner1, BorderLayout.CENTER); frame.add(panel1, BorderLayout.NORTH); frame.setSize(200, 90);//from w w w . j a va2s . c o m frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { String[] columnNames = { "Date", "Field", "Home Team", "Visitor Team", "Score" }; JFrame guiFrame = new JFrame(); guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); guiFrame.setSize(500, 500);/*from ww w . j a v a 2s . co m*/ JPanel panel = new JPanel(); panel.setSize(450, 450); JLabel titleLabel = new JLabel("OK"); String[][] data = new String[0][0]; JTable scheduleTable = new JTable(data, columnNames); JScrollPane scrollPane = new JScrollPane(scheduleTable); panel.add(scrollPane); panel.add(titleLabel); guiFrame.add(panel); guiFrame.setVisible(true); }
From source file:MainClass.java
public static void main(String[] a) { JFrame frame = new JFrame("SpringLayout"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); SpringLayout layout = new SpringLayout(); contentPane.setLayout(layout);//www. j a v a 2 s.c o m Component left = new JLabel("Name"); Component right = new JTextField(15); contentPane.add(left); contentPane.add(right); layout.putConstraint(SpringLayout.WEST, left, 10, SpringLayout.WEST, contentPane); layout.putConstraint(SpringLayout.NORTH, left, 25, SpringLayout.NORTH, contentPane); layout.putConstraint(SpringLayout.NORTH, right, 25, SpringLayout.NORTH, contentPane); layout.putConstraint(SpringLayout.WEST, right, 20, SpringLayout.EAST, left); frame.setSize(300, 100); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) throws Exception { URL url = new URL("http://www.java2s.com/style/download.png"); final Image img = ImageIO.read(url); Runnable r = new Runnable() { @Override//from w w w. j a va2s . c om public void run() { JOptionPane.showMessageDialog(null, new JLabel(new ImageIcon(img))); } }; SwingUtilities.invokeLater(r); }
From source file:SpringSample.java
public static void main(String args[]) { JFrame frame = new JFrame("SpringLayout"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); SpringLayout layout = new SpringLayout(); contentPane.setLayout(layout);//w w w . jav a 2 s . com Component left = new JLabel("Left"); Component right = new JTextField(15); contentPane.add(left); contentPane.add(right); layout.putConstraint(SpringLayout.WEST, left, 10, SpringLayout.WEST, contentPane); layout.putConstraint(SpringLayout.NORTH, left, 25, SpringLayout.NORTH, contentPane); layout.putConstraint(SpringLayout.NORTH, right, 25, SpringLayout.NORTH, contentPane); layout.putConstraint(SpringLayout.WEST, right, 20, SpringLayout.EAST, left); frame.setSize(300, 100); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); JPanel panel = new JPanel(); Container c = frame.getContentPane(); panel.setSize(100, 100);//from ww w . java 2 s. co m panel.setLayout(new GridLayout(1000, 1)); for (int i = 0; i < 1000; i++) panel.add(new JLabel("JLabel " + i)); JScrollPane jsp = new JScrollPane(panel); c.add(jsp); frame.setSize(100, 100); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { JFrame frame = new JFrame("Property Split"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(new JLabel("www.java2s.com")); splitPane.setBottomComponent(new JLabel("www.java2s.com")); PropertyChangeListener propertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent changeEvent) { JSplitPane sourceSplitPane = (JSplitPane) changeEvent.getSource(); String propertyName = changeEvent.getPropertyName(); if (propertyName.equals(JSplitPane.LAST_DIVIDER_LOCATION_PROPERTY)) { int current = sourceSplitPane.getDividerLocation(); System.out.println("Current: " + current); Integer last = (Integer) changeEvent.getNewValue(); System.out.println("Last: " + last); Integer priorLast = (Integer) changeEvent.getOldValue(); System.out.println("Prior last: " + priorLast); }/* w ww . j a v a 2 s . c om*/ } }; // Attach listener splitPane.addPropertyChangeListener(propertyChangeListener); frame.add(splitPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:SpinnerNumberSample.java
public static void main(String args[]) { JFrame frame = new JFrame("JSpinner Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SpinnerModel model1 = new SpinnerNumberModel(); JSpinner spinner1 = new JSpinner(model1); JLabel label1 = new JLabel("Numbers"); JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(label1, BorderLayout.WEST); panel1.add(spinner1, BorderLayout.CENTER); frame.add(panel1, BorderLayout.SOUTH); frame.setSize(200, 90);//from ww w.j a va 2 s. co m frame.setVisible(true); }