List of usage examples for javax.swing JLabel setForeground
@BeanProperty(preferred = true, visualUpdate = true, description = "The foreground color of the component.") public void setForeground(Color fg)
From source file:com.sshtools.common.ui.SshToolsApplication.java
/** * Show an 'About' dialog/*from w w w .ja v a 2 s.c om*/ * * */ public void showAbout(final Component parent) { JPanel p = new JPanel(new GridBagLayout()); p.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); GridBagConstraints gBC = new GridBagConstraints(); gBC.anchor = GridBagConstraints.CENTER; gBC.fill = GridBagConstraints.HORIZONTAL; gBC.insets = new Insets(1, 1, 1, 1); JLabel a = new JLabel(getApplicationName()); a.setFont(a.getFont().deriveFont(24f)); UIUtil.jGridBagAdd(p, a, gBC, GridBagConstraints.REMAINDER); MultilineLabel v = new MultilineLabel(getApplicationName() + " " + getApplicationVersion()); v.setFont(v.getFont().deriveFont(10f)); UIUtil.jGridBagAdd(p, v, gBC, GridBagConstraints.REMAINDER); MultilineLabel x = new MultilineLabel(getAboutAuthors()); x.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 0)); x.setFont(x.getFont().deriveFont(12f)); UIUtil.jGridBagAdd(p, x, gBC, GridBagConstraints.REMAINDER); MultilineLabel c = new MultilineLabel(getAboutLicenseDetails()); c.setFont(c.getFont().deriveFont(10f)); UIUtil.jGridBagAdd(p, c, gBC, GridBagConstraints.REMAINDER); final JLabel h = new JLabel(getAboutURL()); h.setForeground(Color.blue); h.setFont(new Font(h.getFont().getName(), Font.BOLD, 10)); h.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); h.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { try { BrowserLauncher.openURL(getAboutURL()); } catch (IOException ioe) { ioe.printStackTrace(); } } }); UIUtil.jGridBagAdd(p, h, gBC, GridBagConstraints.REMAINDER); JOptionPane.showMessageDialog(parent, p, "About", JOptionPane.PLAIN_MESSAGE, getApplicationLargeIcon()); }
From source file:com.eviware.soapui.support.components.SimpleForm.java
public void addInputFieldHintText(String text) { JLabel label = new JLabel(text); label.setForeground(HINT_TEXT_COLOR); addComponentWithoutLabel(label);/*from ww w . j a v a 2 s. c o m*/ }
From source file:com.edduarte.protbox.ui.windows.RestoreFileWindow.java
private RestoreFileWindow(final PReg registry) { super();//from ww w .j a va2 s.com setLayout(null); final JTextField searchField = new JTextField(); searchField.setLayout(null); searchField.setBounds(2, 2, 301, 26); searchField.setBorder(new LineBorder(Color.lightGray)); searchField.setFont(Constants.FONT); add(searchField); final JLabel noBackupFilesLabel = new JLabel("<html>No backups files were found!<br><br>" + "<font color=\"gray\">If you think there is a problem with the<br>" + "backup system, please create an issue here:<br>" + "<a href=\"#\">https://github.com/com.edduarte/protbox/issues</a></font></html>"); noBackupFilesLabel.setLayout(null); noBackupFilesLabel.setBounds(20, 50, 300, 300); noBackupFilesLabel.setFont(Constants.FONT.deriveFont(14f)); noBackupFilesLabel.addMouseListener((OnMouseClick) e -> { String urlPath = "https://github.com/com.edduarte/protbox/issues"; try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().browse(new URI(urlPath)); } else { if (SystemUtils.IS_OS_WINDOWS) { Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + urlPath); } else { java.util.List<String> browsers = Lists.newArrayList("firefox", "opera", "safari", "mozilla", "chrome"); for (String browser : browsers) { if (Runtime.getRuntime().exec(new String[] { "which", browser }).waitFor() == 0) { Runtime.getRuntime().exec(new String[] { browser, urlPath }); break; } } } } } catch (Exception ex) { ex.printStackTrace(); } }); DefaultMutableTreeNode rootTreeNode = registry.buildEntryTree(); final JTree tree = new JTree(rootTreeNode); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); if (rootTreeNode.getChildCount() == 0) { searchField.setEnabled(false); add(noBackupFilesLabel); } expandTree(tree); tree.setLayout(null); tree.setRootVisible(false); tree.setEditable(false); tree.setCellRenderer(new SearchableTreeCellRenderer(searchField)); searchField.addKeyListener((OnKeyReleased) e -> { // update and expand tree DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); model.nodeStructureChanged((TreeNode) model.getRoot()); expandTree(tree); }); final JScrollPane scroll = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scroll.setBorder(new DropShadowBorder()); scroll.setBorder(new LineBorder(Color.lightGray)); scroll.setBounds(2, 30, 334, 360); add(scroll); JLabel close = new JLabel(new ImageIcon(Constants.getAsset("close.png"))); close.setLayout(null); close.setBounds(312, 7, 18, 18); close.setFont(Constants.FONT); close.setForeground(Color.gray); close.addMouseListener((OnMouseClick) e -> dispose()); add(close); final JLabel permanentDeleteButton = new JLabel(new ImageIcon(Constants.getAsset("permanent.png"))); permanentDeleteButton.setLayout(null); permanentDeleteButton.setBounds(91, 390, 40, 39); permanentDeleteButton.setBackground(Color.black); permanentDeleteButton.setEnabled(false); permanentDeleteButton.addMouseListener((OnMouseClick) e -> { if (permanentDeleteButton.isEnabled()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); PbxEntry entry = (PbxEntry) node.getUserObject(); if (JOptionPane.showConfirmDialog(null, "Are you sure you wish to permanently delete '" + entry.realName() + "'?\nThis file and its " + "backup copies will be deleted immediately. You cannot undo this action.", "Confirm Cancel", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { registry.permanentDelete(entry); dispose(); RestoreFileWindow.getInstance(registry); } else { setVisible(true); } } }); add(permanentDeleteButton); final JLabel configBackupsButton = new JLabel(new ImageIcon(Constants.getAsset("config.png"))); configBackupsButton.setLayout(null); configBackupsButton.setBounds(134, 390, 40, 39); configBackupsButton.setBackground(Color.black); configBackupsButton.setEnabled(false); configBackupsButton.addMouseListener((OnMouseClick) e -> { if (configBackupsButton.isEnabled()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); PbxEntry entry = (PbxEntry) node.getUserObject(); if (entry instanceof PbxFile) { PbxFile pbxFile = (PbxFile) entry; JFrame frame = new JFrame("Choose backup policy"); Object option = JOptionPane.showInputDialog(frame, "Choose below the backup policy for this file:", "Choose backup", JOptionPane.QUESTION_MESSAGE, null, PbxFile.BackupPolicy.values(), pbxFile.getBackupPolicy()); if (option == null) { setVisible(true); return; } PbxFile.BackupPolicy pickedPolicy = PbxFile.BackupPolicy.valueOf(option.toString()); pbxFile.setBackupPolicy(pickedPolicy); } setVisible(true); } }); add(configBackupsButton); final JLabel restoreBackupButton = new JLabel(new ImageIcon(Constants.getAsset("restore.png"))); restoreBackupButton.setLayout(null); restoreBackupButton.setBounds(3, 390, 85, 39); restoreBackupButton.setBackground(Color.black); restoreBackupButton.setEnabled(false); restoreBackupButton.addMouseListener((OnMouseClick) e -> { if (restoreBackupButton.isEnabled()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); PbxEntry entry = (PbxEntry) node.getUserObject(); if (entry instanceof PbxFolder) { registry.restoreFolderFromEntry((PbxFolder) entry); } else if (entry instanceof PbxFile) { PbxFile pbxFile = (PbxFile) entry; java.util.List<String> snapshots = pbxFile.snapshotsToString(); if (snapshots.isEmpty()) { setVisible(true); return; } JFrame frame = new JFrame("Choose backup"); Object option = JOptionPane.showInputDialog(frame, "Choose below what backup snapshot would you like restore:", "Choose backup", JOptionPane.QUESTION_MESSAGE, null, snapshots.toArray(), snapshots.get(0)); if (option == null) { setVisible(true); return; } int pickedIndex = snapshots.indexOf(option.toString()); registry.restoreFileFromEntry((PbxFile) entry, pickedIndex); } dispose(); } }); add(restoreBackupButton); tree.addMouseListener((OnMouseClick) e -> { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node != null) { PbxEntry entry = (PbxEntry) node.getUserObject(); if ((entry instanceof PbxFolder && entry.areNativeFilesDeleted())) { permanentDeleteButton.setEnabled(true); restoreBackupButton.setEnabled(true); configBackupsButton.setEnabled(false); } else if (entry instanceof PbxFile) { permanentDeleteButton.setEnabled(true); restoreBackupButton.setEnabled(true); configBackupsButton.setEnabled(true); } else { permanentDeleteButton.setEnabled(false); restoreBackupButton.setEnabled(false); configBackupsButton.setEnabled(false); } } }); final JLabel cancel = new JLabel(new ImageIcon(Constants.getAsset("cancel.png"))); cancel.setLayout(null); cancel.setBounds(229, 390, 122, 39); cancel.setBackground(Color.black); cancel.addMouseListener((OnMouseClick) e -> dispose()); add(cancel); addWindowFocusListener(new WindowFocusListener() { private boolean gained = false; @Override public void windowGainedFocus(WindowEvent e) { gained = true; } @Override public void windowLostFocus(WindowEvent e) { if (gained) { dispose(); } } }); setSize(340, 432); setUndecorated(true); getContentPane().setBackground(Color.white); setResizable(false); getRootPane().setBorder(BorderFactory.createLineBorder(new Color(100, 100, 100))); Utils.setComponentLocationOnCenter(this); setVisible(true); }
From source file:gov.nih.nci.nbia.StandaloneDMV3.java
JFrame showProgressForMac(String message) { JFrame f = new JFrame("Info"); f.setUndecorated(true);/* w ww . j av a 2s. co m*/ JPanel p = new JPanel(); p.setLayout(new BorderLayout()); JLabel waitInfo = new JLabel("Loading your data..."); waitInfo.setForeground(new Color(105, 105, 105)); waitInfo.setFont(new Font("Tahoma", Font.BOLD, 13)); waitInfo.setHorizontalAlignment(JLabel.CENTER); waitInfo.setVerticalAlignment(JLabel.CENTER); p.add(waitInfo, BorderLayout.CENTER); f.getContentPane().add(p); f.setSize(360, 40); f.setLocationRelativeTo(null); f.setVisible(true); return f; }
From source file:gov.nih.nci.nbia.StandaloneDMV3.java
private void setStatus(JLabel statusLbl, String msg, Color c) { statusLbl.setText(msg); statusLbl.setForeground(c); }
From source file:dk.dma.epd.common.prototype.gui.voct.VOCTAdditionalInfoPanel.java
/** * Updates the chat message panel in the Swing event thread *///from w w w. j a v a 2 s.co m public void updateChatMessagePanel() { // Ensure that we operate in the Swing event thread if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { updateChatMessagePanel(); } }); return; } // Only enable send-function when there is chat data, and hence a target addBtn.setEnabled(true); messageText.setEditable(true); // Remove all components from the messages panel messagesPanel.removeAll(); Insets insets = new Insets(0, 2, 2, 2); Insets insets2 = new Insets(6, 2, 0, 2); // if (chatData != null && chatData.getMessageCount() > 0) { // First, add a filler component int y = 0; messagesPanel.add(new JLabel(""), new GridBagConstraints(0, y++, 1, 1, 0.0, 1.0, NORTH, VERTICAL, insets, 0, 0)); // Add the messages long lastMessageTime = 0; long ownMMSI = MaritimeCloudUtils.toMmsi(EPD.getInstance().getMaritimeId()); for (VOCTSARInfoMessage message : EPD.getInstance().getVoctHandler().getAdditionalInformationMsgs()) { boolean ownMessage = false; if (message.getSender() == ownMMSI) { ownMessage = true; } // EPD.getInstance().getIdentityHandler().getActor(mmsi) // Check if we need to add a time label if (message.getDate() - lastMessageTime > PRINT_DATE_INTERVAL) { JLabel dateLabel = new JLabel(String.format(ownMessage ? "Added %s" : "Received %s", Formatter.formatShortDateTimeNoTz(new Date(message.getDate())))); dateLabel.setFont(dateLabel.getFont().deriveFont(9.0f).deriveFont(Font.PLAIN)); dateLabel.setHorizontalAlignment(SwingConstants.CENTER); dateLabel.setForeground(Color.LIGHT_GRAY); messagesPanel.add(dateLabel, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, NORTH, HORIZONTAL, insets2, 0, 0)); } // Add a chat message field JPanel msg = new JPanel(); msg.setBorder(new ChatMessageBorder(message, ownMessage)); JLabel msgLabel = new ChatMessageLabel(message.getMessage(), ownMessage); msg.add(msgLabel); messagesPanel.add(msg, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, NORTH, HORIZONTAL, insets, 0, 0)); lastMessageTime = message.getDate(); } // Scroll to the bottom validate(); scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum()); messagesPanel.repaint(); // } else if (chatData == null && noDataComponent != null) { // // The noDataComponent may e.g. be a message // messagesPanel.add(noDataComponent, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0)); // } }
From source file:ecg.ecgshow.ECGShowUI.java
private void createGuardData() { GuardDataPanel = new JPanel(); GuardDataPanel.setBackground(new Color(0, 150, 255)); // GuardDataPanel.setBounds(); // BoxLayout layout=new BoxLayout(GuardDataPanel,BoxLayout.Y_AXIS); // GuardDataPanel.setLayout(layout); GroupLayout layout = new GroupLayout(GuardDataPanel); GuardDataPanel.setLayout(layout);/*from www . j a v a 2 s . co m*/ JPanel temperatureData = new JPanel(); temperatureData.setLayout(new FlowLayout()); // temperatureData.setLayout(null); // temperatureData.setBounds(0,0,(int) (WIDTH * 0.14), (int) (HEIGHT * 0.15)); temperatureData.setSize((int) (WIDTH * 0.16), (int) (HEIGHT * 0.11)); temperatureData.setBackground(new Color(0, 150, 255)); temperatureLabel = new JLabel("--.- "); temperatureLabel.setFont(loadFont("LED.tff", (float) (HEIGHT * 0.070))); temperatureLabel.setBackground(new Color(0, 150, 255)); temperatureLabel.setForeground(Color.RED); // temperatureLabel.setBounds(0,0,200,100); temperatureLabel.setOpaque(true); JLabel temperatureLabelName = new JLabel(" "); temperatureLabelName.setFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.020))); temperatureLabelName.setBackground(new Color(0, 150, 255)); temperatureLabelName.setForeground(Color.BLACK); temperatureLabelName.setBounds(0, 0, 100, 100); temperatureLabelName.setOpaque(true); //?? temperatureData.add(temperatureLabelName); temperatureData.add(temperatureLabel); // JPanel emptyPanel=new JPanel(); // emptyPanel.setSize((int)(WIDTH*0.14),(int)(HEIGHT*0.2)); // emptyPanel.setBackground(new Color(0,150,255)); // GuardDataPanel.add(emptyPanel); JPanel lightValueData = new JPanel(); lightValueData.setLayout(new BorderLayout()); lightValueData.setBackground(new Color(0, 150, 255)); // lightValueData.setBounds(0,(int)(HEIGHT*0.28),(int)(WIDTH*0.14),(int)(HEIGHT*0.30)); lightValueData.setSize((int) (WIDTH * 0.14), (int) (HEIGHT * 0.22)); lightValueDataSet = new DefaultValueDataset(); DialPlot lightValueDialPlot = new DialPlot(); lightValueDialPlot.setDataset(lightValueDataSet); StandardDialFrame dialFrame = new StandardDialFrame(); dialFrame.setVisible(false); lightValueDialPlot.setDialFrame(dialFrame); GradientPaint gradientpaint = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(170, 170, 170)); DialBackground dialBackground = new DialBackground(gradientpaint); dialBackground.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL)); lightValueDialPlot.setBackground(dialBackground); // ?? DialTextAnnotation dialtextannotation = new DialTextAnnotation(""); dialtextannotation.setFont(new Font("Dialog", 0, (int) (0.016 * HEIGHT))); dialtextannotation.setRadius(0.1D); lightValueDialPlot.addLayer(dialtextannotation); DialValueIndicator dialValueIndicator = new DialValueIndicator(0); dialValueIndicator.setFont(new Font("Dialog", Font.PLAIN, (int) (0.011 * HEIGHT))); dialValueIndicator.setOutlinePaint(Color.darkGray); dialValueIndicator.setRadius(0.4D); dialValueIndicator.setAngle(-90.0); lightValueDialPlot.addLayer(dialValueIndicator); StandardDialScale dialScale = new StandardDialScale(); dialScale.setLowerBound(0D); // dialScale.setUpperBound(1024); // dialScale.setMajorTickIncrement(100); dialScale.setStartAngle(-120D); // 120,? dialScale.setExtent(-300D); // 300,? dialScale.setTickRadius(0.85D); // , dialScale.setTickLabelOffset(0.1D); // ,0 bloodDialRange = new StandardDialRange(500D, 750D, Color.red); bloodDialRange.setInnerRadius(0.52000000000000002D); bloodDialRange.setOuterRadius(0.55000000000000004D); lightValueDialPlot.addLayer(bloodDialRange); // bubbleDialRange = new StandardDialRange(0D, 500D, Color.black); bubbleDialRange.setInnerRadius(0.52000000000000002D); bubbleDialRange.setOuterRadius(0.55000000000000004D); lightValueDialPlot.addLayer(bubbleDialRange); // normalDialRange = new StandardDialRange(750D, 1024D, Color.green); normalDialRange.setInnerRadius(0.52000000000000002D); normalDialRange.setOuterRadius(0.55000000000000004D); lightValueDialPlot.addLayer(normalDialRange); dialScale.setTickLabelFont(new Font("Dialog", 0, (int) (0.011 * HEIGHT))); // lightValueDialPlot.addScale(0, dialScale); DialPointer.Pointer pointer = new DialPointer.Pointer(); lightValueDialPlot.addPointer(pointer); lightValueDialPlot.mapDatasetToScale(0, 0); DialCap dialCap = new DialCap(); dialCap.setRadius(0.07D); JFreeChart lightValueDialChart = new JFreeChart(lightValueDialPlot); lightValueDialChart.setBackgroundPaint(new Color(0, 150, 255)); lightValueDialChart.setTitle("??"); lightValueDialChart.getTitle().setFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.020))); ChartPanel lightValueDialChartPanel = new ChartPanel(lightValueDialChart, (int) (WIDTH * 0.15), (int) (HEIGHT * 0.27), 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false, true, false, false); lightValueData.add(lightValueDialChartPanel, BorderLayout.CENTER); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(temperatureData, GroupLayout.Alignment.LEADING) .addComponent(lightValueData, GroupLayout.Alignment.LEADING)))); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05)) .addComponent(temperatureData) .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05)) .addComponent(lightValueData) .addGap((int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05), (int) (HEIGHT * 0.05)))); // JPanel alarmMessage=new JPanel(); // alarmMessage.setBackground(new Color(0,150,255)); // alarmMessLabel=new JLabel(""); // alarmMessLabel.setFont(new Font("SansSerif", 0, (int)(HEIGHT *0.020))); // alarmMessLabel.setBackground(new Color(0,150,255)); // alarmMessage.add(alarmMessLabel); // GuardDataPanel.add(alarmMessage); }
From source file:com.francetelecom.rd.dashboard.pc.DashboardPC.java
private void initDashboardWithRules() { // get existing rules and display them try {// w ww. j a v a 2 s . c o m Rule[] ruleList = busConnector.getAllRules(); for (int i = 0; i < ruleList.length; i++) { if (!ruleList[i].isPrivate()) addRulePanelToDashboard(ruleList[i].getId()); } } catch (HomeBusException e) { logger.error("Could not retrieve bus rules : " + e.getMessage()); e.printStackTrace(); } // small add rule panel init JPanel panelAddRule = new JPanel(); panelAddRule.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); panelAddRule.setLayout(null); JLabel addRuleLbl = new JLabel("Configure new rule"); addRuleLbl.setHorizontalAlignment(SwingConstants.CENTER); addRuleLbl.setForeground(new Color(169, 169, 169)); addRuleLbl.setFont(new Font("Arial", Font.BOLD, 13)); addRuleLbl.setBounds(10, 25, 229, 27); panelAddRule.add(addRuleLbl); JButton addRuleBtn = new JButton("+"); addRuleBtn.setForeground(new Color(128, 128, 128)); addRuleBtn.setBounds(100, 57, 41, 23); panelAddRule.add(addRuleBtn); rulesContent.add(panelAddRule); myRulePanelMap.put("0", panelAddRule); updateRuleListDisplay(); // add panel elements : photo, service friendly name, IF label, condition parameter JPanel panelRule1 = new JPanel(); panelRule1.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); panelRule1.setLayout(null); JPanel rulePanelServicePhoto1 = new JPanel(); rulePanelServicePhoto1.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); rulePanelServicePhoto1.setBounds(10, 16, 27, 27); panelRule1.add(rulePanelServicePhoto1); String serviceName1 = "Visio TV"; JLabel ruleLblServiceName1 = new JLabel(serviceName1); ruleLblServiceName1.setFont(new Font("Arial", Font.BOLD, 15)); ruleLblServiceName1.setForeground(new Color(100, 149, 237)); ruleLblServiceName1.setBounds(47, 11, 212, 18); panelRule1.add(ruleLblServiceName1); String serviceDeviceOwner1 = "Set-top Box"; JLabel ruleLblOnDevice1 = new JLabel("on " + serviceDeviceOwner1); ruleLblOnDevice1.setForeground(Color.GRAY); ruleLblOnDevice1.setFont(new Font("Arial", Font.PLAIN, 11)); ruleLblOnDevice1.setBounds(47, 29, 212, 14); panelRule1.add(ruleLblOnDevice1); JLabel ruleLblIf1 = new JLabel("IF"); ruleLblIf1.setForeground(Color.GRAY); ruleLblIf1.setFont(new Font("Arial", Font.BOLD, 30)); ruleLblIf1.setBounds(10, 49, 27, 35); panelRule1.add(ruleLblIf1); // condition String condition1 = "IncomingVoIP" + " = " + "true"; JLabel ruleLblConditionParam1 = new JLabel(condition1); ruleLblConditionParam1.setFont(new Font("Arial", Font.BOLD, 13)); ruleLblConditionParam1.setForeground(Color.GRAY); ruleLblConditionParam1.setBounds(47, 49, 192, 35); panelRule1.add(ruleLblConditionParam1); myRulePanelMap.put("1", panelRule1); rulesContent.add(panelRule1); // add panel elements : photo, service friendly name, IF label, condition parameter JPanel panelRule2 = new JPanel(); panelRule2.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); panelRule2.setLayout(null); JPanel rulePanelServicePhoto2 = new JPanel(); rulePanelServicePhoto2.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); rulePanelServicePhoto2.setBounds(10, 16, 27, 27); panelRule2.add(rulePanelServicePhoto2); String serviceName2 = "Wi-Fi Off"; JLabel ruleLblServiceName2 = new JLabel(serviceName2); ruleLblServiceName2.setFont(new Font("Arial", Font.BOLD, 15)); ruleLblServiceName2.setForeground(new Color(100, 149, 237)); ruleLblServiceName2.setBounds(47, 11, 212, 18); panelRule2.add(ruleLblServiceName2); String serviceDeviceOwner2 = "Livebox"; JLabel ruleLblOnDevice2 = new JLabel("on " + serviceDeviceOwner2); ruleLblOnDevice2.setForeground(Color.GRAY); ruleLblOnDevice2.setFont(new Font("Arial", Font.PLAIN, 11)); ruleLblOnDevice2.setBounds(47, 29, 212, 14); panelRule2.add(ruleLblOnDevice2); JLabel ruleLblIf2 = new JLabel("IF"); ruleLblIf2.setForeground(Color.GRAY); ruleLblIf2.setFont(new Font("Arial", Font.BOLD, 30)); ruleLblIf2.setBounds(10, 49, 27, 35); panelRule2.add(ruleLblIf2); // condition String condition2 = "Absence" + " = " + "true"; JLabel ruleLblConditionParam2 = new JLabel(condition2); ruleLblConditionParam2.setFont(new Font("Arial", Font.BOLD, 13)); ruleLblConditionParam2.setForeground(Color.GRAY); ruleLblConditionParam2.setBounds(47, 49, 192, 35); panelRule2.add(ruleLblConditionParam2); myRulePanelMap.put("2", panelRule2); rulesContent.add(panelRule2); updateRuleListDisplay(); busConnector.addRuleDefinitionsListener(this); }
From source file:lol.search.RankedStatsPage.java
private void totalJLabel(JLabel label, String text, Color color) { label.setText(text);// www . j a v a 2 s . c o m label.setForeground(color); label.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 16)); //custom font }
From source file:com.francetelecom.rd.dashboard.pc.DashboardPC.java
private void addRulePanelToDashboard(String ruleId) { if (myRulePanelMap.containsKey(ruleId)) { // remove it from display as it will be redisplayed rulesContent.remove(myRulePanelMap.remove(ruleId)); }/* www . ja va2 s . c o m*/ Rule newRule; try { newRule = busConnector.getRule(ruleId); } catch (Exception e) { logger.error("Could not get new rule (" + ruleId + ") from bus connector! \n" + e.getMessage() + "Will not display new rule"); e.printStackTrace(); return; } // add panel elements : photo, service friendly name, IF label, condition parameter JPanel panelRule = new JPanel(); panelRule.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); panelRule.setLayout(null); JPanel rulePanelServicePhoto = new JPanel(); rulePanelServicePhoto.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); rulePanelServicePhoto.setBounds(10, 16, 27, 27); panelRule.add(rulePanelServicePhoto); String serviceName = ""; String serviceDeviceOwner = ""; try { String serviceId = newRule.getServiceReference(); NodeService ns = busConnector.getNodeService(serviceId); serviceName = ns.getName(); serviceDeviceOwner = busConnector.getServiceOwner(serviceId).getName(); } catch (Exception e) { logger.error("Error when getting new rule's service name! \n" + e.getMessage()); e.printStackTrace(); } JLabel ruleLblServiceName = new JLabel(serviceName); ruleLblServiceName.setFont(new Font("Arial", Font.BOLD, 15)); ruleLblServiceName.setForeground(new Color(100, 149, 237)); ruleLblServiceName.setBounds(47, 11, 212, 18); panelRule.add(ruleLblServiceName); JLabel ruleLblOnDevice = new JLabel("on " + serviceDeviceOwner); ruleLblOnDevice.setForeground(Color.GRAY); ruleLblOnDevice.setFont(new Font("Arial", Font.PLAIN, 11)); ruleLblOnDevice.setBounds(47, 29, 212, 14); panelRule.add(ruleLblOnDevice); JLabel ruleLblIf = new JLabel("IF"); ruleLblIf.setForeground(Color.GRAY); ruleLblIf.setFont(new Font("Arial", Font.BOLD, 30)); ruleLblIf.setBounds(10, 49, 27, 35); panelRule.add(ruleLblIf); // condition Condition c = newRule.getCondition(); // condition resource String[] resource = c.getResourcePath().split("\\."); // condition operator String operator = ""; switch (c.getOperator()) { case Condition.OPERATOR_DIFF: { operator = "!="; break; } case Condition.OPERATOR_EQUAL: { operator = "="; break; } case Condition.OPERATOR_INF: { operator = "<"; break; } case Condition.OPERATOR_INFEQUAL: { operator = "<="; break; } case Condition.OPERATOR_SUP: { operator = ">"; break; } case Condition.OPERATOR_SUPEQUAL: { operator = ">="; break; } default: { logger.error("Unknown condition operator " + c.getOperator()); break; } } // condition target value // FIXME the target value type is an int, that corresponds to static // parameters from SDS that we dont have in Hlc // must find a way to make the types constants be available in Hlc // temporary solution : declared here String targetValue = ""; switch (c.getTargetValueType()) { case TYPE_BOOL: { targetValue = String.valueOf(c.getTargetBooleanValue()); break; } case TYPE_INT: { targetValue = String.valueOf(c.getTargetIntValue()); break; } case TYPE_STRING: { targetValue = String.valueOf(c.getTargetStringValue()); break; } default: { logger.warn("Attention target value type " + c.getTargetValueType() + " not treated!"); break; } } String condition = resource[(resource.length - 1)] + " " + operator + " " + targetValue; JLabel ruleLblConditionParam = new JLabel(condition); ruleLblConditionParam.setFont(new Font("Arial", Font.BOLD, 13)); ruleLblConditionParam.setForeground(Color.GRAY); ruleLblConditionParam.setBounds(47, 49, 192, 35); panelRule.add(ruleLblConditionParam); myRulePanelMap.put(ruleId, panelRule); rulesContent.add(panelRule); updateRuleListDisplay(); }