List of usage examples for javax.swing JPanel setBackground
@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.") public void setBackground(Color bg)
From source file:org.openmicroscopy.shoola.agents.metadata.util.FilesetInfoDialog.java
/** * Sets the data to display// w ww . j av a 2s.c o m * * @param set * The fileset which paths should be shown * @param importType * The import type */ public void setData(Set<FilesetData> set, ImportType importType) { if (set == null) return; JPanel content = new JPanel(); content.setLayout(new GridBagLayout()); content.setBackground(UIUtilities.BACKGROUND_COLOR); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHEAST; if (CollectionUtils.isEmpty(set)) { JLabel l = new JLabel("No information available."); l.setBackground(UIUtilities.BACKGROUND_COLOR); content.add(l, c); } else { int size = 0; FilesetData fsd = set.iterator().next(); if (Fileset.class.isAssignableFrom(fsd.asIObject().getClass())) { size = ((Fileset) fsd.asIObject()).sizeOfUsedFiles(); } String txt = size <= 1 ? "Image file" : "Image files"; JLabel l = new JLabel(size + " " + txt); l.setBackground(UIUtilities.BACKGROUND_COLOR); content.add(l, c); c.gridy++; JSeparator sep = new JSeparator(JSeparator.HORIZONTAL); sep.setBackground(UIUtilities.BACKGROUND_COLOR); content.add(sep, c); c.gridy++; String header = (importType == ImportType.HARDLINK || importType == ImportType.SOFTLINK) ? "Imported with <b>--transfer=" + importType.getSymbol() + "</b> from:" : "Imported from:"; ExpandableTextPane t1 = new ExpandableTextPane(); t1.setBackground(UIUtilities.BACKGROUND_COLOR); t1.setText(header + "<br/>" + getOriginPaths(set)); content.add(t1, c); c.gridy++; JSeparator sep2 = new JSeparator(JSeparator.HORIZONTAL); sep2.setBackground(UIUtilities.BACKGROUND_COLOR); content.add(sep2, c); c.gridy++; ExpandableTextPane t2 = new ExpandableTextPane(); t2.setBackground(UIUtilities.BACKGROUND_COLOR); t2.setText("Path on server:<br/>" + getServerPaths(set)); content.add(t2, c); } setCanvas(new JScrollPane(content)); }
From source file:org.openmicroscopy.shoola.agents.treeviewer.util.MoveGroupSelectionDialog.java
/** * Builds the main component of this dialog. * /* ww w.ja v a 2 s. c o m*/ * @param group The selected group if any. * @param comp The component to add. * @return See above. */ private JComponent buildContent(JComponent comp) { double[][] tl = { { TableLayout.FILL }, //columns { TableLayout.FILL } }; //rows JPanel content = new JPanel(); content.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); content.setLayout(new TableLayout(tl)); content.setBackground(UIUtilities.BACKGROUND); content.add(comp, "0, 0, CENTER, CENTER"); return content; }
From source file:org.openmicroscopy.shoola.agents.treeviewer.util.MoveGroupSelectionDialog.java
/** Builds the components displayed when no node to display.*/ private void buildNoContentPane() { noDisplay = true;//from w w w .j a v a 2 s . com Container c = getContentPane(); StringBuffer s = new StringBuffer(); StringBuffer s1 = new StringBuffer(); if (ProjectData.class.equals(containerType)) { s.append("There is no Project to move the Dataset(s) into."); s1.append("Please create a new Project if you wish."); } else if (DatasetData.class.equals(containerType)) { s.append("There is no Dataset to move the Image(s) into."); s1.append("Please create a new Dataset if you wish."); } else if (ScreenData.class.equals(containerType)) { s.append("There is no Screen to move the Plate into."); s1.append("Please create a new Screen if you wish."); } JPanel p = new JPanel(); p.setBackground(UIUtilities.BACKGROUND); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.add(new JLabel(s.toString())); p.add(new JLabel(s1.toString())); body = buildContent(p); c.add(body, BorderLayout.CENTER); c.add(buildToolBar(), BorderLayout.SOUTH); validate(); repaint(); }
From source file:org.openmicroscopy.shoola.agents.treeviewer.view.ToolBar.java
/** * Formats the header./*from w w w .j ava2s .c o m*/ * * @param text The text to display * @return See above. */ private JPanel formatHeader(String text) { JPanel title = new JPanel(); title.setLayout(new FlowLayout(FlowLayout.LEFT)); title.add(UIUtilities.setTextFont(text)); title.setBackground(UIUtilities.BACKGROUND_COLOUR_EVEN); return title; }
From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptingDialog.java
/** * Returns the component displaying the description of the script. * * @return See above./*from ww w. ja v a2s . c o m*/ */ private JComponent buildDescriptionPane() { String description = script.getDescription(); if (StringUtils.isBlank(description)) return null; OMEWikiComponent area = new OMEWikiComponent(false); area.setEnabled(false); area.setText(description); JPanel content = new JPanel(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); JLabel label = UIUtilities.setTextFont(script.getName()); Font f = label.getFont(); label.setFont(f.deriveFont(f.getStyle(), f.getSize() + 2)); content.add(UIUtilities.buildComponentPanel(label)); content.add(Box.createVerticalStrut(5)); JPanel p = UIUtilities.buildComponentPanel(area); p.setBackground(BG_COLOR); area.setBackground(BG_COLOR); content.add(p); return content; }
From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptingDialog.java
/** * Builds and lays out the details of the script e.g. * authors, contact, version.// www .j a v a 2 s . c om * * @return See above. */ private JPanel buildScriptDetails() { String[] authors = script.getAuthors(); String contact = script.getContact(); String version = script.getVersion(); if (authors == null && contact == null && version == null) return null; JPanel p = new JPanel(); p.setBackground(BG_COLOR); double[] columns = { TableLayout.PREFERRED, 5, TableLayout.FILL }; TableLayout layout = new TableLayout(); layout.setColumn(columns); p.setLayout(layout); int row = 0; JLabel l; if (authors != null && authors.length > 0) { l = UIUtilities.setTextFont("Authors:"); StringBuffer buffer = new StringBuffer(); int n = authors.length - 1; for (int i = 0; i < authors.length; i++) { buffer.append(authors[i]); if (i < n) buffer.append(", "); } layout.insertRow(row, TableLayout.PREFERRED); p.add(l, "0," + row); l = new JLabel(); l.setText(buffer.toString()); p.add(l, "2," + row); row++; } if (StringUtils.isNotBlank(contact)) { l = UIUtilities.setTextFont("Contact:"); layout.insertRow(row, TableLayout.PREFERRED); p.add(l, "0," + row); l = new JLabel(); l.setText(contact); p.add(l, "2," + row); row++; } if (StringUtils.isNotBlank(version)) { l = UIUtilities.setTextFont("Version:"); layout.insertRow(row, TableLayout.PREFERRED); p.add(l, "0," + row); l = new JLabel(); l.setText(version); p.add(l, "2," + row); } if (p.getComponentCount() == 0) return null; return p; }
From source file:org.openmicroscopy.shoola.env.ui.ActivityComponent.java
/** Builds and lays out the UI. */ private void buildGUI() { JPanel barPane = new JPanel(); barPane.setOpaque(false);/* w ww . ja v a 2s .c o m*/ barPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); double[][] size = { { TableLayout.FILL }, { TableLayout.PREFERRED, TableLayout.PREFERRED } }; barPane.setLayout(new TableLayout(size)); barPane.add(type, "0, 0, LEFT, CENTER"); barPane.add(messageLabel, "0, 1, CENTER, CENTER"); //icon, message, content, toolbar double[][] tl = { { TableLayout.PREFERRED, TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED }, { TableLayout.PREFERRED } }; setLayout(new TableLayout(tl)); add(statusPane, "0, 0"); JPanel p = UIUtilities.buildComponentPanel(barPane); p.setOpaque(false); p.setBackground(barPane.getBackground()); add(p, "1, 0"); paneIndex = "2, 0"; add(resultPane, paneIndex); add(createToolBar(), "3, 0"); }
From source file:org.openmicroscopy.shoola.env.ui.ActivityComponent.java
/** * Invokes when the activity end. //from w ww . j av a 2 s . c o m * * @param result The result of the activity. */ public void endActivity(Object result) { this.result = result; boolean busy = status.isBusy(); reset(); if (result instanceof Map) { Map<String, Object> m = convertResult((Map<String, Object>) result); int size = m.size(); this.result = m; remove(resultPane); Color c = getBackground(); if (size == 0) { JToolBar row = new JToolBar(); row.setOpaque(false); row.setFloatable(false); row.setBorder(null); row.setBackground(c); JButton button; if (errorObject != null) { button = createButton(ActivityResultRow.ERROR_TEXT, ERROR, this); button.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { showMenu((JComponent) e.getSource(), ERROR, e.getX(), e.getY()); } }); row.add(button); } if (infoObject != null) { button = createButton(ActivityResultRow.INFO_TEXT, INFO, this); button.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { showMenu((JComponent) e.getSource(), INFO, e.getX(), e.getY()); } }); row.add(button); } add(row, paneIndex); } else { Entry<String, Object> entry; Iterator<Entry<String, Object>> i = m.entrySet().iterator(); ActivityResultRow row = null; JPanel content = new JPanel(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); content.setBackground(c); int index = 0; int max = 2; JButton moreButton = null; while (i.hasNext()) { entry = (Entry<String, Object>) i.next(); this.result = entry.getValue(); row = new ActivityResultRow((String) entry.getKey(), entry.getValue(), this); row.setBackground(c); row.addPropertyChangeListener(listener); resultButtons.add(row); if (index < max) content.add(row); else { if (moreButton == null) { moreButton = createButton("" + (m.size() - max) + " more", ALL_RESULT, this); content.add(moreButton); } } index++; } if (m.size() == 1) add(row, paneIndex); else add(content, paneIndex); resultPane = content; } repaint(); } firePropertyChange(UNREGISTER_ACTIVITY_PROPERTY, null, this); notifyActivityEnd(); //Post an event to //if (busy) { EventBus bus = registry.getEventBus(); bus.post(new ActivityProcessEvent(this, busy)); //} }
From source file:org.openmicroscopy.shoola.env.ui.ActivityComponent.java
/** * Removes the activity from the display * @see ActionListener#actionPerformed(ActionEvent) *//*from w ww. j a v a2 s . com*/ public void actionPerformed(ActionEvent e) { int index = Integer.parseInt(e.getActionCommand()); switch (index) { case REMOVE: firePropertyChange(REMOVE_ACTIVITY_PROPERTY, null, this); break; case CANCEL: onActivityCancelled(); if (cancelButton != null) cancelButton.setEnabled(false); if (loader != null) loader.cancel(); break; case EXCEPTION: showException(); break; case ALL_RESULT: Iterator<ActivityResultRow> i = resultButtons.iterator(); JPanel content = new JPanel(); content.setBackground(getBackground()); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); while (i.hasNext()) { content.add(i.next()); } remove(resultPane); add(content, paneIndex); resultPane = content; validate(); repaint(); break; } }
From source file:org.openmicroscopy.shoola.util.ui.omeeditpane.OMEWikiComponent.java
/** Builds and lays out the UI. */ private void buildGUI() { //setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); if (toolBar != null) { JPanel p = new JPanel(); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.add(Box.createVerticalStrut(5)); JPanel bar = UIUtilities.buildComponentPanel(toolBar, 0, 0); bar.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(bar);/* w ww .jav a 2 s . co m*/ p.add(Box.createVerticalStrut(2)); add(p, BorderLayout.NORTH); } setLayout(new BorderLayout()); add(pane, BorderLayout.CENTER); }