Java Code Examples for javax.swing.JPanel#putClientProperty()

The following examples show how to use javax.swing.JPanel#putClientProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdditionalWizardPanel.java    From netbeans with Apache License 2.0 8 votes vote down vote up
/** Gets component to display. Implements superclass abstract method. 
 * @return <code>AdditionalPanel</code> instance */
protected Component createComponent() {
    JPanel panel = new JPanel();
    
    //Accessibility
    panel.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(AdditionalWizardPanel.class).getString("ACS_AdditionalWizardPanel"));                    
    
    panel.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(2));
    panel.setName(NbBundle.getBundle(getClass()).getString("TXT_ModifyAdditional"));
    panel.setPreferredSize(I18nWizardDescriptor.PREFERRED_DIMENSION);

    panel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    panel.add(getUI(), constraints);
    
    return panel;
}
 
Example 2
Source File: ResourceWizardPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Gets component to display. Implements superclass abstract method. 
 * @return this instance */
protected Component createComponent() {
    JPanel panel = new JPanel(new CardLayout());

    // Accessibility
    panel.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(ResourceWizardPanel.class).getString("ACS_ResourceWizardPanel"));                 
    
    panel.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(1));

    String msgKey = testWizard ? "TXT_SelectTestResource"       //NOI18N
                               : "TXT_SelectResource";          //NOI18N
    panel.setName(NbBundle.getMessage(ResourceWizardPanel.class, msgKey));
    panel.setPreferredSize(I18nWizardDescriptor.PREFERRED_DIMENSION);
    
    panel.add(getUI(), CARD_GUI);

    return panel;
}
 
Example 3
Source File: TestStringWizardPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Gets component to display. Implements superclass abstract method. 
 * @return this instance */
protected Component createComponent() {
    JPanel panel = new JPanel(new CardLayout());
    panel.getAccessibleContext().setAccessibleDescription(
            NbBundle.getMessage(
                    TestStringWizardPanel.class,
                    "ACS_TestStringWizardPanel"));              //NOI18N
    
    panel.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX,
                            Integer.valueOf(2));
    panel.setName(
            NbBundle.getMessage(TestStringWizardPanel.class,
                                "TXT_FoundMissingResource"));   //NOI18N
    panel.setPreferredSize(I18nWizardDescriptor.PREFERRED_DIMENSION);                    
    return panel;
}
 
Example 4
Source File: BlazeSelectWorkspaceControl.java    From intellij with Apache License 2.0 6 votes vote down vote up
public BlazeSelectWorkspaceControl(BlazeNewProjectBuilder builder, Disposable parentDisposable) {
  this.builder = builder;
  this.userSettings = builder.getUserSettings();
  availableWorkspaceTypes =
      BlazeWizardOptionProvider.getInstance()
          .getSelectWorkspaceOptions(this.builder, parentDisposable);
  Preconditions.checkState(
      !availableWorkspaceTypes.isEmpty(), "No project workspace types available to be selected.");

  cardLayout = new CardLayout();
  cardPanel = new JPanel(cardLayout);
  cardPanel.putClientProperty("BorderFactoryClass", PlainSmallWithoutIndent.class.getName());
  cardPanel.setOpaque(false);
  availableWorkspaceTypes.forEach(
      type -> cardPanel.add(type.getUiComponent(), type.getOptionName()));
  workspaceTypeList = new WorkspaceTypeList(availableWorkspaceTypes);
  workspaceTypeList.addListSelectionListener(e -> updateSelection());
  component = initPanel();

  selectInitialItem();
}
 
Example 5
Source File: BlazeSelectWorkspaceControl.java    From intellij with Apache License 2.0 6 votes vote down vote up
private JPanel getSideBar() {
  // initially generated by IntelliJ IDEA GUI Designer
  JPanel sidebar = new JPanel(new GridLayoutManager(1, 1, JBUI.emptyInsets(), -1, -1));
  sidebar.putClientProperty("BorderFactoryClass", PlainSmallWithoutIndent.class.getName());
  JBScrollPane scrollPane = new JBScrollPane();
  scrollPane.setViewportView(workspaceTypeList);
  sidebar.add(
      scrollPane,
      new GridConstraints(
          0,
          0,
          1,
          1,
          GridConstraints.ANCHOR_CENTER,
          GridConstraints.FILL_BOTH,
          GridConstraints.SIZEPOLICY_FIXED,
          GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
          null,
          null,
          null,
          0,
          false));
  return sidebar;
}
 
Example 6
Source File: HardStringWizardPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Gets component to display. Implements superclass abstract method. 
 * @return this instance */
protected Component createComponent() {
    JPanel panel = new JPanel(new CardLayout());
    
    panel.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(HardStringWizardPanel.class).getString("ACS_HardStringWizardPanel"));//NOI18N
    
    panel.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(3));
    panel.setName(NbBundle.getBundle(HardStringWizardPanel.class).getString("TXT_ModifyStrings"));//NOI18N
    panel.setPreferredSize(I18nWizardDescriptor.PREFERRED_DIMENSION);        

    return panel;
}
 
Example 7
Source File: DiffTopComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
DiffTopComponent (MultiDiffPanelController controller) {
    setLayout(new BorderLayout());
    this.controller = controller;
    JPanel panel = controller.getPanel();
    panel.putClientProperty(TopComponent.class, this);
    add(panel, BorderLayout.CENTER);
    getAccessibleContext().setAccessibleName(NbBundle.getMessage(DiffTopComponent.class, "ACSN_Diff_Top_Component")); // NOI18N
    getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(DiffTopComponent.class, "ACSD_Diff_Top_Component")); // NOI18N
}
 
Example 8
Source File: Inspector.java    From pumpernickel with MIT License 5 votes vote down vote up
/**
 * Create a new Inspector that populates a specific panel.
 * 
 * @param panel
 *            the panel to populate.
 */
public Inspector(JPanel panel) {
	Objects.requireNonNull(panel);
	this.panel = panel;
	panel.putClientProperty(PROPERTY_INSPECTOR, this);
	layout = new InspectorLayoutManager(this);
	panel.setLayout(layout);
	clear();
}
 
Example 9
Source File: Inspector.java    From pumpernickel with MIT License 5 votes vote down vote up
/**
 * Append a row containing these elements to this inspector.
 * 
 * @param identifier
 *            the control on the left. This should usually contain text. A
 *            <code>JLabel</code> or a <code>JCheckBox</code> is
 *            recommended.
 * @param controls
 *            a series of controls to group together from left to right. The
 *            cluster of components will be anchored on the left.
 */
public InspectorRowPanel addRow(JComponent identifier,
		JComponent... controls) {
	if (controls.length == 1) {
		return addRow(identifier, controls[0], false);
	}
	prepare(Position.LEAD, identifier);
	JPanel controlPanel = new JPanel(new GridBagLayout());
	controlPanel.setOpaque(false);
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 1;
	c.weighty = 1;
	c.anchor = GridBagConstraints.BASELINE;
	for (int a = 0; a < controls.length; a++) {
		Position pos;

		if (a == 0 && a == controls.length - 1) {
			pos = Position.MAIN_WITH_LEAD_NO_STRETCH;
		} else if (a == 0) {
			pos = Position.MAIN_WITH_LEAD_FIRST_IN_SERIES;
		} else if (a == controls.length - 1) {
			pos = Position.MAIN_WITH_LEAD_LAST_IN_SERIES;
		} else {
			pos = Position.MAIN_WITH_LEAD_MIDDLE_IN_SERIES;
		}
		prepare(pos, controls[a]);

		c.insets = getInsets(pos, controls[a]);
		controlPanel.add(controls[a], c);
		c.gridx++;
	}
	controlPanel.putClientProperty(PROPERTY_WRAPPED, Boolean.TRUE);
	return addRow(new InspectorRow(identifier, controlPanel, false, 0));
}
 
Example 10
Source File: Inspector.java    From pumpernickel with MIT License 5 votes vote down vote up
/**
 * Appends a new row containing 3 objects to this inspector.
 * 
 * The identifier is right-aligned. The leftControl is right-aligned, and
 * the rightControl is right-aligned against the far right margin of the
 * inspector.
 * 
 * @param identifier
 *            the control on the left. This should usually contain text. A
 *            <code>JLabel</code> or a <code>JCheckBox</code> is
 *            recommended.
 * @param leftControl
 *            any other control.
 * @param stretchToFill
 *            whether the <code>leftControl</code> should stretch to fit the
 *            remaining width.
 * @param rightControl
 *            the element to add on the right.
 */
public InspectorRowPanel addRow(JComponent identifier,
		JComponent leftControl, boolean stretchToFill,
		JComponent rightControl) {
	prepare(Position.LEAD, identifier);
	Position pos = stretchToFill ? Position.MAIN_WITH_LEAD_STRETCH_TO_FILL
			: Position.MAIN_WITH_LEAD_NO_STRETCH;
	prepare(pos, leftControl);
	prepare(Position.TRAIL, rightControl);

	JPanel controlPanel = new JPanel(new GridBagLayout());
	controlPanel.setOpaque(false);
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 1;
	c.weighty = 1;
	c.anchor = GridBagConstraints.BASELINE_LEADING;
	c.fill = stretchToFill ? GridBagConstraints.BOTH
			: GridBagConstraints.NONE;
	c.insets = getInsets(pos, leftControl);
	controlPanel.add(leftControl, c);
	c.gridx++;
	c.weightx = 0;
	c.fill = GridBagConstraints.NONE;
	c.anchor = GridBagConstraints.BASELINE_TRAILING;
	c.insets = getInsets(Position.TRAIL, rightControl);
	controlPanel.add(rightControl, c);
	controlPanel.putClientProperty(PROPERTY_WRAPPED, Boolean.TRUE);
	return addRow(new InspectorRow(identifier, controlPanel, false, 0));
}
 
Example 11
Source File: ControlGridLayout.java    From pumpernickel with MIT License 5 votes vote down vote up
public JPanel createGrid(JComponent... components) {
	JPanel panel = new JPanel();
	panel.setUI(new TopBaselinePanelUI());
	panel.putClientProperty(Inspector.PROPERTY_WRAPPED, Boolean.TRUE);
	addContainer(panel);
	panel.setOpaque(false);
	panel.setLayout(this);
	for (JComponent c : components) {
		c.setOpaque(false);
		panel.add(c);
	}
	return panel;
}
 
Example 12
Source File: QPanelUI.java    From pumpernickel with MIT License 5 votes vote down vote up
private Outline getOutline(JPanel c, boolean ideal) {
	String key = ideal ? PROPERTY_CACHED_SCRATCH_OUTLINE
			: PROPERTY_CACHED_REAL_OUTLINE;
	Outline outline = (Outline) c.getClientProperty(key);
	int effectiveWidth = ideal ? 1000 : c.getWidth();
	int effectiveHeight = ideal ? 1000 : c.getHeight();

	if (outline == null
			|| !outline.isValid(effectiveWidth, effectiveHeight)) {
		outline = new Outline(effectiveWidth, effectiveHeight);
		c.putClientProperty(key, outline);
	}

	return outline;
}
 
Example 13
Source File: FeaturesView.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private JPanel createContainer(ProfilerFeature feature) {
    JPanel container = new JPanel(new BorderLayout(0, 0));
    container.putClientProperty(ProfilerFeature.class, feature);
    
    JPanel results = feature.getResultsUI();
    JPanel xresults = new JPanel(new BorderLayout()) {
        public void paint(Graphics g) {
            super.paint(g);
            if (hintLabel != null) {
                Dimension dim = hintLabel.getSize();
                int x = (getWidth() - dim.width) / 2;
                int y = (getHeight() - dim.height) / 2;
                
                g.setColor(hintColor);
                g.fillRect(x - XMAR, y - YMAR, dim.width + XMAR * 2, dim.height + YMAR * 2);
                g.setColor(Color.LIGHT_GRAY);
                g.drawRect(x - XMAR, y - YMAR, dim.width + XMAR * 2, dim.height + YMAR * 2);
                
                g.translate(x, y);
                hintLabel.paint(g);
                g.translate(-x, -y);
            }
        }
    };
    xresults.add(results, BorderLayout.CENTER);
    container.add(xresults, BorderLayout.CENTER);
    
    JPanel settings = feature.getSettingsUI();
    if (settings != null) {
        JPanel pan = new JPanel(new BorderLayout(0, 0)) {
            public void setVisible(boolean visible) {
                super.setVisible(visible);
                for (Component c : getComponents()) c.setVisible(visible);
            }
        };
        pan.setOpaque(true);
        pan.setBackground(UIUtils.getProfilerResultsBackground());
        pan.add(settings, BorderLayout.CENTER);
        JSeparator sep = UIUtils.createHorizontalLine(pan.getBackground());
        pan.add(sep, BorderLayout.SOUTH);
        pan.setVisible(settings.isVisible());
        container.add(pan, BorderLayout.NORTH);
    }
    
    return container;
}
 
Example 14
Source File: FeaturesView.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private JPanel createContainer(ProfilerFeature feature) {
    JPanel container = new JPanel(new BorderLayout(0, 0));
    container.putClientProperty(ProfilerFeature.class, feature);
    
    JPanel results = feature.getResultsUI();
    JPanel xresults = new JPanel(new BorderLayout()) {
        public void paint(Graphics g) {
            super.paint(g);
            if (hintLabel != null) {
                Dimension dim = hintLabel.getSize();
                int x = (getWidth() - dim.width) / 2;
                int y = (getHeight() - dim.height) / 2;
                
                g.setColor(hintColor);
                g.fillRect(x - XMAR, y - YMAR, dim.width + XMAR * 2, dim.height + YMAR * 2);
                g.setColor(Color.LIGHT_GRAY);
                g.drawRect(x - XMAR, y - YMAR, dim.width + XMAR * 2, dim.height + YMAR * 2);
                
                g.translate(x, y);
                hintLabel.paint(g);
                g.translate(-x, -y);
            }
        }
    };
    xresults.add(results, BorderLayout.CENTER);
    container.add(xresults, BorderLayout.CENTER);
    
    JPanel settings = feature.getSettingsUI();
    if (settings != null) {
        JPanel pan = new JPanel(new BorderLayout(0, 0)) {
            public void setVisible(boolean visible) {
                super.setVisible(visible);
                for (Component c : getComponents()) c.setVisible(visible);
            }
        };
        pan.setOpaque(true);
        pan.setBackground(UIUtils.getProfilerResultsBackground());
        pan.add(settings, BorderLayout.CENTER);
        JSeparator sep = UIUtils.createHorizontalLine(pan.getBackground());
        pan.add(sep, BorderLayout.SOUTH);
        pan.setVisible(settings.isVisible());
        container.add(pan, BorderLayout.NORTH);
    }
    
    return container;
}
 
Example 15
Source File: SBOLInputDialog.java    From iBioSim with Apache License 2.0 4 votes vote down vote up
@Override
protected JPanel createTablePanel(AbstractListTableModel<?> tableModel, String title) 
{
	/* Set up Design Table */
	final JTable table = new JTable(tableModel);
	table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
		@Override
		public void valueChanged(ListSelectionEvent event) {
			setSelectAllowed(table.getSelectedRow() >= 0);
		}
	});

	setWidthAsPercentages(table, tableModel.getWidths());

	TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tableModel);
	table.setRowSorter(sorter);

	JScrollPane tableScroller = new JScrollPane(table);
	tableScroller.setPreferredSize(new Dimension(450, 200));
	tableScroller.setAlignmentX(LEFT_ALIGNMENT);

	JLabel tableLabel = new JLabel(title);
	tableLabel.setLabelFor(table);

	JPanel tablePane = new JPanel();
	tablePane.setLayout(new BoxLayout(tablePane, BoxLayout.PAGE_AXIS));
	tablePane.add(tableLabel);
	tablePane.add(Box.createRigidArea(new Dimension(0, 5)));
	tablePane.add(tableScroller);

	tablePane.putClientProperty("table", table);
	tablePane.putClientProperty("scroller", tableScroller);
	tablePane.putClientProperty("label", tableLabel);

	//If the user decide to double click on a design, open the design in SBOLDesigner.
	table.addMouseListener(new MouseAdapter() {
		public void mouseClicked(MouseEvent e) {
			if (e.getClickCount() == 2 && table.getSelectedRow() >= 0 && !showModDefs.isSelected())
			{
				SBOLDocument chosenDesign = getSelection(); 
				gui.openSBOLDesigner(filePath, fileName, chosenDesign.getRootComponentDefinitions(), chosenDesign.getDefaultURIprefix());
				setVisible(false);
			}
		}
	});
	
	return tablePane;
}