List of usage examples for javax.swing JLabel setText
@BeanProperty(preferred = true, visualUpdate = true, description = "Defines the single line of text this component will display.") public void setText(String text)
From source file:Main.java
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = new JLabel() { public Dimension getPreferredSize() { return new Dimension(200, 100); }/*from ww w . j av a 2s.co m*/ }; label.setText(String.valueOf(value)); return label; }
From source file:ComboTableCellRenderer.java
private void configureRenderer(JLabel renderer, Object value) { if ((value != null) && (value instanceof Color)) { renderer.setText(value.toString()); renderer.setBackground((Color) value); } else {/* w w w. j a v a 2 s .c o m*/ renderer.setText((String) value); } }
From source file:app.Plot.java
public void showElements(List<WordStatistic> was, JComboBox cb) { JFreeChart chart = createPlot(was, cb.getSelectedItem()); plotDesign(chart);/*from www.ja va 2s. c o m*/ ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setDomainZoomable(false); PlotWindow plot = new PlotWindow(); plot.setVisible(true); JPanel panetJTitle = new JPanel(); JPanel panelJPanel = new JPanel(); JPanel panelJComboBox = new JPanel(); panelJPanel.removeAll(); panelJComboBox.removeAll(); JLabel title = new JLabel(); title.setText( " ?? ? ? ?? '" + cb.getSelectedItem().toString() + "' ?"); chartPanel.setPreferredSize(new java.awt.Dimension(600, 400)); JLabel label = new JLabel(); label.setText(" ?? "); panetJTitle.add(title); panelJPanel.add(chartPanel); panelJComboBox.add(label); panelJComboBox.add(cb); JPanel panelWindow = new JPanel(); panelWindow.add(panetJTitle); panelWindow.add(panelJPanel); panelWindow.add(panelJComboBox); plot.setContentPane(panelWindow); }
From source file:cl.almejo.vsim.gui.actions.preferences.ColorPreferences.java
private void addColorChooser(JPanel panel, final String item) { JLabel label = new JLabel(); label.setText(Messages.t("preferences.color.scheme." + item + ".label")); panel.add(label);/*from w w w . j ava 2s . co m*/ JButton button = new JButton(Messages.t("default.change.label")); ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JButton button = (JButton) e.getSource(); String themeName = ColorScheme.getCurrent().getName(); Color color = JColorChooser.showDialog(button, Messages.t("preferences.color.choose.title"), ColorScheme.getScheme(themeName).get(item)); if (color != null) { ColorScheme.getScheme(themeName).set(item, color); } } }; button.addActionListener(actionListener); panel.add(button); }
From source file:kuvalataaja.user_interface.GUI.java
/** * Creates a label to keep the rest of the code cleaner. * @return The created label //w w w. ja v a2 s.c om */ private JLabel createJLabel() { JLabel label = new JLabel(); label.setText("<html><p>Hello and welcome to my program!</p></html>"); label.setHorizontalAlignment(JLabel.CENTER); label.setVerticalAlignment(JLabel.CENTER); return label; }
From source file:com.game.ui.views.UserDialog.java
public UserDialog(String message, JFrame frame) { setLayout(new BorderLayout(5, 5)); setModalityType(ModalityType.APPLICATION_MODAL); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setResizable(false);//from w w w . j a v a2 s . co m ImageIcon icon = null; try { icon = GameUtils.shrinkImage("warning.gif", 30, 30); } catch (IOException e) { System.out.println("Dialog : showDialogForMap(): Exception occured :" + e); e.printStackTrace(); } JPanel panel = new JPanel(); JLabel label = new JLabel(icon); panel.setLayout(new FlowLayout(FlowLayout.LEFT)); label.setText(message); label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); label.setHorizontalAlignment(0); panel.add(label); add(panel, BorderLayout.NORTH); JPanel contentPanel = new JPanel(); contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS)); txt = new JTextField(); txt.setPreferredSize(new Dimension(150, 30)); txt.setAlignmentX(.5f); txt.setMaximumSize(new Dimension(150, 30)); contentPanel.add(txt); contentPanel.add(Box.createVerticalStrut(10)); JButton btn = new JButton("Submit."); btn.setAlignmentX(.5f); btn.setPreferredSize(new Dimension(50, 25)); btn.addActionListener(this); validationMess = new JLabel("All fields are mandatory"); validationMess.setVisible(false); validationMess.setForeground(Color.red); validationMess.setAlignmentX(.5f); contentPanel.add(btn); contentPanel.add(Box.createVerticalStrut(10)); contentPanel.add(validationMess); contentPanel.add(Box.createVerticalGlue()); add(contentPanel, BorderLayout.CENTER); pack(); setSize(new Dimension(300, 200)); setLocationRelativeTo(frame); setVisible(true); }
From source file:bazaar4idea.ui.BzrTagDialog.java
/** Method generated by IntelliJ IDEA GUI Designer * >>> IMPORTANT!! <<< * DO NOT edit this method OR call it in your code! * @noinspection ALL// www . j a v a2s .c o m */ private void $$$setupUI$$$() { contentPanel = new JPanel(); contentPanel.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1)); final Spacer spacer1 = new Spacer(); contentPanel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); hgRepositorySelectorComponent = new BzrRepositorySelectorComponent(); contentPanel.add(hgRepositorySelectorComponent.$$$getRootComponent$$$(), new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); final JPanel panel1 = new JPanel(); panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); contentPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); final JLabel label1 = new JLabel(); label1.setText("Tag name:"); panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final Spacer spacer2 = new Spacer(); panel1.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); tagTxt = new JTextField(); panel1.add(tagTxt, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); }
From source file:com.jdom.util.patterns.mvp.swing.RadioButtonGroupDialog.java
private RadioButtonGroupDialog(Frame frame, Component locationComp, String labelText, String title, Collection<String> data, String initialValue, String longValue) { super(frame, title, true); final JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); final JButton setButton = new JButton("OK"); setButton.setActionCommand("OK"); setButton.addActionListener(this); getRootPane().setDefaultButton(setButton); ButtonGroup radioButtonGroup = new ButtonGroup(); for (String option : data) { JRadioButton button = new JRadioButton(option); if (option.equals(initialValue)) { button.setSelected(true);//from ww w. j a va 2 s .co m } radioButtonGroup.add(button); panel.add(button); } JScrollPane listScroller = new JScrollPane(panel); listScroller.setPreferredSize(new Dimension(250, 80)); listScroller.setAlignmentX(LEFT_ALIGNMENT); JPanel listPane = new JPanel(); listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS)); if (!StringUtils.isEmpty(labelText)) { JLabel label = new JLabel(labelText); label.setText(labelText); listPane.add(label); } listPane.add(Box.createRigidArea(new Dimension(0, 5))); listPane.add(listScroller); listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(cancelButton); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(setButton); Container contentPane = getContentPane(); contentPane.add(listPane, BorderLayout.CENTER); contentPane.add(buttonPane, BorderLayout.PAGE_END); pack(); setLocationRelativeTo(locationComp); }
From source file:bazaar4idea.ui.BzrPullDialog.java
/** Method generated by IntelliJ IDEA GUI Designer * >>> IMPORTANT!! <<< * DO NOT edit this method OR call it in your code! * @noinspection ALL/*ww w.j a va 2 s . co m*/ */ private void $$$setupUI$$$() { mainPanel = new JPanel(); mainPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); hgRepositorySelector = new BzrRepositorySelectorComponent(); mainPanel.add(hgRepositorySelector.$$$getRootComponent$$$(), new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); final Spacer spacer1 = new Spacer(); mainPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); final JPanel panel1 = new JPanel(); panel1.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); mainPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); final JLabel label1 = new JLabel(); label1.setText("Pull From:"); panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final Spacer spacer2 = new Spacer(); panel1.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); sourceTxt = new JTextField(); panel1.add(sourceTxt, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); }
From source file:SecretTest.java
public SecretTest() { super("EventListenerList Demo"); setSize(200, 100);/*from w w w. ja v a 2s. c om*/ setDefaultCloseOperation(EXIT_ON_CLOSE); SecretLabel secret = new SecretLabel("Try Clicking Me"); final JLabel reporter = new JLabel("Event reports will show here..."); secret.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { reporter.setText("Got it: " + ae.getActionCommand()); } }); getContentPane().add(secret, BorderLayout.NORTH); getContentPane().add(reporter, BorderLayout.SOUTH); }