List of usage examples for javax.swing JLabel setBackground
@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.") public void setBackground(Color bg)
From source file:projectresurrection.Music.java
public void subMenu(int type, String menu) { JPanel panel = (JPanel) ((JViewport) ((JScrollPane) pnlSub.getComponent(3)).getComponent(0)) .getComponent(0);// w w w .j a v a 2s .com JLabel header = (JLabel) pnlSub.getComponent(1); JLabel label; header.setText(menu); panel.removeAll(); int y = 10; switch (type) { case 0: List albumList = new ArrayList(((Map) artists.get(menu)).keySet()); Collections.sort(albumList); panel.setPreferredSize(new Dimension(349, (55 + (albumList.size() * 35)))); label = new JLabel("All"); label.setOpaque(true); label.setBackground(new Color(245, 245, 245)); label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { subMenuAll(ARTISTS, menu); panel.revalidate(); panel.repaint(); } }); panel.add(label); y += 35; for (int i = 0; i < albumList.size(); i++) { String album = albumList.get(i).toString(); label = new JLabel(album); label.setOpaque(true); if (i % 2 == 1) { label.setBackground(new Color(245, 245, 245)); } label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { subMenu(ALBUMS, album); panel.revalidate(); panel.repaint(); } }); panel.add(label); y += 35; } break; case 1: List songList = new ArrayList(); List albumSongs = new ArrayList(((Map) albums.get(menu)).keySet()); Collections.sort(albumSongs); Map tracks = new HashMap(); for (int i = 0; i < albumSongs.size(); i++) { String track = ((List) songs.get(albumSongs.get(i))).get(1).toString(); if (tracks.containsKey(track)) { track = track + "(1)"; int j = 2; while (tracks.containsKey(track)) { track = track + "(" + j + ")"; } } tracks.put(track, albumSongs.get(i)); } List nums = new ArrayList(tracks.keySet()); Collections.sort(nums); List hasTrack = new ArrayList(); List noTrack = new ArrayList(); for (int i = 0; i < nums.size(); i++) { if (nums.get(i).equals("-1")) { noTrack.add(tracks.get(nums.get(i))); } else { hasTrack.add(tracks.get(nums.get(i))); } } Collections.sort(noTrack); for (int i = 0; i < hasTrack.size(); i++) { songList.add(hasTrack.get(i)); } for (int i = 0; i < noTrack.size(); i++) { songList.add(noTrack.get(i)); } panel.setPreferredSize(new Dimension(349, (20 + (albumSongs.size() * 35)))); List fileList = new ArrayList(); for (int i = 0; i < songList.size(); i++) { fileList.add(((List) songs.get(songList.get(i))).get(0)); } for (int i = 0; i < songList.size(); i++) { int num = i; String song = songList.get(i).toString(); label = new JLabel(song); label.setOpaque(true); if (i % 2 == 0) { label.setBackground(new Color(245, 245, 245)); } label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { player.setPlaylist(fileList, num); pnlSub.setVisible(false); pnlPlayer.setVisible(true); try { Thread.sleep(200); } catch (Exception e) { } if (player.isPlaying() == false) { player.toggle(); } } }); panel.add(label); y += 35; } break; } panel.revalidate(); panel.repaint(); }
From source file:projectresurrection.Music.java
public void subMenuAll(int type, String menu) { JPanel panel = (JPanel) ((JViewport) ((JScrollPane) pnlSub.getComponent(3)).getComponent(0)) .getComponent(0);//from w w w . j a v a 2 s . co m JLabel header = (JLabel) pnlSub.getComponent(1); header.setText(menu + " - All"); panel.removeAll(); int y = 10; switch (type) { case 0: List songList = new ArrayList(); List albumList = new ArrayList(((Map) artists.get(menu)).keySet()); Collections.sort(albumList); for (int i = 0; i < albumList.size(); i++) { List albumSongs = new ArrayList(((Map) albums.get(albumList.get(i))).keySet()); Map tracks = new HashMap(); for (int j = 0; j < albumSongs.size(); j++) { String track = ((List) songs.get(albumSongs.get(j))).get(1).toString(); tracks.put(track, albumSongs.get(j)); } List nums = new ArrayList(tracks.keySet()); Collections.sort(nums); List hasTrack = new ArrayList(); List noTrack = new ArrayList(); for (int j = 0; j < nums.size(); j++) { if (nums.get(j).equals("-1")) { noTrack.add(tracks.get(nums.get(j))); } else { hasTrack.add(tracks.get(nums.get(j))); } } for (int j = 0; j < hasTrack.size(); j++) { songList.add(hasTrack.get(j)); } for (int j = 0; j < noTrack.size(); j++) { songList.add(noTrack.get(j)); } } panel.setPreferredSize(new Dimension(349, (20 + (songList.size() * 35)))); List fileList = new ArrayList(); for (int i = 0; i < songList.size(); i++) { fileList.add(((List) songs.get(songList.get(i))).get(0)); } for (int i = 0; i < songList.size(); i++) { int num = i; String song = songList.get(i).toString(); JLabel label = new JLabel(song); label.setOpaque(true); if (i % 2 == 0) { label.setBackground(new Color(245, 245, 245)); } label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { player.setPlaylist(fileList, num); pnlSub.setVisible(false); pnlPlayer.setVisible(true); try { Thread.sleep(200); } catch (Exception e) { } if (player.isPlaying() == false) { player.toggle(); } } }); panel.add(label); y += 35; } break; } panel.revalidate(); panel.repaint(); }
From source file:savant.amino.AminoPlugin.java
/** * Create the user-interface which appears within the panel. * * @param panel provided by Savant/* ww w. ja va2 s.c o m*/ */ @Override public void init(JPanel panel) { panel.setLayout(new GridLayout(5, 4, 2, 2)); // Create a label for each amino-acid. For now, these are just for reference, // but we might make them into buttons to change the colour scheme. for (AminoAcid a : AminoAcid.values()) { JLabel label = new JLabel(a.name, SwingConstants.CENTER); label.setOpaque(true); label.setBackground(a.color); label.setForeground(a == AminoAcid.STOP ? Color.WHITE : Color.BLACK); panel.add(label); } // First time through, create canvasses for any existing gene tracks. We // hook this onto a listener so that we'll know that Savant has fully loaded // the plugin before we try to do anything. PluginUtils.addPluginListener(new Listener<PluginEvent>() { @Override public void handleEvent(PluginEvent event) { if (event.getType() == PluginEvent.Type.LOADED && event.getPlugin() instanceof AminoPlugin) { PluginUtils.removePluginListener(this); TrackAdapter[] existingTracks = TrackUtils.getTracks(DataFormat.RICH_INTERVAL); for (TrackAdapter t : existingTracks) { createCanvas(t); } } } }); TrackUtils.addTrackListener(new Listener<TrackEvent>() { @Override public void handleEvent(TrackEvent event) { if (event.getType() == TrackEvent.Type.ADDED) { createCanvas(event.getTrack()); } } }); NavigationUtils.addLocationChangedListener(new Listener<LocationChangedEvent>() { @Override public void handleEvent(LocationChangedEvent event) { for (TrackAdapter t : TrackUtils.getTracks()) { if (t.getDataFormat() == DataFormat.RICH_INTERVAL) { t.getLayerCanvas(AminoPlugin.this).repaint(); } } } }); }
From source file:semgen.extraction.RadialGraph.Clusterer.java
public String clusterAndRecolor(AggregateLayout<String, Number> layout, int numEdgesToRemove, Color[] colors, boolean groupClusters) { setCursor(new Cursor(Cursor.WAIT_CURSOR)); String moduletable = ""; Graph<String, Number> g = layout.getGraph(); layout.removeAll();/*from ww w . j a v a2s.c o m*/ EdgeBetweennessClusterer<String, Number> clusterer = new EdgeBetweennessClusterer<String, Number>( numEdgesToRemove); Set<Set<String>> clusterSet = clusterer.transform(g); List<Number> edges = clusterer.getEdgesRemoved(); sempanel.removeAll(); int i = 0; // Set the colors of each node so that each cluster's vertices have the same color extractor.clusterpanel.checkboxpanel.removeAll(); for (Iterator<Set<String>> cIt = clusterSet.iterator(); cIt.hasNext();) { moduletable = moduletable + "\nCLUSTER " + (i + 1); Set<String> vertices = cIt.next(); Color c = colors[i % colors.length]; Set<DataStructure> datastrs = new HashSet<DataStructure>(); for (String vertex : vertices) { datastrs.add(extractor.semsimmodel.getDataStructure(vertex)); } JLabel modulelabel = new JLabel("Cluster " + (i + 1)); modulelabel.setOpaque(true); modulelabel.setFont(SemGenFont.defaultBold()); modulelabel.setBackground(c); modulelabel.setAlignmentX(LEFT_ALIGNMENT); sempanel.add(modulelabel); // Update the semantics panel Set<String> addedterms = new HashSet<String>(); for (String ver : vertices) { if (extractor.semsimmodel.getDataStructure(ver).hasPhysicalProperty()) { if (extractor.semsimmodel.getDataStructure(ver).getPhysicalProperty() .getPhysicalPropertyOf() != null) { PhysicalModelComponent pmc = extractor.semsimmodel.getDataStructure(ver) .getPhysicalProperty().getPhysicalPropertyOf(); String name = null; if (pmc.hasRefersToAnnotation()) { name = pmc.getFirstRefersToReferenceOntologyAnnotation().getValueDescription(); } else { name = pmc.getName(); } if (!addedterms.contains(name)) { addedterms.add(name); JTextArea enttext = new JTextArea(name); enttext.setOpaque(true); enttext.setBackground(c); enttext.setFont(SemGenFont.defaultPlain(-2)); if (pmc instanceof PhysicalProcess) { enttext.setFont(SemGenFont.defaultItalic(-2)); name = "Process: " + name; } else name = "Entity: " + name; enttext.setWrapStyleWord(true); enttext.setLineWrap(true); enttext.setBorder(BorderFactory.createEmptyBorder(7, 7, 0, 0)); enttext.setAlignmentX(LEFT_ALIGNMENT); sempanel.add(enttext); moduletable = moduletable + "\n " + name; } } } } sempanel.validate(); sempanel.repaint(); semscroller.repaint(); semscroller.validate(); this.repaint(); this.validate(); colorCluster(vertices, c); ExtractorJCheckBox box = new ExtractorJCheckBox("Cluster " + (i + 1), datastrs); box.setBackground(c); box.setOpaque(true); box.addItemListener(extractor); extractor.clusterpanel.checkboxpanel.add(box); if (groupClusters == true) groupCluster(layout, vertices); i++; } refreshModulePanel(); for (Number e : g.getEdges()) { if (edges.contains(e)) edgePaints.put(e, Color.lightGray); else edgePaints.put(e, Color.black); } nummodules = i; setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); return moduletable; }
From source file:uk.nhs.cfh.dsp.srth.desktop.modules.querycreationtreepanel.renderer.ReportingQueryStatementTreeCellRenderer.java
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { final JLabel label = new JLabel(); if (value instanceof QueryExpression) { QueryExpression expression = (QueryExpression) value; if (expression instanceof QueryStatement) { label.setText("Get patients who have"); } else if (expression instanceof QueryIntersectionExpression) { QueryIntersectionExpression intersectionObject = (QueryIntersectionExpression) expression; QueryExpression.QueryOperatorType operatorType = intersectionObject.getOperator(); if (operatorType != QueryExpression.QueryOperatorType.AND) { label.setText("ALL of the following (" + operatorType.toString() + ")"); } else { label.setText("ALL of the following"); }/* w w w .ja v a2 s .co m*/ } else if (expression instanceof QueryUnionExpression) { label.setText("ANY of the following"); } else if (expression instanceof QueryComponentExpression) { QueryComponentExpression componentExpression = (QueryComponentExpression) value; TerminologyConstraint includedConstraint = componentExpression.getIncludedConstraint(); if (includedConstraint != null) { String text = humanReadableRender .getHumanReadableLabel((CloseToUserExpression) includedConstraint.getExpression()); label.setText(text); } final Collection<TerminologyConstraint> excludedTerms = componentExpression .getExcludedConstraints(); if (excludedTerms.size() > 0) { label.setIcon(icon); } SwingUtilities.updateComponentTreeUI(label); } // set label text color based on run time status setFontColor(expression, label); } if (hasFocus) { Color lineColor = UIManager.getColor("Tree.selectionBorderColor"); label.setBorder(BorderFactory.createLineBorder(lineColor)); label.setBackground(UIManager.getColor("Tree.selectionBackground")); } else { label.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); label.setBackground(UIManager.getColor("Tree.background")); } return label; }
From source file:uk.nhs.cfh.dsp.srth.desktop.uiframework.app.impl.ModularApplicationAboutDialog.java
/** * Inits the components.//w ww . j a v a 2 s. c om */ public void initComponents() { // initialise gui mainPanel = new JPanel(); JLabel logoLabel = new JLabel(); logoLabel.setIcon(ImageUtils.getIcon(ImageUtils.IconName.LOGO_WHITE)); logoLabel.setBackground(Color.WHITE); logoLabel.setOpaque(true); infoPane = new JTextPane(); infoPane.setEditorKit(new HTMLEditorKit()); infoPane.setText(createHTMLText()); infoPane.setEditable(false); mainPanel.setLayout(new BorderLayout()); mainPanel.add(logoLabel, BorderLayout.NORTH); mainPanel.add(new JScrollPane(infoPane), BorderLayout.CENTER); createButtonsPanel(); getContentPane().add(mainPanel); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setPreferredSize(new Dimension(400, 500)); setResizable(true); }
From source file:uk.nhs.cfh.dsp.yasb.searchpanel.renderer.SearchResultListCellRenderer.java
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean hasFocus) { JLabel label = new JLabel(); label.setOpaque(true);//from w w w . j a v a 2 s .co m if (value instanceof Document) { // get field that has value of the fully specified name Document doc = (Document) value; if (isRenderConceptId()) { label.setText("<html><b>" + doc.get("TERM") + "</b><font color=\"eee\">|" + doc.get("CONCEPTID") + "|</font></html>"); } else { label.setText("<html><b>" + doc.get("TERM") + "</b></html>"); } // set icon based on status String status = doc.get("STATUS"); if ("limited".equalsIgnoreCase(status)) { label.setIcon(limitedStatusIcon); } else if ("duplicate".equalsIgnoreCase(status)) { label.setIcon(duplicateStatusIcon); } else if ("ambiguous".equalsIgnoreCase(status)) { label.setIcon(ambiguousStatusIcon); } else { label.setIcon(currentStatusIcon); } // always set tooltip to FSN + concept id label.setToolTipText("<html><b>" + doc.get("TERM") + "</b><font color=\"eee\">|" + doc.get("CONCEPTID") + "|</font></html>"); } if (isSelected) { label.setBackground(UIManager.getColor("Tree.selectionbackground")); } else { label.setBackground(UIManager.getColor("Tree.background")); } return label; }
From source file:vista.ArchToxHome.java
public void setButtonColor(javax.swing.JLabel label) { label.setBackground(new Color(168, 28, 28)); }
From source file:vista.ArchToxHome.java
public void resetButtonColor(javax.swing.JLabel label) { label.setBackground(new Color(255, 51, 51)); }