Example usage for javax.swing JPanel setName

List of usage examples for javax.swing JPanel setName

Introduction

In this page you can find the example usage for javax.swing JPanel setName.

Prototype

public void setName(String name) 

Source Link

Document

Sets the name of the component to the specified string.

Usage

From source file:org.kuali.test.handlers.htmltag.DefaultHtmlTagHandler.java

/**
 *
 * @param tag//w w w  .j a v  a 2 s .com
 * @return
 */
protected JPanel getNewPanel(Element tag) {
    JPanel retval = new JPanel();
    retval.setName(getGroupName(tag));
    return retval;
}

From source file:uk.nhs.cfh.dsp.yasb.searchpanel.SearchPanel.java

/**
 * a method that initalises the components.
 *///from   w ww.ja  v a  2 s. c  o m
public synchronized void initComponents() {

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Search"));
    mainPanel.setName("searchPanelMainPanel");

    searchField = new JTextField();
    if (org.jdesktop.swingx.util.OS.isMacOSX()) {
        searchField.putClientProperty("JTextField.variant", "search");
    }
    searchField.setName("searchField");
    searchField.addActionListener(new AbstractAction() {

        public void actionPerformed(ActionEvent arg0) {
            doSearch();

        }
    });

    // create controls panel
    createControlPanel();

    // create button panel
    createButtonPanel();

    // create busy label
    createBusyLabel();

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(searchField, BorderLayout.CENTER);
    panel.add(busyStatusLabel, BorderLayout.EAST);
    JPanel searchPanel = new JPanel(new BorderLayout());
    searchPanel.add(panel, BorderLayout.NORTH);
    searchPanel.add(buttonsPanel, BorderLayout.CENTER);
    searchPanel.add(controlsPane, BorderLayout.SOUTH);

    listModel = new SearchResultsListModel();
    resultsList = new JList(listModel);
    resultsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    renderer = new SearchResultListCellRenderer();
    resultsList.setCellRenderer(renderer);
    // add mouse listener to resultsList
    resultsList.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            // check if double click and get selected object
            if (e.getClickCount() == 2) {
                Object selectedObject = resultsList.getSelectedValue();
                if (selectedObject instanceof Document) {
                    Document document = (Document) selectedObject;
                    String conceptId = document.get("CONCEPTID");
                    SnomedConcept concept = checkAndReturnConceptForID(conceptId);
                    // set focus concept if concept is not null
                    if (concept != null) {
                        // publish as selection
                        selectionService.objectSelected(concept, SearchPanel.this);
                    }
                }
            }
        }
    });

    // add components to main panel
    mainPanel.add(searchPanel, BorderLayout.NORTH);
    mainPanel.add(new JScrollPane(resultsList), BorderLayout.CENTER);

    // add main panel to search panel
    setLayout(new BorderLayout());
    add(mainPanel, BorderLayout.CENTER);
}