List of usage examples for javax.swing JLabel setOpaque
@BeanProperty(expert = true, description = "The component's opacity") public void setOpaque(boolean isOpaque)
From source file:HeaderDemo.java
public HeaderDemo() { super("JScrollPane Demo"); JScrollPane scrollPane = new JScrollPane(label); JLabel[] corners = new JLabel[4]; for (int i = 0; i < 4; i++) { corners[i] = new JLabel(); corners[i].setBackground(Color.white); corners[i].setOpaque(true);// w w w. j av a2 s .co m } JLabel rowheader = new JLabel() { public void paintComponent(Graphics g) { super.paintComponent(g); Rectangle rect = g.getClipBounds(); for (int i = 50 - (rect.y % 50); i < rect.height; i += 50) { g.drawLine(0, rect.y + i, 3, rect.y + i); g.drawString("" + (rect.y + i), 6, rect.y + i + 3); } } public Dimension getPreferredSize() { return new Dimension(25, (int) label.getPreferredSize().getHeight()); } }; rowheader.setBackground(Color.white); rowheader.setOpaque(true); JLabel columnheader = new JLabel() { public void paintComponent(Graphics g) { super.paintComponent(g); Rectangle r = g.getClipBounds(); for (int i = 50 - (r.x % 50); i < r.width; i += 50) { g.drawLine(r.x + i, 0, r.x + i, 3); g.drawString("" + (r.x + i), r.x + i - 10, 16); } } public Dimension getPreferredSize() { return new Dimension((int) label.getPreferredSize().getWidth(), 25); } }; columnheader.setBackground(Color.white); columnheader.setOpaque(true); scrollPane.setRowHeaderView(rowheader); scrollPane.setColumnHeaderView(columnheader); scrollPane.setCorner(JScrollPane.LOWER_LEFT_CORNER, corners[0]); scrollPane.setCorner(JScrollPane.LOWER_RIGHT_CORNER, corners[1]); scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, corners[2]); scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, corners[3]); getContentPane().add(scrollPane); setSize(400, 300); setVisible(true); }
From source file:es.urjc.ia.fia.genericSearch.statistics.JUNGStatistics.java
@Override public void showStatistics() { // Layout: tree and radial treeLayout = new TreeLayout<AuxVertex, ACTION>(this.tree, 35, 100); radialLayout = new RadialTreeLayout<AuxVertex, ACTION>(this.tree, 35, 130); radialLayout.setSize(new Dimension(200 * (this.tree.getHeight() + 1), 200 * (this.tree.getHeight() + 1))); // The BasicVisualizationServer<V,E> is parameterized by the edge types vv = new VisualizationViewer<AuxVertex, ACTION>(treeLayout); vv.setPreferredSize(new Dimension(800, 600)); //Sets the viewing area size vv.setBackground(Color.white); // Background color vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<AuxVertex>()); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<AuxVertex, ACTION>()); // Setup up a new vertex to paint transformer Transformer<AuxVertex, Paint> vertexPaint = new Transformer<AuxVertex, Paint>() { @Override//from w w w.j a v a2 s . c om public Paint transform(AuxVertex arg0) { if (arg0.getState().isSolution() && arg0.isExplored()) { return Color.GREEN; } else if (arg0.isExplored()) { return Color.CYAN; } else if (arg0.isDuplicated()) { return Color.GRAY; } else { return Color.WHITE; } } }; // Tooltip for vertex Transformer<AuxVertex, String> toolTipsState = new Transformer<AuxVertex, String>() { @Override public String transform(AuxVertex arg0) { String sortInfo = ""; if (arg0.isExplored()) { if (arg0.getState().isSolution() && arg0.isExplored()) { sortInfo = "<u><i>Solution state " + arg0.getExplored() + "</i></u>"; } else { sortInfo = "<u><i>Explored state " + arg0.getExplored() + "</i></u>"; } } else if (arg0.isDuplicated()) { sortInfo = "<u><i>Duplicated state </i></u>"; } else { sortInfo = "<u><i>Unexplored state</i></u>"; } return "<html><p>" + sortInfo + "</p>" + "<p>State: " + arg0.getState().toString() + "</p>" + "<p>Cost: " + arg0.getState().getSolutionCost() + "</p></html>"; } }; vv.setVertexToolTipTransformer(toolTipsState); // Tooltip for edge Transformer<ACTION, String> toolTipsAction = new Transformer<ACTION, String>() { @Override public String transform(ACTION arg0) { return "Cost: " + arg0.cost(); } }; vv.setEdgeToolTipTransformer(toolTipsAction); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<AuxVertex, ACTION>()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<ACTION>()); vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); // Create a graph mouse and add it to the visualization component DefaultModalGraphMouse<State<ACTION>, ACTION> gm = new DefaultModalGraphMouse<State<ACTION>, ACTION>(); gm.setMode(ModalGraphMouse.Mode.TRANSFORMING); vv.setGraphMouse(gm); vv.addKeyListener(gm.getModeKeyListener()); JFrame vFrame = new JFrame("Statistics Tree View"); vFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); /* vFrame.getContentPane().add(vv); vFrame.pack(); vFrame.setVisible(true); */ rings = new Rings(); Container content = vFrame.getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); JComboBox modeBox = gm.getModeComboBox(); modeBox.addItemListener(gm.getModeListener()); gm.setMode(ModalGraphMouse.Mode.TRANSFORMING); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JToggleButton radial = new JToggleButton("Radial"); radial.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { LayoutTransition<AuxVertex, ACTION> lt = new LayoutTransition<AuxVertex, ACTION>(vv, treeLayout, radialLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.addPreRenderPaintable(rings); } else { LayoutTransition<AuxVertex, ACTION> lt = new LayoutTransition<AuxVertex, ACTION>(vv, radialLayout, treeLayout); Animator animator = new Animator(lt); animator.start(); vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.removePreRenderPaintable(rings); } vv.repaint(); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); /* * Statistics */ JLabel stats = new JLabel(); long totalTime = endTime.getTime() - initTime.getTime(); stats.setText("<html>" + "<b>Total States:</b> " + this.totalStates + "<br>" + "<b>Explored States:</b> " + this.explorerStates + "<br>" + "<b>Duplicated States (detected):</b> " + this.duplicatedStates + "<br>" + "<b>Solution States:</b> " + this.solutionStates + "<br>" + "<b>Total time: </b>" + totalTime + " milliseconds" + "</html>"); JPanel legend = new JPanel(); legend.setLayout(new BoxLayout(legend, BoxLayout.Y_AXIS)); JLabel len = new JLabel("<html><b>Lengend</b></html>"); JLabel lexpl = new JLabel("Explored state"); lexpl.setBackground(Color.CYAN); lexpl.setOpaque(true); JLabel lune = new JLabel("Unexplored state"); lune.setBackground(Color.WHITE); lune.setOpaque(true); JLabel ldupl = new JLabel("Duplicated state"); ldupl.setBackground(Color.GRAY); ldupl.setOpaque(true); JLabel lsol = new JLabel("Solution state"); lsol.setBackground(Color.GREEN); lsol.setOpaque(true); legend.add(len); legend.add(lexpl); legend.add(lune); legend.add(ldupl); legend.add(lsol); JPanel controls = new JPanel(); controls.add(stats); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(radial); controls.add(scaleGrid); //controls.add(modeBox); controls.add(legend); content.add(controls, BorderLayout.SOUTH); vFrame.pack(); vFrame.setVisible(true); }
From source file:ca.phon.app.session.editor.view.segmentation.SegmentationEditorView.java
private void updateParticipantPanel() { participantPanel.removeAll();/*from w ww . j av a 2 s . co m*/ // setup layout String colLayout = "fill:default"; String rowLayout = "pref, 5px"; for (int i = 0; i <= getEditor().getSession().getParticipantCount(); i++) { rowLayout += ", pref, 5px"; } FormLayout layout = new FormLayout(colLayout, rowLayout); participantPanel.setLayout(layout); CellConstraints cc = new CellConstraints(); int currentRow = 1; String ksStr = (OSInfo.isMacOs() ? "\u2318" : "CTRL +") + "0"; PhonUIAction noPartSegmentAct = new PhonUIAction(this, "performSegmentation", null); noPartSegmentAct.putValue(Action.NAME, ksStr + " speaker undefined"); // setup labels to be used like buttons String segMsg = "Click name to create a new record:"; JLabel segLbl = new JLabel(segMsg); participantPanel.add(segLbl, cc.xy(1, currentRow)); currentRow += 2; JLabel noPartLbl = new JLabel(); String noPartMsg = ksStr + " <no speaker>"; noPartLbl.setText(noPartMsg); noPartLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); noPartLbl.addMouseListener(new SegmentLabelMouseHandler()); noPartLbl.setOpaque(false); participantPanel.add(noPartLbl, cc.xy(1, currentRow)); currentRow += 2; final Session session = getEditor().getSession(); int pIdx = 1; for (Participant p : session.getParticipants()) { ksStr = (OSInfo.isMacOs() ? "\u2318" : "CTRL +") + pIdx; final NewSegmentAction segmentAction = new NewSegmentAction(getEditor(), this, p); segmentAction.putValue(Action.NAME, ksStr + " " + p.toString()); JLabel participantLbl = new JLabel(); String participantStr = ksStr + " " + (p.getName() != null ? p.getName() : p.getId()); participantLbl.setText(participantStr); participantLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); participantLbl.addMouseListener(new SegmentLabelMouseHandler(p)); participantLbl.setOpaque(false); participantPanel.add(participantLbl, cc.xy(1, currentRow)); currentRow += 2; pIdx++; } }
From source file:edu.ku.brc.af.ui.forms.formatters.DataObjAggregatorDlg.java
@Override public void createUI() { super.createUI(); isNew = StringUtils.isEmpty(selectedAggregator.getName()); validator.setNewObj(isNew);/*from w w w . ja va 2 s . c o m*/ CellConstraints cc = new CellConstraints(); // panel for aggregator editing controls // display combobox with available data obj formatters PanelBuilder displayPB = new PanelBuilder(new FormLayout("f:p:g,min", "p")); displayCbo = createComboBox(); JButton displayDlgBtn = createButton("..."); displayPB.add(displayCbo, cc.xy(1, 1)); displayPB.add(displayDlgBtn, cc.xy(2, 1)); fieldOrderCbo = createComboBox(); ActionListener displayDlgBtnAL = new ActionListener() { public void actionPerformed(ActionEvent e) { // subtract 1 from selected index to account for empty entry at the beginning // if selected index is zero, then select "new" entry in the dialog, which is the last one boolean newFormatter; DataObjSwitchFormatter dosf; if (displayCbo.getSelectedIndex() == 0) { // no formatter selected: create a new one and pass it to the dialog so the user can edit it newFormatter = true; dosf = new DataObjSwitchFormatter(null, null, true, false, tableInfo.getClassObj(), ""); } else { // pass selected formatter to the dialog so the user can edit it newFormatter = false; dosf = (DataObjSwitchFormatter) displayCbo.getSelectedItem(); } DataObjFieldFormatDlg dlg = new DataObjFieldFormatDlg(null, tableInfo, dataObjFieldFormatMgrCache, uiFieldFormatterMgrCache, dosf); dlg.createUI(); if (dlg.isEditable()) { dlg.setVisible(true); // set combo selection to formatter selected in dialog if (dlg.getBtnPressed() == OK_BTN) { selectedAggregator.setFormatName(dosf.getName()); if (newFormatter) { // must add new DO formatter and then select it dataObjFieldFormatMgrCache.addFormatter(dosf); } // update the display combo, adding the new formatter and selecting it // if that's the case updateDisplayCombo(); } } } }; displayDlgBtn.addActionListener(displayDlgBtnAL); // text fields titleText = new ValTextField(10); nameText = new ValTextField(10) { @Override public ErrorType validateState() { ErrorType state = super.validateState(); if (state == ErrorType.Valid) { return isNameInError ? ErrorType.Error : ErrorType.Valid; } return state; } }; sepText = new ValTextField(10); endingText = new ValTextField(10); countSpinner = new ValSpinner(0, 10, true, false); countSpinner.setValue(0); JButton valBtn = FormViewObj.createValidationIndicator(this, validator); PanelBuilder valInfoBtnPB = new PanelBuilder(new FormLayout("f:p:g,p", "p")); valInfoBtnPB.add(valBtn, cc.xy(2, 1)); validator.setValidationBtn(valBtn); PanelBuilder pb = new PanelBuilder( new FormLayout("r:p,2px,p,f:p:g", UIHelper.createDuplicateJGoodiesDef("p", "2px", 11))); int y = 1; JLabel tableTitleLbl = createI18NFormLabel("FFE_TABLE"); JLabel tableTitleValueLbl = createLabel(tableInfo.getTitle()); tableTitleValueLbl.setBackground(Color.WHITE); tableTitleValueLbl.setOpaque(true); pb.add(tableTitleLbl, cc.xy(1, y)); pb.add(tableTitleValueLbl, cc.xyw(3, y, 2)); y += 2; pb.addSeparator(" ", cc.xyw(1, y, 3)); y += 2; pb.add(createI18NFormLabelBold("DOA_NAME"), cc.xy(1, y)); add(pb, nameText, "DOA_NAME", "DOA_NAME.getText().length() > 0", cc.xyw(3, y, 2)); y += 2; pb.add(createI18NFormLabelBold("DOA_TITLE"), cc.xy(1, y)); add(pb, titleText, "DOA_TITLE", "DOA_TITLE.getText().length() > 0", cc.xyw(3, y, 2)); y += 2; pb.add(createI18NFormLabelBold("DOA_DISPLAY"), cc.xy(1, y)); pb.add(displayPB.getPanel(), cc.xyw(3, y, 2)); y += 2; pb.add(createI18NFormLabelBold("DOA_SEP"), cc.xy(1, y)); add(pb, sepText, "DOA_SEP", "DOA_SEP.getText().length() > 0", cc.xyw(3, y, 2)); y += 2; pb.add(createI18NFormLabelBold("DOA_COUNT"), cc.xy(1, y)); add(pb, countSpinner, "DOA_COUNT", null, cc.xyw(3, y, 2)); y += 2; pb.add(createI18NFormLabel("DOA_ENDING"), cc.xy(1, y)); add(pb, endingText, "DOA_ENDING", "DOA_ENDING.getText().length() > 0", cc.xyw(3, y, 2)); y += 2; pb.add(createI18NFormLabel("DOA_SORT_BY"), cc.xy(1, y)); add(pb, fieldOrderCbo, "DOA_DEFAULT", null, cc.xy(3, y)); y += 2; pb.add(valInfoBtnPB.getPanel(), cc.xyw(3, y, 2)); y += 2; pb.setBorder(BorderFactory.createEmptyBorder(14, 14, 0, 14)); contentPanel = pb.getPanel(); mainPanel.add(contentPanel, BorderLayout.CENTER); fillWithObjAggregator(selectedAggregator); updateUIEnabled(); addComboBoxActionListeners(); if (!isNew) { ViewFactory.changeTextFieldUIForDisplay(nameText, false); } validator.resetFields(); validator.setEnabled(true); validator.setHasChanged(false); pack(); if (isNew) { nameText.getDocument().addDocumentListener(new DocumentAdaptor() { @Override public void changedUpdate(DocumentEvent e) { isNameInError = dataObjFieldFormatMgrCache.getAggregator(nameText.getText()) != null; validator.validateForm(); updateUIEnabled(); } }); } }
From source file:com.lottery.gui.MainLotteryForm.java
private void btnAddNumberActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddNumberActionPerformed try {//from w w w. j a va2 s . c o m Integer number = Integer.parseInt(inputNumberTf.getText()); if (inputNumbers.contains(number)) { JOptionPane.showMessageDialog(this, "Number has already existed!"); return; } if (number > LotteryUtils.MAX_BALL_VALUE || number < LotteryUtils.MIN_BALL_VALUE) { JOptionPane.showMessageDialog(this, "Invalid range (" + LotteryUtils.MIN_BALL_VALUE + " - " + LotteryUtils.MAX_BALL_VALUE + ")!"); return; } JLabel numberLbl = new JLabel(number + ""); numberLbl.setOpaque(true); //numberLbl.setMinimumSize(new Dimension(100, 100)); // numberLbl.setPreferredSize(new Dimension(400, 100)); // numberLbl.setBackground(Color.white); numberLbl.setForeground(Color.red); setFont(numberLbl.getFont().deriveFont(150f)); numberLbl.setFont(new Font("Serif", Font.PLAIN, 30)); int numberOfInput = inputNumbers.size(); int row = numberOfInput / NO_NUMBER_PER_ROW; int col = numberOfInput % NO_NUMBER_PER_ROW; c.fill = GridBagConstraints.HORIZONTAL; c.gridx = col; c.gridy = row; c.weightx = 0.5; ballNumbersPanel.add(numberLbl, c); lbNumbers.add(numberLbl); inputNumbers.add(number); ballNumbersPanel.revalidate(); ballNumbersPanel.repaint(); inputNumberTf.setText(""); inputNumberTf.requestFocusInWindow(); // // check if has winner // Date today = LotteryUtils.getNextDate(new Date()); // if (dbTicketTables.isEmpty()) { // dbTicketTables = ticketTableService.getByDate(today); // } totalDrawedNumbers++; checkCanAddNumber(); if (inputNumbers.size() < LotteryUtils.MAX_BALLS_PER_LINE) { return; } winTicketTables.addAll(LotteryUtils.getWinnerByLine(dbTicketTables, inputNumbers)); if (winTicketTables.size() > 0) { // update table list view refreshWinnerTable(); // JOptionPane.showMessageDialog(this, "Number of winner: " + winTicketTables.size()); } // check if has full table, then stop game if (totalDrawedNumbers >= (LotteryUtils.MAX_BALLS_PER_LINE * LotteryUtils.NO_LINES_PER_TABLE)) { Iterator<TicketTable> iter = winTicketTables.iterator(); while (iter.hasNext()) { TicketTable tmp = iter.next(); if (tmp.getWinType() == TicketTable.FULL_TABLE) { JOptionPane.showMessageDialog(this, "Got winner with full table!"); // save draw results, update ticket_table winner DrawResult drawResult = new DrawResult(); drawResult.setDrawDate(LotteryUtils.getDate(ftfDrawDate.getText().trim())); drawResult.setDrawBalls(StringUtils.join(inputNumbers, LotteryUtils.BALLS_SEPARATOR)); drawResult.setRound(Byte.parseByte((String) cbbRound.getSelectedItem())); drawResultService.updateWinner(drawResult, winTicketTables); restartGame(); return; } } } } catch (NumberFormatException ex) { LOGGER.error("Invalid number!: ", ex); JOptionPane.showMessageDialog(this, "Invalid number!"); } catch (ParseException ex) { LOGGER.error("Cant parse date", ex); JOptionPane.showMessageDialog(this, "Cant save result!"); } }
From source file:gate.gui.docview.AnnotationStack.java
/** * Draw the annotation stack in a JPanel with a GridBagLayout. */// ww w. j a v a2 s .c o m public void drawStack() { // clear the panel removeAll(); boolean textTooLong = text.length() > maxTextLength; int upperBound = text.length() - (maxTextLength / 2); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.BOTH; /********************** * First row of text * *********************/ gbc.gridwidth = 1; gbc.insets = new java.awt.Insets(10, 10, 10, 10); JLabel labelTitle = new JLabel("Context"); labelTitle.setOpaque(true); labelTitle.setBackground(Color.WHITE); labelTitle.setBorder(new CompoundBorder( new EtchedBorder(EtchedBorder.LOWERED, new Color(250, 250, 250), new Color(250, 250, 250).darker()), new EmptyBorder(new Insets(0, 2, 0, 2)))); labelTitle.setToolTipText("Expression and its context."); add(labelTitle, gbc); gbc.insets = new java.awt.Insets(10, 0, 10, 0); int expressionStart = contextBeforeSize; int expressionEnd = text.length() - contextAfterSize; // for each character for (int charNum = 0; charNum < text.length(); charNum++) { gbc.gridx = charNum + 1; if (textTooLong) { if (charNum == maxTextLength / 2) { // add ellipsis dots in case of a too long text displayed add(new JLabel("..."), gbc); // skip the middle part of the text if too long charNum = upperBound + 1; continue; } else if (charNum > upperBound) { gbc.gridx -= upperBound - (maxTextLength / 2) + 1; } } // set the text and color of the feature value JLabel label = new JLabel(text.substring(charNum, charNum + 1)); if (charNum >= expressionStart && charNum < expressionEnd) { // this part is matched by the pattern, color it label.setBackground(new Color(240, 201, 184)); } else { // this part is the context, no color label.setBackground(Color.WHITE); } label.setOpaque(true); // get the word from which belongs the current character charNum int start = text.lastIndexOf(" ", charNum); int end = text.indexOf(" ", charNum); String word = text.substring((start == -1) ? 0 : start, (end == -1) ? text.length() : end); // add a mouse listener that modify the query label.addMouseListener(textMouseListener.createListener(word)); add(label, gbc); } /************************************ * Subsequent rows with annotations * ************************************/ // for each row to display for (StackRow stackRow : stackRows) { String type = stackRow.getType(); String feature = stackRow.getFeature(); if (feature == null) { feature = ""; } String shortcut = stackRow.getShortcut(); if (shortcut == null) { shortcut = ""; } gbc.gridy++; gbc.gridx = 0; gbc.gridwidth = 1; gbc.insets = new Insets(0, 0, 3, 0); // add the header of the row JLabel annotationTypeAndFeature = new JLabel(); String typeAndFeature = type + (feature.equals("") ? "" : ".") + feature; annotationTypeAndFeature.setText(!shortcut.equals("") ? shortcut : stackRow.getSet() != null ? stackRow.getSet() + "#" + typeAndFeature : typeAndFeature); annotationTypeAndFeature.setOpaque(true); annotationTypeAndFeature.setBackground(Color.WHITE); annotationTypeAndFeature .setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.LOWERED, new Color(250, 250, 250), new Color(250, 250, 250).darker()), new EmptyBorder(new Insets(0, 2, 0, 2)))); if (feature.equals("")) { annotationTypeAndFeature.addMouseListener(headerMouseListener.createListener(type)); } else { annotationTypeAndFeature.addMouseListener(headerMouseListener.createListener(type, feature)); } gbc.insets = new java.awt.Insets(0, 10, 3, 10); add(annotationTypeAndFeature, gbc); gbc.insets = new java.awt.Insets(0, 0, 3, 0); // add all annotations for this row HashMap<Integer, TreeSet<Integer>> gridSet = new HashMap<Integer, TreeSet<Integer>>(); int gridyMax = gbc.gridy; for (StackAnnotation ann : stackRow.getAnnotations()) { gbc.gridx = ann.getStartNode().getOffset().intValue() - expressionStartOffset + contextBeforeSize + 1; gbc.gridwidth = ann.getEndNode().getOffset().intValue() - ann.getStartNode().getOffset().intValue(); if (gbc.gridx == 0) { // column 0 is already the row header gbc.gridwidth -= 1; gbc.gridx = 1; } else if (gbc.gridx < 0) { // annotation starts before displayed text gbc.gridwidth += gbc.gridx - 1; gbc.gridx = 1; } if (gbc.gridx + gbc.gridwidth > text.length()) { // annotation ends after displayed text gbc.gridwidth = text.length() - gbc.gridx + 1; } if (textTooLong) { if (gbc.gridx > (upperBound + 1)) { // x starts after the hidden middle part gbc.gridx -= upperBound - (maxTextLength / 2) + 1; } else if (gbc.gridx > (maxTextLength / 2)) { // x starts in the hidden middle part if (gbc.gridx + gbc.gridwidth <= (upperBound + 3)) { // x ends in the hidden middle part continue; // skip the middle part of the text } else { // x ends after the hidden middle part gbc.gridwidth -= upperBound - gbc.gridx + 2; gbc.gridx = (maxTextLength / 2) + 2; } } else { // x starts before the hidden middle part if (gbc.gridx + gbc.gridwidth < (maxTextLength / 2)) { // x ends before the hidden middle part // do nothing } else if (gbc.gridx + gbc.gridwidth < upperBound) { // x ends in the hidden middle part gbc.gridwidth = (maxTextLength / 2) - gbc.gridx + 1; } else { // x ends after the hidden middle part gbc.gridwidth -= upperBound - (maxTextLength / 2) + 1; } } } if (gbc.gridwidth == 0) { gbc.gridwidth = 1; } JLabel label = new JLabel(); Object object = ann.getFeatures().get(feature); String value = (object == null) ? " " : Strings.toString(object); if (value.length() > maxFeatureValueLength) { // show the full text in the tooltip label.setToolTipText((value.length() > 500) ? "<html><textarea rows=\"30\" cols=\"40\" readonly=\"readonly\">" + value.replaceAll("(.{50,60})\\b", "$1\n") + "</textarea></html>" : ((value.length() > 100) ? "<html><table width=\"500\" border=\"0\" cellspacing=\"0\">" + "<tr><td>" + value.replaceAll("\n", "<br>") + "</td></tr></table></html>" : value)); if (stackRow.getCrop() == CROP_START) { value = "..." + value.substring(value.length() - maxFeatureValueLength - 1); } else if (stackRow.getCrop() == CROP_END) { value = value.substring(0, maxFeatureValueLength - 2) + "..."; } else {// cut in the middle value = value.substring(0, maxFeatureValueLength / 2) + "..." + value.substring(value.length() - (maxFeatureValueLength / 2)); } } label.setText(value); label.setBackground(AnnotationSetsView.getColor(stackRow.getSet(), ann.getType())); label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); label.setOpaque(true); label.addMouseListener(annotationMouseListener.createListener(stackRow.getSet(), type, String.valueOf(ann.getId()))); // show the feature values in the tooltip if (!ann.getFeatures().isEmpty()) { String width = (Strings.toString(ann.getFeatures()).length() > 100) ? "500" : "100%"; String toolTip = "<html><table width=\"" + width + "\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\">"; Color color = (Color) UIManager.get("ToolTip.background"); float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null); color = Color.getHSBColor(hsb[0], hsb[1], Math.max(0f, hsb[2] - hsb[2] * 0.075f)); // darken the color String hexColor = Integer.toHexString(color.getRed()) + Integer.toHexString(color.getGreen()) + Integer.toHexString(color.getBlue()); boolean odd = false; // alternate background color every other row List<Object> features = new ArrayList<Object>(ann.getFeatures().keySet()); //sort the features into alphabetical order Collections.sort(features, new Comparator<Object>() { @Override public int compare(Object o1, Object o2) { return o1.toString().compareToIgnoreCase(o2.toString()); } }); for (Object key : features) { String fv = Strings.toString(ann.getFeatures().get(key)); toolTip += "<tr align=\"left\"" + (odd ? " bgcolor=\"#" + hexColor + "\"" : "") + "><td><strong>" + key + "</strong></td><td>" + ((fv.length() > 500) ? "<textarea rows=\"20\" cols=\"40\" cellspacing=\"0\">" + StringEscapeUtils .escapeHtml(fv.replaceAll("(.{50,60})\\b", "$1\n")) + "</textarea>" : StringEscapeUtils.escapeHtml(fv).replaceAll("\n", "<br>")) + "</td></tr>"; odd = !odd; } label.setToolTipText(toolTip + "</table></html>"); } else { label.setToolTipText("No features."); } if (!feature.equals("")) { label.addMouseListener(annotationMouseListener.createListener(stackRow.getSet(), type, feature, Strings.toString(ann.getFeatures().get(feature)), String.valueOf(ann.getId()))); } // find the first empty row span for this annotation int oldGridy = gbc.gridy; for (int y = oldGridy; y <= (gridyMax + 1); y++) { // for each cell of this row where spans the annotation boolean xSpanIsEmpty = true; for (int x = gbc.gridx; (x < (gbc.gridx + gbc.gridwidth)) && xSpanIsEmpty; x++) { xSpanIsEmpty = !(gridSet.containsKey(x) && gridSet.get(x).contains(y)); } if (xSpanIsEmpty) { gbc.gridy = y; break; } } // save the column x and row y of the current value TreeSet<Integer> ts; for (int x = gbc.gridx; x < (gbc.gridx + gbc.gridwidth); x++) { ts = gridSet.get(x); if (ts == null) { ts = new TreeSet<Integer>(); } ts.add(gbc.gridy); gridSet.put(x, ts); } add(label, gbc); gridyMax = Math.max(gridyMax, gbc.gridy); gbc.gridy = oldGridy; } // add a button at the end of the row gbc.gridwidth = 1; if (stackRow.getLastColumnButton() != null) { // last cell of the row gbc.gridx = Math.min(text.length(), maxTextLength) + 1; gbc.insets = new Insets(0, 10, 3, 0); gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.WEST; add(stackRow.getLastColumnButton(), gbc); gbc.insets = new Insets(0, 0, 3, 0); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.CENTER; } // set the new gridy to the maximum row we put a value gbc.gridy = gridyMax; } if (lastRowButton != null) { // add a configuration button on the last row gbc.insets = new java.awt.Insets(0, 10, 0, 10); gbc.gridx = 0; gbc.gridy++; add(lastRowButton, gbc); } // add an empty cell that takes all remaining space to // align the visible cells at the top-left corner gbc.gridy++; gbc.gridx = Math.min(text.length(), maxTextLength) + 1; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridheight = GridBagConstraints.REMAINDER; gbc.weightx = 1; gbc.weighty = 1; add(new JLabel(""), gbc); validate(); updateUI(); }
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 w w w . java 2s .c om 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: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 {/*from w ww . jav a 2 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:edu.ku.brc.specify.dbsupport.cleanuptools.GeoChooserDlg.java
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override/*from w w w. j a va2s .co m*/ public void createUI() { boolean doStatesOrCounties = doAllCountries[1] || doAllCountries[2] || doInvCountry[1] || doInvCountry[2]; //this.whichBtns = doStatesOrCounties && !doInvCountry[1] && rankId > 200 ? CustomDialog.OKCANCELAPPLYHELP : CustomDialog.OKCANCELHELP; boolean isStCnty = true;//rankId > 200; dataListModel = new DefaultListModel<GeoSearchResultsItem>(); mainList = new JList<GeoSearchResultsItem>(dataListModel); JScrollPane sb = createScrollPane(mainList, true); String listDim; if (UIHelper.isWindows()) { listDim = "250px"; Dimension sz = new Dimension(250, 250); mainList.setPreferredSize(sz); sb.setPreferredSize(sz); } else { listDim = "f:p:g"; } CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,2px,p,12px,p,2px," + listDim + ",8px,p,4px,p,10px,p" + (isStCnty ? ",8px,p" : ""))); this.contentPanel = pb.getPanel(); super.createUI(); okBtn.setEnabled(false); calcProgress(); try { if (coInfoList != null && coInfoList.size() > 0) { fillFromLuceneResults(); } else { fillFromQuery(); } mainList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { getOkBtn().doClick(); } else if (e.getClickCount() == 1 && !noMatchesFound && !mainList.isSelectionEmpty()) { getOkBtn().setEnabled(true); } } }); mainList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { listItemSelected(); } } }); updateNameCB = createCheckBox("Update the Name in the Geography tree."); // I18N //mergeCB = createCheckBox("Merge all the geographies with the same name."); addISOCodeCB = createCheckBox("Add the ISO Code to the record"); isoCodeTF = createTextField(8); isoCodeTF.setVisible(rankId < 400); updateNameCB.setSelected(isUpdateNamesChecked); //mergeCB.setSelected(true); addISOCodeCB.setSelected(true); updateNameCB.addChangeListener(new ChangeListener() { @Override public void stateChanged(final ChangeEvent e) { isUpdateNamesChecked = updateNameCB.isSelected(); } }); DocumentListener dl = new DocumentAdaptor() { @Override protected void changed(DocumentEvent e) { okBtn.setEnabled(!isoCodeTF.getText().isEmpty()); } }; isoCodeTF.getDocument().addDocumentListener(dl); //labels.add(nameStr);// + " (Unknown)"); PanelBuilder lookPB = null; JButton lookupBtn = null; if (isStCnty) { lookPB = new PanelBuilder(new FormLayout("f:p:g,p", "p")); lookupBtn = createI18NButton("CLNUP_GEO_LOOK_UP_ISO"); lookPB.add(lookupBtn, cc.xy(2, 1)); lookupBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { globalRankSearch(); } }); } int i = 0; ArrayList<String> labels = new ArrayList<String>(); while (i < parentNames.length && parentRanks[i] > -1) { labels.add(i18NLabelsMap.get(parentRanks[i++])); } PanelBuilder pbTop = new PanelBuilder( new FormLayout("p,2px,f:p:g", UIHelper.createDuplicateJGoodiesDef("p", "2px", labels.size()))); int y = 1; for (i = 0; i < labels.size(); i++) { JLabel lbl = createLabel(parentNames[i]); pbTop.add(createFormLabel(labels.get(i)), cc.xy(1, y)); pbTop.add(lbl, cc.xy(3, y)); lbl.setBackground(Color.WHITE); lbl.setOpaque(true); y += 2; } pb.add(pbTop.getPanel(), cc.xy(1, 3)); pb.addSeparator("Possible standard Geography choices", cc.xy(1, 5)); // I18N pb.add(sb, cc.xy(1, 7)); pb.add(updateNameCB, cc.xy(1, 9)); PanelBuilder pbc = new PanelBuilder(new FormLayout("p,10px,p,f:p:g", "p")); pbc.add(addISOCodeCB, cc.xy(1, 1)); pbc.add(isoCodeTF, cc.xy(3, 1)); pb.add(pbc.getPanel(), cc.xy(1, 11)); i = 13; if (isStCnty) { pb.add(lookPB.getPanel(), cc.xy(1, i)); i += 2; } //if (doAllCountries[0]) if (false) // hidding it for now { progressBar = new JProgressBar(0, 100); progressBar.setStringPainted(true); PanelBuilder prgPB = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p")); prgPB.add(createFormLabel("Progress"), cc.xy(1, 1)); prgPB.add(progressBar, cc.xy(3, 1)); pb.add(prgPB.getPanel(), cc.xy(1, i)); i += 2; } mainList.setSelectedIndex(selectedIndex); mainList.ensureIndexIsVisible(selectedIndex); noMatchesFound = dataListModel.size() == 0; // Optional Depending on States / Countries if (doStatesOrCounties) { if (dataListModel.getSize() == 0) { dataListModel.addElement(new GeoSearchResultsItem("No matches found."));// I18N } } pb.setDefaultDialogBorder(); } catch (Exception ex) { ex.printStackTrace(); } if (UIHelper.isWindows()) { setResizable(false); } setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); // Must be called at the end 'createUI' }
From source file:ecg.ecgshow.ECGShowUI.java
private void createBloodOxygenData(long timeZone) { BloodOxygendatas = new short[2]; BloodOxygenData = new JPanel(); BloodOxygenData.setLayout(new FlowLayout()); BloodOxygenData.setBounds(0, 0, (int) (WIDTH * 0.14), (int) (HEIGHT * 0.15)); BloodOxygenData.setBackground(Color.BLACK); JLabel jLabel1 = new JLabel("---"); if (BloodOxygendatas[0] == 0x00 || BloodOxygendatas == null) { jLabel1.setText("---"); } else {//from w ww . j a va 2 s. com jLabel1.setText(Short.toString((short) BloodOxygendatas[0])); } System.out.println("BloodOxygendatas" + Short.toString(BloodOxygendatas[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(" %"); 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); //?? BloodOxygenData.add(jLabelName); BloodOxygenData.add(jLabel1); BloodOxygenData.add(jLabelUnit); ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); scheduledExecutorService.scheduleAtFixedRate(new Runnable() { @Override public void run() { if (BloodOxygendatas[0] == 0 || HeartRatedatas[0] == -100) { jLabel1.setText("--"); } else { jLabel1.setText(String.valueOf(BloodOxygendatas[0])); } BloodOxygenData.repaint(); } }, 0, 3, TimeUnit.SECONDS); }