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:com.floreantpos.ui.views.payment.SettleTicketDialog.java
private JPanel createTotalViewerPanel() { JLabel lblSubtotal = new javax.swing.JLabel(); lblSubtotal.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblSubtotal.setText(com.floreantpos.POSConstants.SUBTOTAL + ":" + " " + CurrencyUtil.getCurrencySymbol()); //$NON-NLS-1$ //$NON-NLS-2$ tfSubtotal = new javax.swing.JTextField(10); tfSubtotal.setHorizontalAlignment(SwingConstants.TRAILING); tfSubtotal.setEditable(false);/*from w ww. j a v a2s . c o m*/ JLabel lblDiscount = new javax.swing.JLabel(); lblDiscount.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblDiscount.setText(Messages.getString("TicketView.9") + " " + CurrencyUtil.getCurrencySymbol()); //$NON-NLS-1$ //$NON-NLS-2$ tfDiscount = new javax.swing.JTextField(10); // tfDiscount.setFont(tfDiscount.getFont().deriveFont(Font.PLAIN, 16)); tfDiscount.setHorizontalAlignment(SwingConstants.TRAILING); tfDiscount.setEditable(false); tfDiscount.setText(ticket.getDiscountAmount().toString()); JLabel lblDeliveryCharge = new javax.swing.JLabel(); lblDeliveryCharge.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblDeliveryCharge.setText("Delivery Charge:" + " " + CurrencyUtil.getCurrencySymbol()); //$NON-NLS-1$ //$NON-NLS-2$ tfDeliveryCharge = new javax.swing.JTextField(10); tfDeliveryCharge.setHorizontalAlignment(SwingConstants.TRAILING); tfDeliveryCharge.setEditable(false); JLabel lblTax = new javax.swing.JLabel(); lblTax.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblTax.setText(com.floreantpos.POSConstants.TAX + ":" + " " + CurrencyUtil.getCurrencySymbol()); //$NON-NLS-1$ //$NON-NLS-2$ tfTax = new javax.swing.JTextField(10); // tfTax.setFont(tfTax.getFont().deriveFont(Font.PLAIN, 16)); tfTax.setEditable(false); tfTax.setHorizontalAlignment(SwingConstants.TRAILING); JLabel lblGratuity = new javax.swing.JLabel(); lblGratuity.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblGratuity .setText(Messages.getString("SettleTicketDialog.5") + ":" + " " + CurrencyUtil.getCurrencySymbol()); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ tfGratuity = new javax.swing.JTextField(10); tfGratuity.setEditable(false); tfGratuity.setHorizontalAlignment(SwingConstants.TRAILING); JLabel lblTotal = new javax.swing.JLabel(); lblTotal.setFont(lblTotal.getFont().deriveFont(Font.BOLD, PosUIManager.getFontSize(18))); lblTotal.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblTotal.setText(com.floreantpos.POSConstants.TOTAL + ":" + " " + CurrencyUtil.getCurrencySymbol()); //$NON-NLS-1$ //$NON-NLS-2$ tfTotal = new javax.swing.JTextField(10); tfTotal.setFont(tfTotal.getFont().deriveFont(Font.BOLD, PosUIManager.getFontSize(18))); tfTotal.setHorizontalAlignment(SwingConstants.TRAILING); tfTotal.setEditable(false); JPanel ticketAmountPanel = new com.floreantpos.swing.TransparentPanel( new MigLayout("hidemode 3,ins 2 2 3 2,alignx trailing,fill", "[grow]2[]", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ ticketAmountPanel.add(lblSubtotal, "growx,aligny center"); //$NON-NLS-1$ ticketAmountPanel.add(tfSubtotal, "growx,aligny center"); //$NON-NLS-1$ ticketAmountPanel.add(lblDiscount, "newline,growx,aligny center"); //$NON-NLS-1$ //$NON-NLS-2$ ticketAmountPanel.add(tfDiscount, "growx,aligny center"); //$NON-NLS-1$ ticketAmountPanel.add(lblTax, "newline,growx,aligny center"); //$NON-NLS-1$ ticketAmountPanel.add(tfTax, "growx,aligny center"); //$NON-NLS-1$ if (ticket.getOrderType().isDelivery() && !ticket.isCustomerWillPickup()) { ticketAmountPanel.add(lblDeliveryCharge, "newline,growx,aligny center"); //$NON-NLS-1$ ticketAmountPanel.add(tfDeliveryCharge, "growx,aligny center"); //$NON-NLS-1$ } ticketAmountPanel.add(lblGratuity, "newline,growx,aligny center"); //$NON-NLS-1$ ticketAmountPanel.add(tfGratuity, "growx,aligny center"); //$NON-NLS-1$ ticketAmountPanel.add(lblTotal, "newline,growx,aligny center"); //$NON-NLS-1$ ticketAmountPanel.add(tfTotal, "growx,aligny center"); //$NON-NLS-1$ return ticketAmountPanel; }
From source file:com.commander4j.util.JUtility.java
public static void setResultRecordCountColour(JLabel label, boolean limitSet, Integer limitRecords, Integer ActualRecords) {//from w w w . java 2 s.c o m String warning = ""; if (ActualRecords > 0) { if (limitSet) { if (ActualRecords >= limitRecords) { label.setForeground(Color.RED); warning = " Number of records returned constrained by user defined limit."; } else { label.setForeground(Color.BLACK); } } else { label.setForeground(Color.BLACK); } label.setText(String.valueOf(ActualRecords) + " record(s) retrieved." + warning); } else { label.setForeground(Color.BLACK); label.setText("0 records shown."); } }
From source file:com.atlassian.theplugin.idea.jira.IssueCreateDialog.java
/** * Method generated by IntelliJ IDEA GUI Designer * >>> IMPORTANT!! <<< * DO NOT edit this method OR call it in your code! * * @noinspection ALL//from www . j a v a2 s .c om */ private void $$$setupUI$$$() { mainPanel = new JPanel(); mainPanel.setLayout(new GridLayoutManager(10, 3, new Insets(5, 5, 5, 5), -1, -1)); mainPanel.setMinimumSize(new Dimension(480, 500)); final JScrollPane scrollPane1 = new JScrollPane(); mainPanel.add(scrollPane1, new GridConstraints(7, 1, 2, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); description = new JTextArea(); description.setLineWrap(true); description.setWrapStyleWord(true); scrollPane1.setViewportView(description); final JLabel label1 = new JLabel(); label1.setText("Summary:"); mainPanel.add(label1, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JLabel label2 = new JLabel(); label2.setText("Project:"); mainPanel.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); projectComboBox = new JComboBox(); mainPanel.add(projectComboBox, new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(100, -1), null, null, 0, false)); summary = new JTextField(); mainPanel.add(summary, new GridConstraints(6, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(100, -1), null, 0, false)); final JLabel label3 = new JLabel(); label3.setText("Description:"); mainPanel.add(label3, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_NORTHEAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JLabel label4 = new JLabel(); label4.setText("Assignee:"); mainPanel.add(label4, new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JLabel label5 = new JLabel(); label5.setFont(new Font(label5.getFont().getName(), label5.getFont().getStyle(), 10)); label5.setHorizontalTextPosition(10); label5.setText("Warning! This field is not validated prior to sending to JIRA"); mainPanel.add(label5, new GridConstraints(9, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JLabel label6 = new JLabel(); label6.setText("Type:"); mainPanel.add(label6, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); typeComboBox = new JComboBox(); mainPanel.add(typeComboBox, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JLabel label7 = new JLabel(); label7.setText("Priority:"); mainPanel.add(label7, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); priorityComboBox = new JComboBox(); mainPanel.add(priorityComboBox, new GridConstraints(5, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, new Dimension(100, -1), null, null, 0, false)); final JLabel label8 = new JLabel(); label8.setText("Component/s:"); mainPanel.add(label8, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_NORTHEAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JScrollPane scrollPane2 = new JScrollPane(); mainPanel.add(scrollPane2, new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); componentsList = new JList(); componentsList.setToolTipText("Select Affected Components "); componentsList.setVisibleRowCount(5); scrollPane2.setViewportView(componentsList); final JLabel label9 = new JLabel(); label9.setText("Affects Version/s:"); mainPanel.add(label9, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JScrollPane scrollPane3 = new JScrollPane(); mainPanel.add(scrollPane3, new GridConstraints(3, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); versionsList = new JList(); versionsList.setVisibleRowCount(5); scrollPane3.setViewportView(versionsList); final JScrollPane scrollPane4 = new JScrollPane(); mainPanel.add(scrollPane4, new GridConstraints(4, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); fixVersionsList = new JList(); fixVersionsList.setVisible(true); fixVersionsList.setVisibleRowCount(5); scrollPane4.setViewportView(fixVersionsList); final JLabel label10 = new JLabel(); label10.setText("Fix Version/s:"); mainPanel.add(label10, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_NORTHEAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); label1.setLabelFor(summary); label2.setLabelFor(projectComboBox); label3.setLabelFor(description); label6.setLabelFor(typeComboBox); }
From source file:FormatTest.java
/** * Adds a row to the main panel.//www .j a va 2s . co m * @param labelText the label of the field * @param field the sample field */ public void addRow(String labelText, final JFormattedTextField field) { mainPanel.add(new JLabel(labelText)); mainPanel.add(field); final JLabel valueLabel = new JLabel(); mainPanel.add(valueLabel); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { Object value = field.getValue(); Class<?> cl = value.getClass(); String text = null; if (cl.isArray()) { if (cl.getComponentType().isPrimitive()) { try { text = Arrays.class.getMethod("toString", cl).invoke(null, value).toString(); } catch (Exception ex) { // ignore reflection exceptions } } else text = Arrays.toString((Object[]) value); } else text = value.toString(); valueLabel.setText(text); } }); }
From source file:edu.ku.brc.specify.prefs.FormattingPrefsPanel.java
/** * Create the UI for the panel// w w w . j a va 2 s . c o m */ protected void createUI() { createForm("Preferences", "Formatting"); //$NON-NLS-1$ //$NON-NLS-2$ UIValidator.setIgnoreAllValidation(this, true); JLabel fontNamesLabel = form.getLabelFor("fontNames"); //$NON-NLS-1$ ValComboBox fontNamesVCB = form.getCompById("fontNames"); //$NON-NLS-1$ JLabel fontSizesLabel = form.getLabelFor("fontSizes"); //$NON-NLS-1$ ValComboBox fontSizesVCB = form.getCompById("fontSizes"); //$NON-NLS-1$ JLabel controlSizesLabel = form.getLabelFor("controlSizes"); //$NON-NLS-1$ ValComboBox controlSizesVCB = form.getCompById("controlSizes"); //$NON-NLS-1$ formTypesCBX = form.getCompById("formtype"); //$NON-NLS-1$ fontNames = fontNamesVCB.getComboBox(); fontSizes = fontSizesVCB.getComboBox(); controlSizes = controlSizesVCB.getComboBox(); testField = form.getCompById("fontTest"); //$NON-NLS-1$ if (testField != null) { testField.setText(UIRegistry.getResourceString("FormattingPrefsPanel.THIS_TEST")); //$NON-NLS-1$ } if (UIHelper.isMacOS_10_5_X()) { fontNamesLabel.setVisible(false); fontNamesVCB.setVisible(false); fontSizesLabel.setVisible(false); fontSizesVCB.setVisible(false); testField.setVisible(false); int inx = -1; int i = 0; Vector<String> controlSizeTitles = new Vector<String>(); for (UIHelper.CONTROLSIZE cs : UIHelper.CONTROLSIZE.values()) { String titleStr = getResourceString(cs.toString()); controlSizeTitles.add(titleStr); controlSizesHash.put(titleStr, cs); controlSizes.addItem(titleStr); if (cs == UIHelper.getControlSize()) { inx = i; } i++; } controlSizes.setSelectedIndex(inx); Font baseFont = UIRegistry.getBaseFont(); if (baseFont != null) { fontNames.addItem(baseFont.getFamily()); fontSizes.addItem(Integer.toString(baseFont.getSize())); fontNames.setSelectedIndex(0); fontSizes.setSelectedIndex(0); } } else { controlSizesLabel.setVisible(false); controlSizesVCB.setVisible(false); Hashtable<String, Boolean> namesUsed = new Hashtable<String, Boolean>(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); for (Font font : ge.getAllFonts()) { if (namesUsed.get(font.getFamily()) == null) { fontNames.addItem(font.getFamily()); namesUsed.put(font.getFamily(), true); //$NON-NLS-1$ } } for (int i = BASE_FONT_SIZE; i < 22; i++) { fontSizes.addItem(Integer.toString(i)); } Font baseFont = UIRegistry.getBaseFont(); if (baseFont != null) { fontNames.setSelectedItem(baseFont.getFamily()); fontSizes.setSelectedItem(Integer.toString(baseFont.getSize())); if (testField != null) { ActionListener al = new ActionListener() { public void actionPerformed(ActionEvent e) { testField.setFont(new Font((String) fontNames.getSelectedItem(), Font.PLAIN, fontSizes.getSelectedIndex() + BASE_FONT_SIZE)); form.getUIComponent().validate(); clearFontSettings = false; } }; fontNames.addActionListener(al); fontSizes.addActionListener(al); } } } //----------------------------------- // Do DisciplineType Icons //----------------------------------- String iconName = AppPreferences.getRemote().get(getDisciplineImageName(), "CollectionObject"); //$NON-NLS-1$ //$NON-NLS-2$ List<Pair<String, ImageIcon>> list = IconManager.getListByType("disciplines", IconManager.IconSize.Std16); //$NON-NLS-1$ Collections.sort(list, new Comparator<Pair<String, ImageIcon>>() { public int compare(Pair<String, ImageIcon> o1, Pair<String, ImageIcon> o2) { String s1 = UIRegistry.getResourceString(o1.first); String s2 = UIRegistry.getResourceString(o2.first); return s1.compareTo(s2); } }); disciplineCBX = (ValComboBox) form.getCompById("disciplineIconCBX"); //$NON-NLS-1$ final JLabel dispLabel = form.getCompById("disciplineIcon"); //$NON-NLS-1$ JComboBox comboBox = disciplineCBX.getComboBox(); comboBox.setRenderer(new DefaultListCellRenderer() { @SuppressWarnings("unchecked") //$NON-NLS-1$ public Component getListCellRendererComponent(JList listArg, Object value, int index, boolean isSelected, boolean cellHasFocus) { Pair<String, ImageIcon> item = (Pair<String, ImageIcon>) value; JLabel label = (JLabel) super.getListCellRendererComponent(listArg, value, index, isSelected, cellHasFocus); if (item != null) { label.setIcon(item.second); label.setText(UIRegistry.getResourceString(item.first)); } return label; } }); int inx = 0; Pair<String, ImageIcon> colObj = new Pair<String, ImageIcon>("colobj_backstop", //$NON-NLS-1$ IconManager.getIcon("colobj_backstop", IconManager.IconSize.Std16)); //$NON-NLS-1$ comboBox.addItem(colObj); int cnt = 1; for (Pair<String, ImageIcon> item : list) { if (item.first.equals(iconName)) { inx = cnt; } comboBox.addItem(item); cnt++; } comboBox.addActionListener(new ActionListener() { @SuppressWarnings("unchecked") //$NON-NLS-1$ public void actionPerformed(ActionEvent e) { JComboBox cbx = (JComboBox) e.getSource(); Pair<String, ImageIcon> item = (Pair<String, ImageIcon>) cbx.getSelectedItem(); if (item != null) { dispLabel.setIcon(IconManager.getIcon(item.first)); form.getUIComponent().validate(); } } }); comboBox.setSelectedIndex(inx); //----------------------------------- // Date Field //----------------------------------- dateFieldCBX = form.getCompById("scrdateformat"); //$NON-NLS-1$ fillDateFormat(); //----------------------------------- // FormType //----------------------------------- fillFormTypes(); //----------------------------------- // Do App Icon //----------------------------------- final JButton getIconBtn = form.getCompById("GetIconImage"); //$NON-NLS-1$ final JButton clearIconBtn = form.getCompById("ClearIconImage"); //$NON-NLS-1$ final JLabel appLabel = form.getCompById("appIcon"); //$NON-NLS-1$ final JButton resetDefFontBtn = form.getCompById("ResetDefFontBtn"); //$NON-NLS-1$ String imgEncoded = AppPreferences.getRemote().get(iconImagePrefName, ""); //$NON-NLS-1$ ImageIcon innerAppImgIcon = null; if (StringUtils.isNotEmpty(imgEncoded)) { innerAppImgIcon = GraphicsUtils.uudecodeImage("", imgEncoded); //$NON-NLS-1$ if (innerAppImgIcon != null && innerAppImgIcon.getIconWidth() != 32 || innerAppImgIcon.getIconHeight() != 32) { innerAppImgIcon = null; clearIconBtn.setEnabled(false); } else { clearIconBtn.setEnabled(true); } } if (innerAppImgIcon == null) { innerAppImgIcon = IconManager.getIcon("AppIcon"); //$NON-NLS-1$ clearIconBtn.setEnabled(false); } else { clearIconBtn.setEnabled(true); } appLabel.setIcon(innerAppImgIcon); getIconBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { chooseToolbarIcon(appLabel, clearIconBtn); } }); clearIconBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ImageIcon appIcon = IconManager.getIcon("AppIcon"); IconEntry entry = IconManager.getIconEntryByName(INNER_APPICON_NAME); entry.setIcon(appIcon); if (entry.getIcons().get(IconManager.IconSize.Std32) != null) { entry.getIcons().get(IconManager.IconSize.Std32).setImageIcon(appIcon); } appLabel.setIcon(IconManager.getIcon("AppIcon")); //$NON-NLS-1$ clearIconBtn.setEnabled(false); AppPreferences.getRemote().remove(iconImagePrefName); form.getValidator().dataChanged(null, null, null); } }); resetDefFontBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Font sysDefFont = UIRegistry.getDefaultFont(); ComboBoxModel model = fontNames.getModel(); for (int i = 0; i < model.getSize(); i++) { //System.out.println("["+model.getElementAt(i).toString()+"]["+sysDefFont.getFamily()+"]"); if (model.getElementAt(i).toString().equals(sysDefFont.getFamily())) { fontNames.setSelectedIndex(i); clearFontSettings = true; break; } } if (clearFontSettings) { fontSizes.setSelectedIndex(sysDefFont.getSize() - BASE_FONT_SIZE); clearFontSettings = true; // needs to be redone } form.getValidator().dataChanged(null, null, null); } }); //----------------------------------- // Do Banner Icon Size //----------------------------------- String fmtStr = "%d x %d pixels";//getResourceString("BNR_ICON_SIZE"); bnrIconSizeCBX = form.getCompById("bnrIconSizeCBX"); //$NON-NLS-1$ int size = AppPreferences.getLocalPrefs().getInt(BNR_ICON_SIZE, 20); inx = 0; cnt = 0; for (int pixelSize : pixelSizes) { ((DefaultComboBoxModel) bnrIconSizeCBX.getModel()) .addElement(String.format(fmtStr, pixelSize, pixelSize)); if (pixelSize == size) { inx = cnt; } cnt++; } bnrIconSizeCBX.getComboBox().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { form.getUIComponent().validate(); } }); bnrIconSizeCBX.getComboBox().setSelectedIndex(inx); UIValidator.setIgnoreAllValidation(this, false); fontNamesVCB.setChanged(false); fontSizesVCB.setChanged(false); form.getValidator().validateForm(); }
From source file:com.smanempat.controller.ControllerEvaluation.java
public void validasiNumberofNearest(KeyEvent evt, JTextField txtNumberOfK, JLabel labelPesanError, JTable tableDataSetModel) { String numberValidate = txtNumberOfK.getText(); int modelRow = tableDataSetModel.getRowCount(); if (Pattern.matches("[0-9]+", numberValidate) == false && numberValidate.length() > 0) { evt.consume();//from ww w. j av a 2s . co m labelPesanError.setText("Number of Nearest Neighbor tidak valid"); } else if (numberValidate.length() == 9) { evt.consume(); labelPesanError.setText("Number of Nearest Neighbor terlalu panjang"); } else { labelPesanError.setText(""); } }
From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java
private JList buildJList(final Dimension dimension, final Object[] items, final JList list, final boolean sort) { if (items == null) { return null; }/* www . jav a2 s .com*/ list.setModel(new DefaultListModel() { @Override public void addElement(Object obj) { boolean inserted = false; if (sort) { for (int i = 0; i < this.getSize() && !inserted; i++) { try { final String comparator = ((obj == null) ? "" : obj.toString()); if (this.get(i).toString().compareTo(comparator) > 0) { this.add(i, obj); inserted = true; } } catch (Throwable t) { log.error("Error al ordenar a " + obj + " y no lo incluimos", t); inserted = true; } } } if (!inserted) { super.addElement(obj); } } }); log.trace("Lista con " + items.length + " objetos"); for (Object obj : items) { ((DefaultListModel) list.getModel()).addElement(obj); } list.setCellRenderer(new DefaultListCellRenderer() { private static final long serialVersionUID = -987995602141400182L; @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel c = new JLabel(); c.setText(value.toString()); if (isSelected) { c.setOpaque(true); c.setBackground(Color.YELLOW); } return c; } }); list.setMinimumSize(dimension); list.setFixedCellHeight(22); return list; }
From source file:gui_pack.MainGui.java
private void runTestsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runTestsButtonActionPerformed int rangeMin, rangeMax, spacing; int passing = 0; {// Beginning of input validation String errorTitle, errorMessage; //make sure at least one sort algorithm is selected if (!(insertionCheckBox.isSelected() || mergeCheckBox.isSelected() || quickCheckBox.isSelected() || selectionCheckBox.isSelected())) { errorTitle = "Selection Error"; errorMessage = "At least one sort algorithm (Insertion Sort, " + "Merge Sort, Quick Sort, or Selection Sort) must be selected."; JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE); return; }/*from w ww . j a v a2 s . co m*/ //make sure at least one order is selected if (!(ascendingCheckBox.isSelected() || descendingCheckBox.isSelected() || randomCheckBox.isSelected())) { errorTitle = "Selection Error"; errorMessage = "At least one order (Ascending Order, Descending Order, or Random Order) " + "must be selected."; JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE); return; } //make sure all the proper fields contain data try { rangeMin = Integer.parseInt(rangeMinField.getText()); rangeMax = Integer.parseInt(rangeMaxField.getText()); spacing = Integer.parseInt(spacingField.getText()); //for the multithreaded version of this program "iterations" cannot be a variable //this was left in to catch if the iteration field is left blank or has no value if (iterationField.isEnabled()) { Integer.parseInt(iterationField.getText()); } } catch (NumberFormatException arbitraryName) { errorTitle = "Input Error"; if (iterationField.isEnabled()) { errorMessage = "The size, intervals, and iterations fields must contain " + "integer values and only integer values."; } else { errorMessage = "The size and intervals fields must contain " + "integer values and only integer values."; } JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE); return; } //make sure field data is appropriate if (rangeMin > rangeMax) { errorTitle = "Range Error"; errorMessage = "Minimum Size must be less than or equal to Maximum Size."; JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE); return; } if (spacing < 1 || rangeMin < 1 || rangeMax < 1 || (iterationField.isEnabled() && Integer.parseInt(iterationField.getText()) < 1)) { errorTitle = "Value Error"; if (iterationField.isEnabled()) { errorMessage = "Intervals, sizes, and iterations must be in the positive domain. " + "Spacing, Range(min), Range(max), and Iterations must be greater than or" + " equal to one."; } else { errorMessage = "Intervals and sizes must be in the positive domain. " + "Spacing, Range(min) and Range(max) be greater than or" + " equal to one."; } JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.WARNING_MESSAGE); return; } if (!iterationField.isEnabled()) { passing = 0; } } // End of input validation //here's where we set up a loading bar in case the tests take a while JProgressBar loadBar = new JProgressBar(); JFrame loadFrame = new JFrame(); JLabel displayLabel1 = new JLabel(); loadBar.setIndeterminate(true); loadBar.setVisible(true); displayLabel1.setText("Running large tests, or many tests, using inefficient algorithms \n" + "may take a while. Please be patient."); loadFrame.setLayout(new FlowLayout()); loadFrame.add(loadBar); loadFrame.add(displayLabel1); loadFrame.setSize(600, 100); loadFrame.setTitle("Loading"); loadFrame.setVisible(true); //now we will leave this open until the tests are completed //now we can conduct the actual tests SwingWorker worker = new SwingWorker<XYSeriesCollection, Void>() { XYSeriesCollection results = new XYSeriesCollection(); @Override protected XYSeriesCollection doInBackground() { XYSeries insertSeries = new XYSeries("Insertion Sort"); XYSeries mergeSeries = new XYSeries("Merge Sort"); XYSeries quickSeries = new XYSeries("Quick Sort"); XYSeries selectSeries = new XYSeries("Selection Sort"); final boolean ascending = ascendingCheckBox.isSelected(); final boolean descending = descendingCheckBox.isSelected(); final boolean insertion = insertionCheckBox.isSelected(); final boolean merge = mergeCheckBox.isSelected(); final boolean quick = quickCheckBox.isSelected(); final boolean selection = selectionCheckBox.isSelected(); final int iterations = Integer.parseInt(iterationField.getText()); ListGenerator generator = new ListGenerator(); int[] list; for (int count = rangeMin; count <= rangeMax; count = count + spacing) { if (ascending) { list = generator.ascending(count); if (insertion) { insertSeries.add(count, insertionSort.sort(list)); } if (merge) { mergeSeries.add(count, mergeSort.sort(list)); } if (quick) { quickSeries.add(count, quickSort.sort(list)); } if (selection) { selectSeries.add(count, selectionSort.sort(list)); } } if (descending) { list = generator.descending(count); if (insertion) { insertSeries.add(count, insertionSort.sort(list)); } if (merge) { mergeSeries.add(count, mergeSort.sort(list)); } if (quick) { quickSeries.add(count, quickSort.sort(list)); } if (selection) { selectSeries.add(count, selectionSort.sort(list)); } } for (int iteration = 0; iteration < iterations; iteration++) { list = generator.random(count); if (insertion) { insertSeries.add(count, insertionSort.sort(list)); } if (merge) { mergeSeries.add(count, mergeSort.sort(list)); } if (quick) { quickSeries.add(count, quickSort.sort(list)); } if (selection) { selectSeries.add(count, selectionSort.sort(list)); } } } //now we aggregate the results if (insertion) { results.addSeries(insertSeries); } if (merge) { results.addSeries(mergeSeries); } if (quick) { results.addSeries(quickSeries); } if (selection) { results.addSeries(selectSeries); } return results; } @Override protected void done() { //finally, we display the results JFreeChart chart = ChartFactory.createScatterPlot("SortExplorer", // chart title "List Size", // x axis label "Number of Comparisons", // y axis label results, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); ChartFrame frame = new ChartFrame("First", chart); frame.pack(); frame.setVisible(true); loadFrame.setVisible(false); } }; //having set up the multithreading 'worker' we can finally conduct the //test worker.execute(); }
From source file:org.cds06.speleograph.graph.GraphEditor.java
/** * Creates a modal dialog by specifying the attached {@link GraphPanel}. * <p>Please look at {@link javax.swing.JDialog#JDialog()} to see defaults params applied to this Dialog.</p> *//*from w w w . java 2 s . com*/ public GraphEditor(GraphPanel panel) { super((Frame) SwingUtilities.windowForComponent(panel), true); Validate.notNull(panel); this.graphPanel = panel; KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); mainPanel.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); setContentPane(mainPanel); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); this.setTitle(I18nSupport.translate("menus.graph.graphEditor")); { // This section use FormLayout which is an external layout for Java, consult the doc before edit the // following lines ! final FormLayout layout = new FormLayout( "right:max(40dlu;p), 4dlu, p:grow, 4dlu, p, 4dlu, p:grow, 4dlu, p", //NON-NLS "p,4dlu,p,4dlu,p,4dlu,p,4dlu,p" //NON-NLS ); PanelBuilder builder = new PanelBuilder(layout); final JLabel colorLabel = new JLabel(); final JTextField titleForGraph = new JTextField( graphPanel.getChart().getTitle() != null ? graphPanel.getChart().getTitle().getText() : ""); final JLabel colorXYPlotLabel = new JLabel(); final JLabel colorGridLabel = new JLabel(); final JCheckBox showLegendCheckBox = new JCheckBox("Afficher la lgende", graphPanel.getChart().getLegend().isVisible()); { builder.addLabel("Titre :", "1,1"); builder.add(titleForGraph, "3,1,7,1"); } { builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.backgroundColor"), "1,3"); colorLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); colorLabel.setText(" "); colorLabel.setBackground((Color) graphPanel.getChart().getBackgroundPaint()); colorLabel.setOpaque(true); colorLabel.setEnabled(false); final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit")); edit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color c = JColorChooser.showDialog(GraphEditor.this, I18nSupport.translate("menus.graph.graphEditor.selectColor"), colorLabel.getBackground()); if (c != null) { colorLabel.setBackground(c); } } }); builder.add(colorLabel, "3,3,5,1"); builder.add(edit, "9,3"); } final XYPlot xyPlot = graphPanel.getChart().getXYPlot(); { builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.graphColor"), "1,5"); colorXYPlotLabel.setText(" "); colorXYPlotLabel.setOpaque(true); colorXYPlotLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); colorXYPlotLabel.setBackground((Color) xyPlot.getBackgroundPaint()); colorXYPlotLabel.setEnabled(false); final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit")); edit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color c = JColorChooser.showDialog(GraphEditor.this, I18nSupport.translate("menus.graph.graphEditor.selectColor"), colorXYPlotLabel.getBackground()); if (c != null) { colorXYPlotLabel.setBackground(c); } } }); builder.add(colorXYPlotLabel, "3,5,5,1"); builder.add(edit, "9,5"); } { builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.gridColor"), "1,7"); colorGridLabel.setOpaque(true); colorGridLabel.setText(" "); colorGridLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); colorGridLabel.setBackground((Color) xyPlot.getRangeGridlinePaint()); colorGridLabel.setEnabled(false); final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit")); edit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color c = JColorChooser.showDialog(GraphEditor.this, I18nSupport.translate("menus.graph.graphEditor.selectColor"), colorGridLabel.getBackground()); if (c != null) { colorGridLabel.setBackground(c); } } }); builder.add(colorGridLabel, "3,7,5,1"); builder.add(edit, "9,7"); } { builder.add(showLegendCheckBox, "1,9,9,1"); } mainPanel.add(builder.build(), BorderLayout.CENTER); ButtonBarBuilder buttonBarBuilder = new ButtonBarBuilder(); buttonBarBuilder.addGlue(); buttonBarBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("cancel")); } @Override public void actionPerformed(ActionEvent e) { GraphEditor.this.setVisible(false); } }); buttonBarBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("ok")); } @Override public void actionPerformed(ActionEvent e) { if (titleForGraph.getText().isEmpty()) graphPanel.getChart().setTitle((String) null); else graphPanel.getChart().setTitle(titleForGraph.getText()); { Color c = colorGridLabel.getBackground(); xyPlot.setRangeGridlinePaint(c); xyPlot.setRangeMinorGridlinePaint(c); xyPlot.setDomainGridlinePaint(c); xyPlot.setDomainMinorGridlinePaint(c); } graphPanel.getChart().setBackgroundPaint(colorLabel.getBackground()); xyPlot.setBackgroundPaint(colorXYPlotLabel.getBackground()); graphPanel.getChart().getLegend().setVisible(showLegendCheckBox.isSelected()); GraphEditor.this.setVisible(false); } }); mainPanel.add(buttonBarBuilder.build(), BorderLayout.SOUTH); } pack(); Dimension d = this.getPreferredSize(); this.setSize(new Dimension(d.width + 20, d.height)); setResizable(false); }
From source file:com.enderville.enderinstaller.ui.Installer.java
protected void initialPanel(JPanel contentPane) { JLabel text = new JLabel(); try {//from www .j a va2 s. co m ImageIcon icon = new ImageIcon(ImageIO.read(new FileInputStream(InstallerConfig.getLogoFile()))); text.setIcon(icon); } catch (IOException e) { LOGGER.error("IO error on logo.png", e); } StringBuilder textBuffer = new StringBuilder(); try { BufferedReader r = new BufferedReader(new FileReader(InstallerConfig.getInitTextFile())); String line = null; while ((line = r.readLine()) != null) { textBuffer.append(line + "\n"); } } catch (IOException ioe) { LOGGER.error("IO error on logo.png", ioe); } text.setText(textBuffer.toString()); text.setVerticalTextPosition(JLabel.BOTTOM); text.setHorizontalTextPosition(JLabel.CENTER); contentPane.setLayout(new MigLayout(new LC().fill())); contentPane.add(text, new CC().alignX("center").wrap()); contentPane.add(getTargetButton(), new CC().alignX("center").wrap()); }