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.editor.PropertiesUI.java
/** * Lays out the components using a <code>FlowLayout</code>. * /* ww w .j av a 2s . com*/ * @param button The component to lay out. * @param component The component to lay out. * @param sizeRow The size of the row. * @return See above. */ private JPanel layoutEditablefield(Component button, JComponent component, int sizeRow) { JPanel p = new JPanel(); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(0, 2, 2, 0); c.gridy = 0; c.gridx = 0; if (button != null) { JToolBar bar = new JToolBar(); bar.setBorder(null); bar.setFloatable(false); bar.setBackground(UIUtilities.BACKGROUND_COLOR); bar.add(button); p.add(bar, c); c.gridx++; } if (sizeRow > 0) { c.ipady = sizeRow; c.gridheight = 2; } p.add(component, c); JPanel content = UIUtilities.buildComponentPanel(p, 0, 0); content.setBackground(UIUtilities.BACKGROUND_COLOR); return content; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java
/** * Builds the properties component.// w w w . j a v a2s. co m * * @return See above. */ private JPanel buildProperties() { Object refObject = model.getRefObject(); JPanel p = new JPanel(); p.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); JPanel idPanel = new JPanel(); idPanel.setLayout(new BoxLayout(idPanel, BoxLayout.X_AXIS)); idPanel.setBackground(UIUtilities.BACKGROUND_COLOR); JPanel l = UIUtilities.buildComponentPanel(idLabel, 0, 0); l.setBackground(UIUtilities.BACKGROUND_COLOR); idPanel.add(l); idPanel.add(Box.createHorizontalGlue()); idPanel.add(inplaceIcon); p.add(idPanel); l = UIUtilities.buildComponentPanel(ownerLabel, 0, 0); l.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(l); int w = editName.getIcon().getIconWidth() + 4; l = UIUtilities.buildComponentPanel(gpLabel, 0, 0); l.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(layoutEditablefield(Box.createHorizontalStrut(w), l)); l = UIUtilities.buildComponentPanel(parentLabel, 0, 0); l.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(layoutEditablefield(Box.createHorizontalStrut(w), l)); l = UIUtilities.buildComponentPanel(wellLabel, 0, 0); l.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(layoutEditablefield(Box.createHorizontalStrut(w), l)); namePanel = layoutEditablefield(editName, namePane); p.add(namePanel); p.add(Box.createVerticalStrut(5)); if (refObject instanceof ImageData || refObject instanceof DatasetData || refObject instanceof ProjectData || refObject instanceof TagAnnotationData || refObject instanceof WellSampleData || refObject instanceof PlateData || refObject instanceof ScreenData || refObject instanceof PlateAcquisitionData) { descriptionScrollPane = new JScrollPane(descriptionWiki); descriptionScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); descriptionScrollPane.setBorder(AnnotationUI.EDIT_BORDER); Dimension viewportSize = new Dimension(WIDTH, HEIGHT); descriptionScrollPane.getViewport().setPreferredSize(viewportSize); double[][] design = new double[][] { { TableLayout.PREFERRED, TableLayout.FILL }, { TableLayout.PREFERRED } }; TableLayout table = new TableLayout(design); descriptionPanel = new JPanel(table); descriptionPanel.setBackground(UIUtilities.BACKGROUND_COLOR); descriptionPanel.add(descriptionButtonEdit, "0, 0, c, t"); descriptionPanel.add(descriptionScrollPane, "1, 0"); p.add(descriptionPanel); p.add(Box.createVerticalStrut(5)); } return p; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.ToolBar.java
/** Builds and lays out the UI. */ private void buildGUI() { JPanel bars = new JPanel(); bars.setBackground(UIUtilities.BACKGROUND_COLOR); bars.setLayout(new BoxLayout(bars, BoxLayout.X_AXIS)); bars.add(buildGeneralBar());// w w w. ja v a 2s .c o m JPanel p = new JPanel(); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); JPanel pp = UIUtilities.buildComponentPanel(bars); pp.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(pp); pp = UIUtilities.buildComponentPanelRight(busyLabel); pp.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(pp); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setBackground(UIUtilities.BACKGROUND_COLOR); add(p); add(new JSeparator()); }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.UserProfile.java
/** * Returns the component displayed the user photo. * /*from w w w . j a va2 s . co m*/ * @return See above. */ private JPanel buildProfileCanvas() { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.add(userPicture); p.setBackground(UIUtilities.BACKGROUND_COLOR); JPanel bar = new JPanel(); bar.setBackground(UIUtilities.BACKGROUND_COLOR); bar.setLayout(new FlowLayout(FlowLayout.LEFT)); bar.add(changePhoto); bar.add(deletePhoto); p.add(bar); return p; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.UserProfile.java
/** * Builds the panel hosting the user's details. * //from ww w . j a va2 s.com * @return See above. */ private JPanel buildContentPanel() { ExperimenterData user = (ExperimenterData) model.getRefObject(); boolean editable = model.isUserOwner(user); if (!editable) editable = MetadataViewerAgent.isAdministrator(); details = EditorUtil.convertExperimenter(user); JPanel content = new JPanel(); content.setBorder(BorderFactory.createTitledBorder("User")); content.setBackground(UIUtilities.BACKGROUND_COLOR); Entry<String, String> entry; Iterator<Entry<String, String>> i = details.entrySet().iterator(); JComponent label; JTextField area; String key, value; content.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(0, 2, 2, 0); //Add log in name but cannot edit. c.gridx = 0; c.gridy = 0; c.gridwidth = GridBagConstraints.REMAINDER;//end row c.fill = GridBagConstraints.HORIZONTAL; content.add(buildProfileCanvas(), c); c.gridy++; c.gridx = 0; label = EditorUtil.getLabel(EditorUtil.DISPLAY_NAME, true); label.setBackground(UIUtilities.BACKGROUND_COLOR); c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE;//reset to default c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER;//end row c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; loginArea.setText(user.getUserName()); loginArea.setEnabled(false); loginArea.setEditable(false); if (MetadataViewerAgent.isAdministrator() && !model.isSystemUser(user.getId()) && !model.isSelf()) { loginArea.setEnabled(true); loginArea.getDocument().addDocumentListener(this); } content.add(loginArea, c); while (i.hasNext()) { ++c.gridy; c.gridx = 0; entry = i.next(); key = entry.getKey(); value = entry.getValue(); label = EditorUtil.getLabel(key, EditorUtil.FIRST_NAME.equals(key) || EditorUtil.LAST_NAME.equals(key)); area = new JTextField(value); area.setBackground(UIUtilities.BACKGROUND_COLOR); area.setEditable(editable); area.setEnabled(editable); if (editable) area.getDocument().addDocumentListener(this); items.put(key, area); label.setBackground(UIUtilities.BACKGROUND_COLOR); c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE;//reset to default c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER;//end row c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(area, c); } c.gridx = 0; c.gridy++; label = EditorUtil.getLabel(EditorUtil.DEFAULT_GROUP, false); c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE;//reset to default c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(groupsBox, c); c.gridy++; content.add(permissionsPane, c); c.gridx = 0; c.gridy++; label = EditorUtil.getLabel(EditorUtil.GROUP_OWNER, false); c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE; //reset to default c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; //end row c.fill = GridBagConstraints.NONE; c.weightx = 1.0; content.add(ownerBox, c); if (activeBox.isVisible()) { c.gridx = 0; c.gridy++; label = EditorUtil.getLabel(EditorUtil.ACTIVE, false); c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE; c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.NONE; c.weightx = 1.0; content.add(activeBox, c); } if (adminBox.isVisible()) { c.gridx = 0; c.gridy++; label = EditorUtil.getLabel(EditorUtil.ADMINISTRATOR, false); c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE; c.weightx = 0.0; content.add(label, c); c.gridx++; content.add(Box.createHorizontalStrut(5), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.NONE; c.weightx = 1.0; content.add(adminBox, c); } c.gridx = 0; c.gridy++; content.add(Box.createHorizontalStrut(10), c); c.gridy++; label = UIUtilities.setTextFont(EditorUtil.MANDATORY_DESCRIPTION, Font.ITALIC); label.setForeground(UIUtilities.REQUIRED_FIELDS_COLOR); c.weightx = 0.0; content.add(label, c); return content; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.UserProfile.java
/** * Builds the UI component hosting the UI component used to modify * the password.// w w w. j av a 2 s. c o m * * @return See above. */ private JPanel buildPasswordPanel() { JPanel content = new JPanel(); content.setBackground(UIUtilities.BACKGROUND_COLOR); Registry reg = MetadataViewerAgent.getRegistry(); String ldap = (String) reg.lookup(LookupNames.USER_AUTHENTICATION); if (ldap != null && ldap.length() > 0) { content.setBorder(BorderFactory.createTitledBorder("LDAP Authentication")); content.setLayout(new FlowLayout(FlowLayout.LEFT)); content.add(new JLabel(ldap)); return content; } content.setBorder(BorderFactory.createTitledBorder("Change Password")); content.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(0, 2, 2, 0); c.gridx = 0; c.gridy = 0; c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE; c.weightx = 0.0; if (MetadataViewerAgent.isAdministrator()) { content.add(UIUtilities.setTextFont(PASSWORD_NEW), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(passwordNew, c); } else { content.add(UIUtilities.setTextFont(PASSWORD_OLD), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(oldPassword, c); c.gridy++; c.gridx = 0; c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE; c.weightx = 0.0; content.add(UIUtilities.setTextFont(PASSWORD_NEW), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(passwordNew, c); c.gridy++; c.gridx = 0; c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE; c.weightx = 0.0; content.add(UIUtilities.setTextFont(PASSWORD_CONFIRMATION), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; content.add(passwordConfirm, c); c.gridy++; c.gridx = 0; } JPanel p = new JPanel(); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.add(content); JPanel buttonPanel = UIUtilities.buildComponentPanel(passwordButton); buttonPanel.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(buttonPanel); return p; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.UserProfile.java
/** Builds and lays out the UI. */ void buildGUI() { removeAll();//from w ww . j a v a 2 s . c o m initComponents(); setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(0, 2, 2, 0); c.gridx = 0; c.gridy = 0; c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.weightx = 1.0; add(buildContentPanel(), c); if (model.isUserOwner(model.getRefObject()) || MetadataViewerAgent.isAdministrator()) { c.gridy++; JPanel buttonPanel = UIUtilities.buildComponentPanel(saveButton); buttonPanel.setBackground(UIUtilities.BACKGROUND_COLOR); add(buttonPanel, c); c.gridy++; add(Box.createVerticalStrut(5), c); c.gridy++; add(buildPasswordPanel(), c); } ExperimenterData exp = (ExperimenterData) model.getRefObject(); BufferedImage photo = model.getUserPhoto(exp.getId()); if (photo == null) setUserPhoto(null); else setUserPhoto(photo); deletePhoto.setVisible(photo != null && canModifyPhoto()); }
From source file:org.openmicroscopy.shoola.agents.metadata.rnd.GraphicsPane.java
/** * Builds hosting the various sliders/* w ww .ja v a 2s . c om*/ * * @return See above. */ private JPanel buildGeneralPane() { JPanel content = new JPanel(); content.setBackground(UIUtilities.BACKGROUND_COLOR); content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); content.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.WEST; c.insets = new Insets(0, 2, 2, 0); c.gridy = 0; c.gridx = 0; if (model.isGeneralIndex()) { content.add(previewToolBar, c); c.gridy++; c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.HORIZONTAL; content.add(new JSeparator(), c); c.gridy++; } content.add(controlsBar, c); c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last c.fill = GridBagConstraints.NONE;//reset to default c.weightx = 0.0; Iterator<ChannelSlider> i = sliders.iterator(); while (i.hasNext()) { c.gridy++; content.add(i.next(), c); } c.gridy++; c.gridwidth = GridBagConstraints.REMAINDER; //end row c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.weighty = 1.0; content.add(viewedBy, c); JPanel p = UIUtilities.buildComponentPanel(content); p.setBackground(content.getBackground()); return p; }
From source file:org.openmicroscopy.shoola.agents.metadata.rnd.GraphicsPane.java
/** * Builds and lays out the slider./*w w w .j a v a 2 s. com*/ * * @return See above. */ private JPanel buildPane() { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.setBackground(UIUtilities.BACKGROUND_COLOR); p.add(codomainSlider); return p; }
From source file:org.openmicroscopy.shoola.agents.metadata.rnd.GraphicsPane.java
/** * Builds and lays out the images as seen by other experimenters. * /* w w w .jav a 2s . c o m*/ * @param results The thumbnails to lay out. */ void displayViewedBy(List results) { if (results == null) return; JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); p.setBackground(UIUtilities.BACKGROUND_COLOR); Iterator<ViewedByItem> i = results.iterator(); JPanel row = null; int index = 0; ViewedByItem item; int maxPerRow = 2; while (i.hasNext()) { item = i.next(); if (index == 0) { row = new JPanel(); row.setBackground(UIUtilities.BACKGROUND_COLOR); row.setLayout(new FlowLayout(FlowLayout.LEFT)); row.add(item); index++; } else if (index == maxPerRow) { row.add(item); p.add(row); index = 0; } else { row.add(item); index++; } } if (index > 0) p.add(row); viewedBy.removeAll(); JPanel content = UIUtilities.buildComponentPanel(p); content.setBackground(UIUtilities.BACKGROUND_COLOR); viewedBy.add(content); viewedBy.setVisible(true); viewedBy.setCollapsed(false); }