Component setName - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Component setName method.

This code example shows how to use the following methods:setName, getText, setText
     * @param commandGroup the command group, must not be <code>null</code> 
     * 
     * @return the menu item 
     */ 
    public JMenuItem createMenuItem(CommandGroup commandGroup) {
        JMenu menu = new JMenu(commandGroup.getAction());
        menu.setName(commandGroup.getCommandID());
        // Ensure that the menu has some text, so that is guranteed to be visible for the user 
        if (menu.getText() == null) {
            menu.setText(commandGroup.getCommandID());
        } 
        enableHelp(menu, commandGroup);
        return menu;
    } 
 
    /** 
     * Creates a tool bar button for the given executable command. 
     * 
     * @param command the executable command, must not be <code>null</code> 
     * 
6
CodeRank
This code example shows how to use the following methods:setName, setBorder, setContinuousLayout, setDividerLocation, setOneTouchExpandable
 
	private static JComponent createSplitPanes(Container container, List<? extends JComponent> components, int start, int end, int divide, int orientation) {
		if (start == end)
			return components.get(start);
		else if (end - start == 1) {
			JSplitPane splitPane = new JSplitPane(orientation, components.get(start), components.get(end));
			splitPane.setDividerLocation(divide);
			splitPane.setContinuousLayout(true);
			splitPane.setOneTouchExpandable(true);
			splitPane.setBorder(null);
			instrumentNames(splitPane);
			return splitPane;
		} 
		else { 
			int middle = (start + end) / 2;
			JSplitPane splitPane = new JSplitPane(orientation, 
								  				  createSplitPanes(container, components, start, middle, divide, orientation),
								  				  createSplitPanes(container, components, middle + 1, end, divide, orientation));
			 
			splitPane.setDividerLocation(divide * (middle + 1));

5
CodeRank
This code example shows how to use the following methods:setBounds, setName, addActionListener, setText
		getContentPane().add(scrollPane);
 
		this.editorPane = new JEditorPane();
		scrollPane.setViewportView(editorPane);
			 
		finishedButton = new JButton();
		finishedButton.setName("buttonDone");
		finishedButton.setBounds(215, 424, 112, 36);
		finishedButton.setText("Finished");
		finishedButton.addActionListener(this);
		getContentPane().add(finishedButton);
 
		 
	} 
	 
	/** 
	 * Creates a CCNFileInputStream to write content to a CCN  
	 * writes the contents from a CCN to the editorPane 
	 *  
	 *<p> 
7
CodeRank
This code example shows how to use the following methods:setName, addActionListener, setActionCommand, setAccelerator
            menu.setEnabled(false);
        } 
    } 
 
    public static JMenuItem makeMenuItem(String label, String name, String actionCommand) {
        JMenuItem newMenuChoice = new JMenuItem(label);
        newMenuChoice.setName(name);
        newMenuChoice.addActionListener(ReportActionRouter.getInstance());
        if (actionCommand != null) {
            newMenuChoice.setActionCommand(actionCommand);
        } 
 
        return newMenuChoice;
    } 
 
    public static JMenuItem makeMenuItem(String label, String name, String actionCommand, KeyStroke accel) {
        JMenuItem item = makeMenuItem(label, name, actionCommand);
        item.setAccelerator(accel);
        return item;
    } 

6
CodeRank
This code example shows how to use the following methods:getBackground, setName, paint
        }); 
    } 
 
    void check(Color c) {
        SwingUtilities.updateComponentTreeUI(label);
        label.paint(g);
        if (label.getBackground().getRGB() != c.getRGB()) {
            System.err.println("Color mismatch!");
            System.err.println("   found: " + label.getBackground());
            System.err.println("   expected: " + c);
            throw new RuntimeException("Test failed");
        } 
    } 
 
    void test() { 
        testOverrides(); 
        testInheritance(); 
        testNames(); 
        testBaseColor(); 
    } 

6
CodeRank
This code example shows how to use the following methods:setName
 
        HorizontalPanel classNamePanel = new HorizontalPanel();
        classNamePanel.add(label);
        classNamePanel.add(classnameCombo);
 
        queueSize = new JTextField("0", 5);  // TODO "0" is a hack to prevent NumberFormatException: For input string: ""
        queueSize.setName("Queue Size"); //$NON-NLS-1$
        JLabel queueSizeLabel = new JLabel(JMeterUtils.getResString("backend_listener_queue_size")); // $NON-NLS-1$
        queueSizeLabel.setLabelFor(queueSize);
        HorizontalPanel queueSizePanel = new HorizontalPanel();
        queueSizePanel.add(queueSizeLabel, BorderLayout.WEST);
        queueSizePanel.add(queueSize);
 
        JPanel panel = new JPanel(new BorderLayout(0, 5));
        panel.add(classNamePanel, BorderLayout.NORTH);
        panel.add(queueSizePanel, BorderLayout.CENTER);
        return panel;
    } 
 
    /** 
6
CodeRank
This code example shows how to use the following methods:setName, addActionListener
    	mainPanel = new JPanel();
    	controlPanel = new JPanel();
        contentPanel = new JXHeader();
        noButton = new JButton("No");
        noButton.setName("no button");
        yesButton = new JButton("Yes");
        yesButton.setName("yes button");
        getRootPane().setDefaultButton(yesButton);
    } 
     
    /** 
     * Binds the {@link #close() close} action to the exit event generated 
     * either by the close icon or by the {@link #yesButton} or 
     * the {@link #noButton}. 
     */ 
    private void attachListeners() 
    { 
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent we) { close(); }
        }); 

6
CodeRank
This code example shows how to use the following methods:setName, setLabelFor
     * Initialize the GUI components and layout. 
     */ 
    private void init() { 
        setLayout(new BorderLayout(5, 0));
        /** The label for the text field. */ 
        JLabel nameLabel = new JLabel(JMeterUtils.getResString("name")); // $NON-NLS-1$
        nameLabel.setName("name");
        nameLabel.setLabelFor(nameField);
 
        add(nameLabel, BorderLayout.WEST);
        add(nameField, BorderLayout.CENTER);
    } 
 
    @Override 
    public void clearGui() { 
        setName(getStaticLabel()); 
    } 
 
    /** 
     * Get the currently displayed name. 
6
CodeRank
This code example shows how to use the following methods:addKeyListener, setName
This code example shows how to use the following methods:setName, setText
    } 
 
    // Initialise the gui field values 
    private void initGui(){ 
        threadInput.setText("1"); // $NON-NLS-1$
        rampInput.setText("1"); // $NON-NLS-1$
        loopPanel.clearGui();
        if (showDelayedStart) {
            delayedStart.setSelected(false);
        } 
        scheduler.setSelected(false);
        Date today = new Date();
        end.setDate(today);
        start.setDate(today);
        delay.setText(""); // $NON-NLS-1$
        duration.setText(""); // $NON-NLS-1$
    } 
 
   private void init() { 
        // THREAD PROPERTIES 

6
CodeRank
setName Method Overview
Sets the name of the component to the specified string.
See Code Examples for other Java 8 Component Methods: