Example usage for javax.swing JLabel setText

List of usage examples for javax.swing JLabel setText

Introduction

In this page you can find the example usage for javax.swing JLabel setText.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "Defines the single line of text this component will display.")
public void setText(String text) 

Source Link

Document

Defines the single line of text this component will display.

Usage

From source file:com.microsoft.alm.plugin.idea.git.ui.simplecheckout.SimpleCheckoutForm.java

/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL/*  w w  w  .j  av a2  s  .  co m*/
 */
private void $$$setupUI$$$() {
    contentPanel = new JPanel();
    contentPanel.setLayout(new GridLayoutManager(6, 1, new Insets(0, 0, 0, 0), -1, -1));
    contentPanel.setMinimumSize(new Dimension(500, 180));
    final JLabel label1 = new JLabel();
    label1.setText("Directory Name:");
    contentPanel.add(label1,
            new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    directoryName = new JTextField();
    contentPanel.add(directoryName,
            new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 0, false));
    final JLabel label2 = new JLabel();
    label2.setText("Repository Url:");
    contentPanel.add(label2,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    repoUrl = new JTextField();
    repoUrl.setEditable(false);
    contentPanel.add(repoUrl,
            new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 0, false));
    parentDirectory = new TextFieldWithBrowseButton();
    contentPanel.add(parentDirectory,
            new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null,
                    new Dimension(150, -1), null, 0, false));
    final JLabel label3 = new JLabel();
    label3.setText("Parent Directory:");
    contentPanel.add(label3,
            new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
}

From source file:MonthPanel.java

protected JPanel createDaysGUI() {
    JPanel dayPanel = new JPanel(true);
    dayPanel.setLayout(new GridLayout(0, dayNames.length));

    Calendar today = Calendar.getInstance();
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.MONTH, month);
    calendar.set(Calendar.YEAR, year);
    calendar.set(Calendar.DAY_OF_MONTH, 1);

    Calendar iterator = (Calendar) calendar.clone();
    iterator.add(Calendar.DAY_OF_MONTH, -(iterator.get(Calendar.DAY_OF_WEEK) - 1));

    Calendar maximum = (Calendar) calendar.clone();
    maximum.add(Calendar.MONTH, +1);

    for (int i = 0; i < dayNames.length; i++) {
        JPanel dPanel = new JPanel(true);
        dPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        JLabel dLabel = new JLabel(dayNames[i]);
        dPanel.add(dLabel);//from  w w  w. ja v a  2  s  . c o m
        dayPanel.add(dPanel);
    }

    int count = 0;
    int limit = dayNames.length * 6;

    while (iterator.getTimeInMillis() < maximum.getTimeInMillis()) {
        int lMonth = iterator.get(Calendar.MONTH);
        int lYear = iterator.get(Calendar.YEAR);

        JPanel dPanel = new JPanel(true);
        dPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        JLabel dayLabel = new JLabel();

        if ((lMonth == month) && (lYear == year)) {
            int lDay = iterator.get(Calendar.DAY_OF_MONTH);
            dayLabel.setText(Integer.toString(lDay));
        }
        dPanel.add(dayLabel);
        dayPanel.add(dPanel);
        iterator.add(Calendar.DAY_OF_YEAR, +1);
        count++;
    }

    for (int i = count; i < limit; i++) {
        JPanel dPanel = new JPanel(true);
        dPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));

        dPanel.add(new JLabel());
        dayPanel.add(dPanel);
    }
    return dayPanel;
}

From source file:Main.java

public Main() {
    for (int i = 0; i < panels.length; i++) {
        final String[] labels = new String[] { "0", "1" };
        final Random rand = new Random();
        int index = rand.nextInt(labels.length);
        String randomTitle = labels[index];
        final JLabel label = new JLabel(randomTitle, JLabel.CENTER);
        Timer lblt = new Timer(00, new ActionListener() {
            @Override/*  w  ww .  j av  a  2 s  .c  om*/
            public void actionPerformed(ActionEvent ae) {
                label.setText(labels[rand.nextInt(labels.length)]);
            }
        });
        lblt.setRepeats(true);
        lblt.start();
        label.setForeground(Color.green);
        label.setVerticalAlignment(JLabel.CENTER);
        panels[i] = new JPanel();
        panels[i].setBackground(Color.BLACK);
        panels[i].add(label);
        frame.getContentPane().add(panels[i]);
    }
    frame.setLayout(new GridLayout(grid, grid));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
    frame.setVisible(true);

    ActionListener action = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            for (int i = 0; i < panels.length; i++) {
                Color mix = new Color(255, 255, 255);
                Random random = new Random();
                int r = random.nextInt(255);
                int g = random.nextInt(255);
                int b = random.nextInt(255);

                if (mix != null) {
                    r = (r + mix.getRed()) / 2;
                    g = (g + mix.getGreen()) / 2;
                    b = (b + mix.getBlue()) / 2;
                }
                Color color = new Color(r, g, b);
                panels[i].setBackground(color);
            }
        }
    };

    t = new Timer(00, action);
    t.setRepeats(true);
    t.start();
}

From source file:EditableColorColumn.java

private void configureRenderer(JLabel renderer, Object value) {
    if ((value != null) && (value instanceof Color)) {
        renderer.setIcon(new DiamondIcon((Color) value));
        renderer.setText("");
    } else {/*  w ww .j a  v  a 2  s.c  o m*/
        renderer.setIcon(null);
        renderer.setText((String) value);
    }
}

From source file:com.diversityarrays.kdxplore.curate.TraitInstanceCellRenderer.java

private void initIcon(JLabel label, Object value) {
    Icon icon = null;//  w ww.ja v a  2 s  .  c om
    if (value instanceof TraitInstance) {
        TraitInstance ti = (TraitInstance) value;
        if (TRAIT_TO_EDIT == ti) {
            label.setText("Trait to Edit");
        } else {
            icon = traitColorProvider.getTraitLegendTile(ti);
            label.setText(instanceNameTransformer.transform(ti));
        }
    }
    label.setIcon(icon);
}

From source file:de.tor.tribes.ui.renderer.DateCellRenderer.java

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    JLabel label = (JLabel) c;
    try {// www  .j a va2  s . c  o  m
        long val = ((Date) value).getTime();
        if (val > System.currentTimeMillis() - DateUtils.MILLIS_PER_DAY * 365 * 10) {//more than ten year ago...invalid!
            label.setText((value == null) ? "" : specialFormat.format(value));
        } else {
            label.setText("-");
        }
    } catch (Exception e) {
        label.setText("-");
    }

    return label;
}

From source file:bazaar4idea.ui.BzrPushDialog.java

/** Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 * @noinspection ALL/*  www.  j av  a2 s  .c o  m*/
 */
private void $$$setupUI$$$() {
    contentPanel = new JPanel();
    contentPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    final JPanel panel1 = new JPanel();
    panel1.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1));
    contentPanel.add(panel1,
            new GridConstraints(0, 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 Spacer spacer1 = new Spacer();
    panel1.add(spacer1,
            new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1,
                    GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
    final JLabel label1 = new JLabel();
    label1.setText("Destination Repository URL:");
    label1.setDisplayedMnemonic('D');
    label1.setDisplayedMnemonicIndex(0);
    panel1.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
            GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    repositoryTxt = new JTextField();
    panel1.add(repositoryTxt,
            new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    final JPanel panel2 = new JPanel();
    panel2.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1));
    panel1.add(panel2,
            new GridConstraints(3, 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,
                    new Dimension(-1, 100), null, null, 0, false));
    panel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Options"));
    revisionCbx = new JCheckBox();
    revisionCbx.setText("Revision");
    revisionCbx.setMnemonic('R');
    revisionCbx.setDisplayedMnemonicIndex(0);
    panel2.add(revisionCbx,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    revisionTxt = new JTextField();
    revisionTxt.setEnabled(false);
    revisionTxt.setText("tip");
    panel2.add(revisionTxt,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 0, false));
    final Spacer spacer2 = new Spacer();
    panel2.add(spacer2,
            new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1,
                    GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
    final Spacer spacer3 = new Spacer();
    panel2.add(spacer3,
            new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
    hgRepositorySelectorComponent = new BzrRepositorySelectorComponent();
    panel1.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));
    label1.setLabelFor(repositoryTxt);
}

From source file:king.flow.action.business.InsertCardAction.java

private void showOnComponent(int componentId, String value) {
    Component meta = (Component) getBlockMeta(componentId);
    getLogger(InsertCardAction.class.getName()).log(Level.INFO, "Display component[{0}] type : {1}",
            new Object[] { String.valueOf(meta.getId()), meta.getType().value() });
    switch (meta.getType()) {
    case LABEL://from www  .ja v  a  2  s  . com
        JLabel label = getBlock(meta.getId(), JLabel.class);
        label.setText(StringEscapeUtils.unescapeHtml(value));
        break;
    case TEXT_FIELD:
        JTextField textField = getBlock(meta.getId(), JTextField.class);
        textField.setText(value);
        break;
    case COMBO_BOX:
        JComboBox combo = getBlock(meta.getId(), JComboBox.class);
        if (combo.isEditable()) {
            combo.getEditor().setItem(value);
        }
        break;
    default:
        getLogger(InsertCardAction.class.getName()).log(Level.WARNING,
                "Unsupported showed component type : {0}", meta.getType());
    }
}

From source file:com.floreantpos.ui.views.order.modifier.TicketItemModifierTableView.java

private JPanel createItemDescriptionPanel() {
    MenuItem menuItem = modifierSelectionModel.getMenuItem();
    JPanel itemDescriptionPanel = new JPanel(new MigLayout("inset 0,center"));
    String description = menuItem.getDescription();
    if (StringUtils.isEmpty(description) && menuItem.getImage() == null) {
        return itemDescriptionPanel;
    }//from   w w  w.  jav a 2 s  .  co  m
    itemDescriptionPanel.setBorder(BorderFactory.createTitledBorder("-"));
    JLabel lblDescription = new JLabel();
    lblDescription.setText("<html><body>" + description + "</body></html>");
    JLabel pictureLabel = new JLabel(menuItem.getImage());

    itemDescriptionPanel.add(pictureLabel);
    itemDescriptionPanel.add(lblDescription);

    return itemDescriptionPanel;
}

From source file:com.game.ui.views.CharachterEditorPanel.java

@Override
public void actionPerformed(ActionEvent ae) {
    if (ae.getActionCommand().equalsIgnoreCase("dropDown")) {
        JComboBox comboBox = (JComboBox) ae.getSource();
        JPanel panel = (JPanel) comboBox.getParent().getComponent(4);
        String name = comboBox.getSelectedItem().toString();
        for (GameCharacter enemy : GameBean.enemyDetails) {
            if (enemy.getName().equalsIgnoreCase(name)) {
                ((JTextField) panel.getComponent(2)).setText(enemy.getName());
                ((JTextField) panel.getComponent(4)).setText(enemy.getImagePath());
                ((JTextField) panel.getComponent(6)).setText(new Integer(enemy.getHealth()).toString());
                ((JTextField) panel.getComponent(8)).setText(new Integer(enemy.getAttackPts()).toString());
                ((JTextField) panel.getComponent(10)).setText(new Integer(enemy.getArmor()).toString());
                ((JTextField) panel.getComponent(12)).setText(new Integer(enemy.getAttackRange()).toString());
                ((JTextField) panel.getComponent(14)).setText(new Integer(enemy.getMovement()).toString());
                return;
            }/*ww w . ja  v a 2  s  .  co m*/
        }
    } else {
        JButton btn = (JButton) ae.getSource();
        JPanel panel = (JPanel) btn.getParent();
        int indexOfBtn = btn.getAccessibleContext().getAccessibleIndexInParent();
        String name = ((JTextField) panel.getComponent(2)).getText();
        String image = ((JTextField) panel.getComponent(4)).getText();
        String health = ((JTextField) panel.getComponent(6)).getText();
        String attackPts = ((JTextField) panel.getComponent(8)).getText();
        String armourPts = ((JTextField) panel.getComponent(10)).getText();
        String attackRnge = ((JTextField) panel.getComponent(12)).getText();
        String movement = ((JTextField) panel.getComponent(14)).getText();
        System.out.println("Index : " + indexOfBtn);
        JLabel message = ((JLabel) this.getComponent(5));
        message.setText("");
        message.setVisible(false);
        if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(image) && StringUtils.isNotBlank(health)
                && StringUtils.isNotBlank(attackPts) && StringUtils.isNotBlank(armourPts)
                && StringUtils.isNotBlank(attackRnge) && StringUtils.isNotBlank(movement)) {
            message.setVisible(false);
            GameCharacter character = new GameCharacter();
            character.setName(name);
            character.setAttackPts(Integer.parseInt(attackPts));
            character.setAttackRange(Integer.parseInt(attackRnge));
            character.setHealth(Integer.parseInt(health));
            character.setImagePath(image);
            character.setMovement(Integer.parseInt(movement));
            character.setArmor(Integer.parseInt(armourPts));
            boolean characterAlrdyPresent = false;
            for (int i = 0; i < GameBean.enemyDetails.size(); i++) {
                GameCharacter charFromList = GameBean.enemyDetails.get(i);
                if (charFromList.getName().equalsIgnoreCase(name)) {
                    GameBean.enemyDetails.remove(i);
                    GameBean.enemyDetails.add(i, character);
                    characterAlrdyPresent = true;
                }
            }
            if (!characterAlrdyPresent) {
                GameBean.enemyDetails.add(character);
            }
            try {
                GameUtils.writeCharactersToXML(GameBean.enemyDetails, Configuration.PATH_FOR_ENEMY_CHARACTERS);
                message.setText("Saved Successfully..");
                message.setVisible(true);
                if (!characterAlrdyPresent) {
                    comboBox.addItem(name);
                    comboBox.setSelectedItem(name);
                }
                TileInformation tileInfo = GameBean.mapInfo.getPathMap().get(location);
                if (tileInfo == null) {
                    tileInfo = new TileInformation();
                }
                tileInfo.setEnemy(character);
                GameBean.mapInfo.getPathMap().put(location, tileInfo);
                chkBox.setSelected(true);
                this.revalidate();
                return;
            } catch (Exception e) {
                System.out.println("CharachterEditorPanel : actionPerformed() : Some error occured " + e);
                e.printStackTrace();
            }

        } else {
            message.setText("Pls enter all the fields or pls choose a character from the drop down");
            message.setVisible(true);
            this.revalidate();
        }
    }
}