List of usage examples for javax.swing JLabel setFont
@BeanProperty(preferred = true, visualUpdate = true, description = "The font for the component.") public void setFont(Font font)
From source file:ComplexCellRenderer.java
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Font theFont = null;/*from w w w . j a v a 2 s . co m*/ Color theForeground = null; Icon theIcon = null; String theText = null; JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof Object[]) { Object values[] = (Object[]) value; theFont = (Font) values[0]; theForeground = (Color) values[1]; theIcon = (Icon) values[2]; theText = (String) values[3]; } else { theFont = list.getFont(); theForeground = list.getForeground(); theText = ""; } if (!isSelected) { renderer.setForeground(theForeground); } if (theIcon != null) { renderer.setIcon(theIcon); } renderer.setText(theText); renderer.setFont(theFont); return renderer; }
From source file:cs.gui.stats.PerformanceStats.java
public JPanel buildPlotDisplayManagementPanel(ValueAxis valueAxis, DateAxis dateAxis, JComboBox ddlScope) { JPanel panel = new JPanel(new FlowLayout()); JLabel lblDisplayScope = new JLabel("Time Range:"); ddlScope = fillScopeDDL(ddlScope);//from ww w .j a va 2 s . com lblDisplayScope.setFont(new Font("Italic", 1, 10)); ddlScope.setFont(new Font("Italic", 1, 10)); panel.add(lblDisplayScope); panel.add(ddlScope); ddlScope.addActionListener(new ComboBoxListener(valueAxis, dateAxis)); return panel; }
From source file:ecg.ecgshow.ECGShowUI.java
private void createHeartRateData(long timeZone) { HeartRatedatas = new short[2]; HeartRateData = new JPanel(); //HeartRateData.setLayout(new BorderLayout()); HeartRateData.setLayout(new FlowLayout()); HeartRateData.setBounds(0, 0, (int) (WIDTH * 0.14), (int) (HEIGHT * 0.15)); HeartRateData.setBackground(Color.BLACK); JLabel jLabel1 = new JLabel("---"); if (HeartRatedatas[0] == 0x00 || HeartRatedatas == null) { jLabel1.setText("---"); } else {/*w ww .ja v a2 s . c o m*/ jLabel1.setText(Short.toString((short) HeartRatedatas[0])); } jLabel1.setFont(loadFont("LED.tff", (float) (HEIGHT * 0.070))); jLabel1.setBackground(Color.BLACK); jLabel1.setForeground(Color.GREEN); jLabel1.setBounds(0, 0, 100, 100); jLabel1.setOpaque(true); //?? JLabel jLabelName = new JLabel(" "); jLabelName.setFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.020))); jLabelName.setBackground(Color.BLACK); jLabelName.setForeground(new Color(237, 65, 43)); jLabelName.setBounds(0, 0, 100, 100); jLabelName.setOpaque(true); //?? JLabel jLabelUnit = new JLabel(" bpm"); jLabelUnit.setFont(new Font("SansSerif", 0, (int) (HEIGHT * 0.020))); jLabelUnit.setBackground(Color.BLACK); jLabelUnit.setForeground(Color.GREEN); jLabelUnit.setBounds(0, 0, 100, 100); jLabelUnit.setOpaque(true); //?? HeartRateData.add(jLabelName); HeartRateData.add(jLabel1); HeartRateData.add(jLabelUnit); System.out.println("HeartRatedatas" + Short.toString(HeartRatedatas[0])); ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { if (HeartRatedatas[0] == -100 || HeartRatedatas[0] == 156 || HeartRatedatas[0] == 0) { jLabel1.setText("--"); } else { jLabel1.setText(String.valueOf(HeartRatedatas[0])); } HeartRateData.repaint(); } }, 0, 3, TimeUnit.SECONDS); }
From source file:multiplayer.pong.client.LobbyFrame.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.//from www .ja v a 2 s. c om */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jScrollPane2 = new javax.swing.JScrollPane(); jScrollPane2.setBackground(Color.WHITE); usernamesT = new javax.swing.JTable(); usernamesT.setBackground(Color.WHITE); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setBackground(new java.awt.Color(0, 0, 0)); usernamesT.setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null }, { null }, { null }, { null } }, new String[] { "Username" }) { boolean[] canEdit = new boolean[] { false }; public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); usernamesT.setGridColor(new java.awt.Color(0, 0, 0)); usernamesT.setInheritsPopupMenu(true); jScrollPane2.setViewportView(usernamesT); if (usernamesT.getColumnModel().getColumnCount() > 0) { usernamesT.getColumnModel().getColumn(0).setResizable(false); } JLabel lblUtilisateursEnligne = new JLabel("Utilisateurs en-ligne"); lblUtilisateursEnligne.setForeground(new Color(255, 255, 255)); lblUtilisateursEnligne.setFont(new Font("Trebuchet MS", Font.PLAIN, 14)); commandBtn = new JButton("Envoyer"); commandBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { commandBtnActionPerformed(e); } }); JLabel lblLobbyPrincipal = new JLabel("Lobby Principal"); lblLobbyPrincipal.setFont(new Font("Georgia", Font.PLAIN, 70)); lblLobbyPrincipal.setForeground(new Color(255, 255, 255)); lblLobbyPrincipal.setBackground(new Color(0, 0, 0)); scrollPane = new JScrollPane(); scrollPane.setBackground(Color.WHITE); cmdPrompt = new JTextField(); cmdPrompt.setColumns(10); cmdPrompt.grabFocus(); scrollPane_1 = new JScrollPane(); lblWelcome = new JLabel("Bienvenue, " + SocketHandler.username); lblWelcome.setHorizontalAlignment(SwingConstants.RIGHT); lblWelcome.setFont(new Font("Georgia", Font.PLAIN, 18)); lblWelcome.setForeground(Color.WHITE); JLabel label = new JLabel("Amis connect\u00E9s"); label.setForeground(Color.WHITE); label.setFont(new Font("Trebuchet MS", Font.PLAIN, 14)); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout .createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(Alignment.LEADING) .addComponent(scrollPane_1, GroupLayout.PREFERRED_SIZE, 605, GroupLayout.PREFERRED_SIZE) .addComponent(cmdPrompt, 605, 605, 605)) .addPreferredGap(ComponentPlacement.RELATED)) .addGroup(layout.createSequentialGroup() .addComponent(lblLobbyPrincipal, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(120))) .addGroup(layout.createParallelGroup(Alignment.TRAILING) .addComponent(lblUtilisateursEnligne, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE) .addGroup(Alignment.LEADING, layout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED) .addComponent(lblWelcome, GroupLayout.PREFERRED_SIZE, 160, GroupLayout.PREFERRED_SIZE)) .addComponent(commandBtn, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED) .addComponent(label, GroupLayout.PREFERRED_SIZE, 169, GroupLayout.PREFERRED_SIZE)) .addGroup(Alignment.LEADING, layout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED) .addComponent(jScrollPane2, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)) .addGroup(Alignment.LEADING, layout.createSequentialGroup().addPreferredGap(ComponentPlacement.UNRELATED) .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE))) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout .createSequentialGroup().addContainerGap() .addGroup(layout.createParallelGroup(Alignment.TRAILING).addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(Alignment.LEADING) .addComponent(lblLobbyPrincipal, GroupLayout.PREFERRED_SIZE, 85, GroupLayout.PREFERRED_SIZE) .addComponent(lblWelcome, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(layout.createParallelGroup(Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 164, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(lblUtilisateursEnligne, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(jScrollPane2, GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)) .addComponent(scrollPane_1, GroupLayout.DEFAULT_SIZE, 432, Short.MAX_VALUE)) .addGap(9) .addGroup( layout.createParallelGroup(Alignment.BASELINE) .addComponent(cmdPrompt, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE) .addComponent(commandBtn)) .addGap(22)) .addGroup(layout.createSequentialGroup() .addComponent(label, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addGap(492))))); ta = new JTextPane(); ta.setEditable(false); ta.setFont(new Font("SansSerif", Font.PLAIN, 14)); scrollPane_1.setViewportView(ta); friendsT = new JTable(); friendsT.setModel(new DefaultTableModel(new Object[][] {}, new String[] { "Username" })); scrollPane.setViewportView(friendsT); getContentPane().setLayout(layout); pack(); }
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)); }/*from ww w . j a va 2s . 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(); }
From source file:dk.dma.epd.common.prototype.gui.notification.ChatServicePanel.java
/** * Updates the chat message panel in the Swing event thread *///w w w .java2s.c o 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; } // Set the title header titleHeader.setText(chatData != null ? NameUtils.getName(chatData.getId(), NameFormat.MEDIUM) : " "); titleHeader.setVisible(chatData != null); // Only enable send-function when there is chat data, and hence a target sendBtn.setEnabled(chatData != null); messageText.setEditable(chatData != null); // 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; for (EPDChatMessage message : chatData.getMessages()) { // Check if we need to add a time label if (message.getSendDate().getTime() - lastMessageTime > PRINT_DATE_INTERVAL) { JLabel dateLabel = new JLabel( String.format(message.isOwnMessage() ? "Sent to %s" : "Received %s", Formatter.formatShortDateTimeNoTz(new Date(message.getSendDate().getTime())))); 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)); JLabel msgLabel = new ChatMessageLabel(message.getMsg(), message.isOwnMessage()); msg.add(msgLabel); messagesPanel.add(msg, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, NORTH, HORIZONTAL, insets, 0, 0)); lastMessageTime = message.getSendDate().getTime(); } // 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:gov.nih.nci.nbia.StandaloneDMV3.java
JFrame showProgressForMac(String message) { JFrame f = new JFrame("Info"); f.setUndecorated(true);/*w w w . j a v a 2 s. c o 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:analisis_proyecto1.Ventana_principal.java
private void jButton4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton4MouseClicked //Generando el arreglo visual de numeros this.HeapSort.setVisible(false); heap.setTitle("Laurenn Alecxandra Cruz| 11211190"); heap.setSize(900, 500);/*from www .j ava2s .c om*/ heap.setVisible(true); JLabel titulo = new JLabel("Arreglo Inicial: "); titulo.setFont(new Font("Consolas", Font.BOLD, 14)); Panelarreglo.add(titulo); this.panelgenera.setForeground(Color.cyan); JButton[] arreglo = new JButton[this.heap_sort_numbers.size()]; for (int i = 0; i < this.heap_sort_numbers.size(); i++) { arreglo[i] = new JButton(); arreglo[i].setText(Integer.toString(this.heap_sort_numbers.get(i))); arreglo[i].setBackground(Color.GREEN); Panelarreglo.add(arreglo[i]); } int[] array = new int[this.heap_sort_numbers.size()]; //convierte ArreyList a arreglo for (int i = 0; i < this.heap_sort_numbers.size(); i++) { array[i] = this.heap_sort_numbers.get(i); } //LLamado a la funcion Heapsort Heapsort ordenamiento = new Heapsort(array); ordenamiento.ordenar(); this.arboles = ordenamiento.getArbolesDelegate(); //Visualizacion del arbol //---------------------Antes---------------------- JButton preview = new JButton("Antes"); preview.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int x = IncrementarIndice(1); if (x >= 0) { if (vs != null) { PanelArbol.remove(vs); } //-----------Dibujar arbol--------- vs = new BasicVisualizationServer<String, String>( new TreeLayout<String, String>(arboles.get(x)), new Dimension(300, 300)); Transformer<String, Paint> vertexPaint = new Transformer<String, Paint>() { public Paint transform(String i) { return Color.GREEN; } }; RenderContext<String, String> renderContext = vs.getRenderContext(); renderContext.setVertexFillPaintTransformer(vertexPaint); Transformer<String, String> transformer = new ToStringLabeller<String>(); renderContext.setEdgeLabelTransformer(transformer); Transformer<String, String> vertexTransformer = new ToStringLabeller<String>(); renderContext.setVertexLabelTransformer(vertexTransformer); vs.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); PanelArbol.add(vs); PanelArbol.updateUI(); } else { indice = 0; } } }); //-------------------Despues------------------------ JButton next = new JButton("Siguiente"); next.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int x = IncrementarIndice(0); if (x < arboles.size()) { if (vs != null) { PanelArbol.remove(vs); } //-----------Dibujar arbol--------- vs = new BasicVisualizationServer<String, String>( new TreeLayout<String, String>(arboles.get(x)), new Dimension(250, 250)); Transformer<String, Paint> vertexPaint = new Transformer<String, Paint>() { public Paint transform(String i) { return Color.GREEN; } }; RenderContext<String, String> renderContext = vs.getRenderContext(); renderContext.setVertexFillPaintTransformer(vertexPaint); Transformer<String, String> transformer = new ToStringLabeller<String>(); renderContext.setEdgeLabelTransformer(transformer); Transformer<String, String> vertexTransformer = new ToStringLabeller<String>(); renderContext.setVertexLabelTransformer(vertexTransformer); vs.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); PanelArbol.add(vs); PanelArbol.updateUI(); heap.repaint(); } else { indice = arboles.size() - 1; } } }); //---------------Terminar accion-------------------------- JButton terminar = new JButton("Salir"); terminar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { heap_sort_numbers = new ArrayList(); arboles = new ArrayList(); indice = -1; PanelArbol = new JPanel(); grid = new GridLayout(2, 0); flow = new FlowLayout(); panelgenera = new JPanel(grid); Panelarreglo = new JPanel(flow); heap.dispose(); HeapSort.dispose(); heap = new JFrame(); heap.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); } }); next.setBackground(Color.BLUE); preview.setBackground(Color.BLUE); terminar.setBackground(Color.BLUE); Panelarreglo.add(preview); Panelarreglo.add(next); Panelarreglo.add(terminar); this.panelgenera.add(Panelarreglo); this.panelgenera.add(PanelArbol); this.heap.add(panelgenera); heap.repaint(); paintComponents(getGraphics()); this.heap.setVisible(true); }
From source file:com.eviware.soapui.support.components.SimpleForm.java
/** * Appends a heading with bold text that streches from the default label column to the end of the form * * @param text The text of the heading//w w w . j a v a 2 s . c om */ public void appendHeading(String text) { JLabel label = new JLabel(text); Font font = label.getFont(); Font fontBold = new Font(font.getName(), Font.BOLD, font.getSize()); label.setFont(fontBold); append(null, null, label, null, DEFAULT_LABEL_COLUMN, getColumnSpanToTheEnd(DEFAULT_LABEL_COLUMN)); }