Java Code Examples for javax.swing.JComponent.setName()

The following are Jave code examples for showing how to use setName() of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: TerminalContainerCommon.java   View Source Code Vote up 6 votes
@Override
   public void setTitle(JComponent comp, String title) {
/* OLD
if (title == null)
    title = originalName;
*/

// Remember title in attributes
// It gets recalled when we switch from tabbed to soleComponent mode
Attributes attrs = attributesFor(comp);
attrs.title = title;

// output2 uses the name property of the JComponent to
// remember the title.
// So do we for good measure.
comp.setName(title);

if (!contains(comp))
    return;

setTitleWork(comp, title);
   }
 
Example 2
Project: incubator-netbeans   File: NewProjectWizard.java   View Source Code Vote up 5 votes
@Override
protected WizardDescriptor.Panel<WizardDescriptor> createTemplateChooser() {
    WizardDescriptor.Panel<WizardDescriptor> panel = new ProjectTemplatePanel();
    JComponent jc = (JComponent)panel.getComponent ();
    jc.setPreferredSize( new java.awt.Dimension (500, 340) );
    jc.setName (NbBundle.getBundle (NewProjectWizard.class).getString ("LBL_NewProjectWizard_Name")); // NOI18N
    jc.getAccessibleContext ().setAccessibleName (NbBundle.getBundle (NewProjectWizard.class).getString ("ACSN_NewProjectWizard")); // NOI18N
    jc.getAccessibleContext ().setAccessibleDescription (NbBundle.getBundle (NewProjectWizard.class).getString ("ACSD_NewProjectWizard")); // NOI18N
    jc.putClientProperty (WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, new Integer (0));
    jc.putClientProperty (WizardDescriptor.PROP_CONTENT_DATA, new String[] {
            NbBundle.getBundle (NewProjectWizard.class).getString ("LBL_NewProjectWizard_Name"), // NOI18N
            NbBundle.getBundle (NewProjectWizard.class).getString ("LBL_NewProjectWizard_Dots")}); // NOI18N
            
    return panel;
}
 
Example 3
Project: AgentWorkbench   File: GraphEnvironmentPopupPlugin.java   View Source Code Vote up 5 votes
/**
   * Update edge menu with context sensitive menu items.
   * @param graphEdge the current GraphEdge
   */
  private void updateEdgeMenu(GraphEdge graphEdge) {
      
  	if (this.edgePopup == null) return;
  	
  	// --- Remove the old customized entries ---------------
  	Component[] comps = this.edgePopup.getComponents();
  	for (int i = 0; i < comps.length; i++) {
  		Component comp = comps[i];
  		if (comp!=null && comp.getName()!=null && comp.getName().startsWith(MENU_ITEM_NAME_PREFIX)) {
  			this.edgePopup.remove(comp);
  		}
}
  	
  	// --- Evaluate for a NetworkComponent -----------------
  	Vector<NetworkComponent> netComps = this.getNetworkComponents(graphEdge);
  	if (netComps!=null) {
  		// --- Add the context sensitive JMenueItems -------
  		NetworkComponent netComp = netComps.iterator().next();
  		NetworkModel netModel = this.basicGraphGui.getGraphEnvironmentController().getNetworkModel();
  		NetworkComponentAdapter adapter = netModel.getNetworkComponentAdapter(this.graphController, netComp);
  		if (adapter!=null) {
  			// --- Get the context menu items -------------- 
  			Vector<JComponent> adapterJComponents2Add = adapter.invokeGetJPopupMenuElements(netComp);
      		if (adapterJComponents2Add!=null) {
      			if (adapterJComponents2Add.size()>0) {
      				// --- Add Separator -------------------
      				this.edgePopup.add(this.getNewSeparator(netComp.getId()+ "Adapter"));
      				for (int i = 0; i < adapterJComponents2Add.size(); i++) {
					JComponent item = adapterJComponents2Add.get(i);
					item.setName(MENU_ITEM_NAME_PREFIX + netComp.getId()+ i);
					this.edgePopup.add(item);
				}
      			}
      		}
  		}
  	}
  }
 
Example 4
Project: incubator-netbeans   File: ProjectCustomizerTest.java   View Source Code Vote up 4 votes
public JComponent createComponent(Category category, Lookup context) {
    JComponent c = new JPanel();
    c.setName(name);
    return c;
}
 
Example 5
Project: AgentWorkbench   File: OptionDialog.java   View Source Code Vote up 2 votes
/**
 * Adds a Project-Tab and a new Base Folder (child of root!) to the OptionDialog.
 *
 * @param title the title
 * @param icon the icon
 * @param component the component
 * @param toolTipText the tool tip text
 */
public void addOptionTab(String title, Icon icon, JComponent component, String toolTipText) {
	component.setName(title); 							
	this.jTabbedPaneRight.addTab(title, icon, component, toolTipText);
	this.addOptionTabNode(title);
}