List of usage examples for javax.swing JComponent setOpaque
@BeanProperty(expert = true, description = "The component's opacity") public void setOpaque(boolean isOpaque)
From source file:GUI.PizzaCat.java
/** * Create the GUI and show it. As with all GUI code, this must run on the * event-dispatching thread./*www.j av a2s. c o m*/ */ public void createAndShowGUI() { // Create and set up the window. //new PizzaCat().setVisible(true); JFrame frame = new JFrame("Processing Results"); frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); // Create and set up the content pane. JComponent newContentPane = new ProgressBarDemo(); newContentPane.setOpaque(true); // content panes must be opaque frame.setContentPane(newContentPane); // Display the window. frame.pack(); frame.setVisible(true); }
From source file:base.BasePlayer.Main.java
private static void createAndShowGUI() { try {//ww w . j a v a2s . co m /* if(System.getProperty("os.name").toLowerCase().contains("nux")) { } else { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } */ // SystemUtils.IS_OS_WINDOWS // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } JFrame.setDefaultLookAndFeelDecorated(false); frame = new JFrame("BasePlayer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(true); JComponent newContentPane = new Main(); newContentPane.setOpaque(true); frame.setContentPane(newContentPane); frame.pack(); frame.setVisible(true); }
From source file:edu.ku.brc.af.ui.forms.FormViewObj.java
/** * Sets the component into the object//from w w w .jav a2 s.co m * @param formComp the UI component that represents this viewable */ public void setFormComp(final JComponent formComp) { // Remove existing component if (this.formComp != null) { mainComp.remove(this.formComp); } // add new component if (MultiView.isOptionOn(options, MultiView.NO_SCROLLBARS)) { if (ViewFactory.isFormTransparent()) { formComp.setOpaque(false); } this.mainComp.add(formComp, BorderLayout.CENTER); this.formComp = formComp; } else { JScrollPane scrollPane = new JScrollPane(formComp, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.getVerticalScrollBar().setUnitIncrement(10); scrollPane.setBorder(null); this.mainComp.add(scrollPane, BorderLayout.CENTER); this.formComp = scrollPane; if (ViewFactory.isFormTransparent()) { scrollPane.setOpaque(false); scrollPane.getViewport().setOpaque(false); } } if (businessRules != null && !hasInitBR) { businessRules.initialize(this); hasInitBR = true; } // This is needed to make the form layout correctly //XXX I hate that I have to do this SwingUtilities.invokeLater(new Runnable() { public void run() { //mainComp.invalidate(); //mainComp.validate(); //mainComp.doLayout(); UIRegistry.forceTopFrameRepaint(); } }); }
From source file:org.codinjutsu.tools.nosql.couchbase.view.CouchbasePanel.java
protected void addCommonsActions() { final TreeExpander treeExpander = new TreeExpander() { @Override//from w w w . j ava 2 s . c o m public void expandAll() { CouchbasePanel.this.expandAll(); } @Override public boolean canExpand() { return true; } @Override public void collapseAll() { CouchbasePanel.this.collapseAll(); } @Override public boolean canCollapse() { return true; } }; CommonActionsManager actionsManager = CommonActionsManager.getInstance(); final AnAction expandAllAction = actionsManager.createExpandAllAction(treeExpander, resultPanel); final AnAction collapseAllAction = actionsManager.createCollapseAllAction(treeExpander, resultPanel); Disposer.register(this, new Disposable() { @Override public void dispose() { collapseAllAction.unregisterCustomShortcutSet(resultPanel); expandAllAction.unregisterCustomShortcutSet(resultPanel); } }); DefaultActionGroup actionResultGroup = new DefaultActionGroup("CouchbaseResultGroup", true); actionResultGroup.add(new ExecuteQuery<>(this)); actionResultGroup.addSeparator(); actionResultGroup.add(expandAllAction); actionResultGroup.add(collapseAllAction); ActionToolbar actionToolBar = ActionManager.getInstance().createActionToolbar("CouchbaseResultGroupActions", actionResultGroup, true); actionToolBar.setLayoutPolicy(ActionToolbar.AUTO_LAYOUT_POLICY); JComponent actionToolBarComponent = actionToolBar.getComponent(); actionToolBarComponent.setBorder(null); actionToolBarComponent.setOpaque(false); toolBarPanel.add(actionToolBarComponent, BorderLayout.CENTER); }
From source file:org.codinjutsu.tools.nosql.redis.view.RedisPanel.java
protected void addCommonsActions() { final TreeExpander treeExpander = new TreeExpander() { @Override//www. j a v a 2s.c om public void expandAll() { RedisPanel.this.expandAll(); } @Override public boolean canExpand() { return true; } @Override public void collapseAll() { RedisPanel.this.collapseAll(); } @Override public boolean canCollapse() { return true; } }; CommonActionsManager actionsManager = CommonActionsManager.getInstance(); final AnAction expandAllAction = actionsManager.createExpandAllAction(treeExpander, resultPanel); final AnAction collapseAllAction = actionsManager.createCollapseAllAction(treeExpander, resultPanel); Disposer.register(this, new Disposable() { @Override public void dispose() { collapseAllAction.unregisterCustomShortcutSet(resultPanel); expandAllAction.unregisterCustomShortcutSet(resultPanel); } }); DefaultActionGroup actionResultGroup = new DefaultActionGroup("RedisResultGroup", true); actionResultGroup.add(new ExecuteQuery<>(this)); actionResultGroup.addSeparator(); actionResultGroup.add(new EnableGroupingAction(this)); actionResultGroup.add(new SetSeparatorAction(this)); actionResultGroup.addSeparator(); actionResultGroup.add(expandAllAction); actionResultGroup.add(collapseAllAction); ActionToolbar actionToolBar = ActionManager.getInstance().createActionToolbar("MongoResultGroupActions", actionResultGroup, true); actionToolBar.setLayoutPolicy(ActionToolbar.AUTO_LAYOUT_POLICY); JComponent actionToolBarComponent = actionToolBar.getComponent(); actionToolBarComponent.setBorder(null); actionToolBarComponent.setOpaque(false); toolBarPanel.add(actionToolBarComponent, BorderLayout.CENTER); }
From source file:org.datacleaner.widgets.table.DCTableCellRenderer.java
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { logger.debug("getTableCellRendererComponent({},{})", row, column); if (value != null) { if (value.getClass().isArray()) { // arrays are printed nicely this way value = ArrayUtils.toString(value); }/* www. j a v a 2 s .c om*/ } // icons are displayed as labels if (value instanceof Icon) { final JLabel label = new JLabel((Icon) value); label.setOpaque(true); value = label; } final Component result; // render components directly if (value instanceof JComponent) { final JComponent component = (JComponent) value; component.setOpaque(true); if (component.getMouseListeners().length == 0) { component.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { MouseEvent newEvent = SwingUtilities.convertMouseEvent(component, e, _table); _table.consumeMouseClick(newEvent); } }); } result = component; } else { result = _delegate.getTableCellRendererComponent(_table, value, isSelected, hasFocus, row, column); assert result instanceof JLabel; } // alignment is applied to all labels or panels (with flowlayout) Alignment alignment = _alignmentOverrides.get(column); if (alignment == null) { alignment = Alignment.LEFT; } // set alignment if (value instanceof JPanel) { final LayoutManager layout = ((JPanel) value).getLayout(); if (layout instanceof FlowLayout) { final FlowLayout flowLayout = (FlowLayout) layout; flowLayout.setAlignment(alignment.getFlowLayoutAlignment()); } } else if (result instanceof JLabel) { final JLabel label = (JLabel) result; label.setHorizontalAlignment(alignment.getSwingContstantsAlignment()); WidgetUtils.setAppropriateFont(label); } return result; }
From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java
/** * Sets the defaults for the specified area. * /*from ww w . ja v a2s. c o m*/ * @param area The text area. */ public static void setTextAreaDefault(JComponent area) { if (area == null) return; area.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); //area.setForeground(STEELBLUE); area.setBackground(BACKGROUND); area.setOpaque(true); if (area instanceof JTextComponent) ((JTextComponent) area).setEditable(true); }
From source file:tufts.vue.EditLibraryPanel.java
private void layoutConfig() { if (DEBUG.BOXES) { cui.setBorder(BorderFactory.createLineBorder(Color.green)); this.setBorder(BorderFactory.createLineBorder(Color.red)); }/* ww w . j a v a 2 s.co m*/ final GridBagConstraints gbc = new GridBagConstraints(); final GridBagLayout gridbag = new GridBagLayout(); setLayout(gridbag); // Set up common GBC config: gbc.insets = (Insets) tufts.vue.gui.GUI.WidgetInsets.clone(); gbc.insets.bottom = 0; gbc.weightx = 1; gbc.weighty = 0; //------------------------------------------------------- // Add ConfigurationUI //------------------------------------------------------- gbc.anchor = GridBagConstraints.NORTH; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.gridy = 0; add(cui, gbc); //------------------------------------------------------- // Add Save button //------------------------------------------------------- gbc.gridwidth = 1; gbc.gridy = 1; gbc.ipadx = 15; // this actually makes the button wider gbc.anchor = GridBagConstraints.NORTHEAST; gbc.fill = GridBagConstraints.NONE; add(updateButton, gbc); //------------------------------------------------------- // Add a default vertical expander so above content // will float to top. //------------------------------------------------------- gbc.ipadx = 0; gbc.gridy = 2; gbc.weighty = 1; // this is the key for the expander to work (non-zero y-weight) gbc.fill = GridBagConstraints.BOTH; gbc.gridheight = GridBagConstraints.REMAINDER; gbc.gridwidth = 0; final JComponent fill; if (DEBUG.BOXES) { fill = new JLabel(VueResources.getString("jlabel.fill"), JLabel.CENTER); fill.setBackground(Color.gray); fill.setOpaque(true); } else { fill = new JPanel(); } add(fill, gbc); }
From source file:tufts.vue.ui.InspectorPane.java
/** labels & values must be of same length */ private void addLabelTextRows(int starty, JLabel[] labels, JComponent[] values, Container gridBag, Font labelFace, Font fieldFace) { // Note that the resulting alignment ends up being somehow FONT dependent! // E.g., works great with Lucida Grand (MacOSX), but with system default, // if the field value is a wrapping JTextPane (thus gets taller as window // gets narrower), the first line of text rises slightly and is no longer // in line with it's label. GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.EAST; c.weighty = 0;//from ww w . ja v a2 s . c om c.gridheight = 1; for (int i = 0; i < labels.length; i++) { //out("ALTR[" + i + "] label=" + GUI.name(labels[i]) + " value=" + GUI.name(values[i])); boolean centerLabelVertically = false; final JLabel label = labels[i]; final JComponent field = values[i]; if (labelFace != null) GUI.apply(labelFace, label); if (field instanceof JTextComponent) { if (field instanceof JTextField) centerLabelVertically = true; // JTextComponent textField = (JTextComponent) field; // editable = textField.isEditable(); // if (field instanceof JTextArea) { // JTextArea textArea = (JTextArea) field; // c.gridheight = textArea.getRows(); // } else if (field instanceof JTextField) } else { if (fieldFace != null) GUI.apply(fieldFace, field); } //------------------------------------------------------- // Add the field label //------------------------------------------------------- c.gridx = 0; c.gridy = starty++; c.insets = labelInsets; c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last in row c.fill = GridBagConstraints.NONE; // the label never grows if (centerLabelVertically) c.anchor = GridBagConstraints.EAST; else c.anchor = GridBagConstraints.NORTHEAST; c.weightx = 0.0; // do not expand gridBag.add(label, c); //------------------------------------------------------- // Add the field value //------------------------------------------------------- c.gridx = 1; c.gridwidth = GridBagConstraints.REMAINDER; // last in row c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.CENTER; //c.anchor = GridBagConstraints.NORTH; c.insets = fieldInsets; c.weightx = 1.0; // field value expands horizontally to use all space gridBag.add(field, c); } // add a default vertical expander to take up extra space // (so the above stack isn't vertically centered if it // doesn't fill the space). c.weighty = 1; c.weightx = 1; c.gridx = 0; c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; JComponent defaultExpander = new JPanel(); defaultExpander.setPreferredSize(new Dimension(Short.MAX_VALUE, 1)); if (DEBUG.BOXES) { defaultExpander.setOpaque(true); defaultExpander.setBackground(Color.red); } else defaultExpander.setOpaque(false); gridBag.add(defaultExpander, c); }
From source file:uk.ac.ebi.demo.picr.swing.PICRBLASTDemo.java
/** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread.//from w ww . j av a2 s. c o m */ private static void createAndShowGUI() { //Create and set up the window. JFrame frame = new JFrame("Map by BLAST Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Create and set up the content pane. JComponent newContentPane = new PICRBLASTDemo(); newContentPane.setOpaque(true); //content panes must be opaque frame.setContentPane(newContentPane); //Display the window. frame.pack(); frame.setVisible(true); }