Example usage for javax.swing JPanel setLayout

List of usage examples for javax.swing JPanel setLayout

Introduction

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

Prototype

public void setLayout(LayoutManager mgr) 

Source Link

Document

Sets the layout manager for this container.

Usage

From source file:logdruid.ui.mainpanel.StatRecordingSelectorPanel.java

/**
 * Create the panel./*  w ww.ja  v  a 2 s . com*/
 */
public StatRecordingSelectorPanel(final Repository rep, Source src) {
    repository = rep;
    source = src;
    records = rep.getRecordings(StatRecording.class);
    // Collections.sort(records);
    Iterator it = records.iterator();
    while (it.hasNext()) {
        Recording record = (Recording) it.next();
        data.add(new Object[] { record.getName(), record.getRegexp(), record.getType(),
                src.isActiveRecordingOnSource(record) });
    }

    model = new logdruid.ui.mainpanel.StatRecordingSelectorPanel.MyTableModel(data, header);

    StatRecordingSelectorPanel thiis = this;
    logger.info("source is " + ((source == null) ? "null" : src.getSourceName()));
    setLayout(new BorderLayout(0, 0));

    JPanel panel_1 = new JPanel();
    panel_1.setLayout(new BorderLayout(0, 0));

    table = new JTable(model);
    JScrollPane scrollPane = new JScrollPane(table);
    panel_1.add(scrollPane, BorderLayout.CENTER);

    table.setPreferredScrollableViewportSize(new Dimension(0, 150));
    table.setFillsViewportHeight(true);
    table.setAutoCreateRowSorter(true);
    // Set up column sizes.
    initColumnSizes(table);

    JSplitPane splitPane = new JSplitPane();
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    add(splitPane);

    jPanelDetail = new JPanel();
    splitPane.setBottomComponent(jPanelDetail);
    splitPane.setTopComponent(panel_1);
    jPanelDetail.setLayout(new BorderLayout(0, 0));
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            int selectedRow = ((table.getSelectedRow() != -1)
                    ? table.convertRowIndexToModel(table.getSelectedRow())
                    : -1);
            logger.info("ListSelectionListener - selectedRow: " + selectedRow);
            if (selectedRow >= 0) {
                if (jPanelDetail != null) {
                    logger.debug("ListSelectionListener - valueChanged");
                    jPanelDetail.removeAll();
                    recEditor = getEditor(repository.getRecording(StatRecording.class, selectedRow));
                    if (recEditor != null) {
                        jPanelDetail.add(recEditor, BorderLayout.CENTER);
                    }
                    jPanelDetail.revalidate();
                }
            }
        }
    });
    if (repository.getRecordings(StatRecording.class).size() > 0) {
        recEditor = getEditor(repository.getRecording(StatRecording.class, 0));
        jPanelDetail.add(recEditor, BorderLayout.CENTER);
        table.setRowSelectionInterval(0, 0);
    }
    if (model.getRowCount() > 0) {
        table.getRowSorter().toggleSortOrder(0);
        table.setRowSelectionInterval(0, 0);

    }
}

From source file:com.mindcognition.mindraider.ui.swing.concept.annotation.renderer.AbstractTextAnnotationRenderer.java

protected void init(AnnotationToHtmlTransformer editorToViewerTransfomer, KeyListener editorKeyListener,
        KeyListener viewerKeyListener, FocusListener editorFocusListener, FocusListener viewerFocusListener,
        MouseListener editorMouseListener, MouseListener viewerMouseListener, TextAnnotationToolbar toolbar) {
    this.editorToViewerTransfomer = editorToViewerTransfomer;
    this.toolbar = toolbar;

    setLayout(new BorderLayout());

    JPanel editorViewerPanel = new JPanel();
    editorViewerPanel.setLayout(new BoxLayout(editorViewerPanel, BoxLayout.Y_AXIS));

    // editor/*www . j a  va  2s  . c  o m*/
    editor = new JTextArea(30, 100);
    configureEditor(editor);
    editor.addKeyListener(editorKeyListener);
    editor.addFocusListener(editorFocusListener);
    editor.addMouseListener(editorMouseListener);
    // TODO bundle
    editorScroll = encapsulateToScroll(editor, " Editor ");
    editorViewerPanel.add(editorScroll);
    editorScroll.setVisible(false);

    // view
    viewer = new JTextPane();
    configureViewer(viewer);
    viewer.addKeyListener(viewerKeyListener);
    viewer.addFocusListener(viewerFocusListener);
    viewer.addMouseListener(viewerMouseListener);
    // TODO bundle
    viewerScroll = encapsulateToScroll(viewer, " Viewer ");
    editorViewerPanel.add(viewerScroll);

    add(editorViewerPanel, BorderLayout.CENTER);
    // toolbar
    if (toolbar != null) {
        add(toolbar, BorderLayout.SOUTH);
    }

    // let the container to redraw its content (hide/show)
    validate();
}

From source file:ExpenseReport.java

public ExpenseReport() {
    super("Expense Report");
    setSize(570, 200);/*  w  w  w . ja v  a2  s .  c o  m*/

    m_data = new ExpenseReportData(this);

    m_table = new JTable();
    m_table.setAutoCreateColumnsFromModel(false);
    m_table.setModel(m_data);
    m_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    for (int k = 0; k < ExpenseReportData.m_columns.length; k++) {
        TableCellRenderer renderer;
        if (k == ExpenseReportData.COL_APPROVED)
            renderer = new CheckCellRenderer();
        else {
            DefaultTableCellRenderer textRenderer = new DefaultTableCellRenderer();
            textRenderer.setHorizontalAlignment(ExpenseReportData.m_columns[k].m_alignment);
            renderer = textRenderer;
        }

        TableCellEditor editor;

        if (k == ExpenseReportData.COL_CATEGORY)
            editor = new DefaultCellEditor(new JComboBox(ExpenseReportData.CATEGORIES));
        else if (k == ExpenseReportData.COL_APPROVED)
            editor = new DefaultCellEditor(new JCheckBox());
        else
            editor = new DefaultCellEditor(new JTextField());

        TableColumn column = new TableColumn(k, ExpenseReportData.m_columns[k].m_width, renderer, editor);
        m_table.addColumn(column);
    }

    JTableHeader header = m_table.getTableHeader();
    header.setUpdateTableInRealTime(false);

    JScrollPane ps = new JScrollPane();
    ps.setSize(550, 150);
    ps.getViewport().add(m_table);
    getContentPane().add(ps, BorderLayout.CENTER);

    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));

    ImageIcon penny = new ImageIcon("penny.gif");
    m_title = new JLabel("Total: $", penny, JButton.LEFT);
    m_title.setForeground(Color.black);
    m_title.setAlignmentY(0.5f);
    p.add(m_title);
    p.add(Box.createHorizontalGlue());

    JButton bt = new JButton("Insert before");
    bt.setMnemonic('b');
    bt.setAlignmentY(0.5f);
    ActionListener lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int row = m_table.getSelectedRow();
            m_data.insert(row);
            m_table.tableChanged(
                    new TableModelEvent(m_data, row, row, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT));
            m_table.repaint();
        }
    };
    bt.addActionListener(lst);
    p.add(bt);

    bt = new JButton("Insert after");
    bt.setMnemonic('a');
    bt.setAlignmentY(0.5f);
    lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int row = m_table.getSelectedRow();
            m_data.insert(row + 1);
            m_table.tableChanged(new TableModelEvent(m_data, row + 1, row + 1, TableModelEvent.ALL_COLUMNS,
                    TableModelEvent.INSERT));
            m_table.repaint();
        }
    };
    bt.addActionListener(lst);
    p.add(bt);

    bt = new JButton("Delete row");
    bt.setMnemonic('d');
    bt.setAlignmentY(0.5f);
    lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int row = m_table.getSelectedRow();
            if (m_data.delete(row)) {
                m_table.tableChanged(new TableModelEvent(m_data, row, row, TableModelEvent.ALL_COLUMNS,
                        TableModelEvent.INSERT));
                m_table.repaint();
                calcTotal();
            }
        }
    };
    bt.addActionListener(lst);
    p.add(bt);

    getContentPane().add(p, BorderLayout.SOUTH);

    calcTotal();

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);

    setVisible(true);
}

From source file:it.cnr.icar.eric.client.ui.swing.FindParamsPanel.java

private JPanel createParamEntryParentPanel() throws JAXRException {
    JPanel paramEntryParentPanel = new JPanel();
    cardLayout = new CardLayout();
    paramEntryParentPanel.setLayout(cardLayout);

    ConfigurationType uiConfigurationType = UIUtility.getInstance().getConfigurationType();

    //The panel used for business query based searches
    businessPanel = new BusinessQueryPanel(this, uiConfigurationType);
    paramEntryParentPanel.add(businessPanel, "businessPanel");

    //The panel used for ad hoc query based searches
    adhocPanel = new AdhocQuerySearchPanel(this, uiConfigurationType);
    paramEntryParentPanel.add(adhocPanel, "adhocPanel");

    return paramEntryParentPanel;
}

From source file:fsart.diffTools.gui.DiffToolsMainPanel.java

/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it by your code!
 *
 * @noinspection ALL/*from  www . j av  a  2  s .c o m*/
 */
private void $$$setupUI$$$() {
    panel1 = new JPanel();
    panel1.setLayout(new BorderLayout(0, 0));
    final Spacer spacer1 = new Spacer();
    panel1.add(spacer1, BorderLayout.WEST);
    final Spacer spacer2 = new Spacer();
    panel1.add(spacer2, BorderLayout.EAST);
    final Spacer spacer3 = new Spacer();
    panel1.add(spacer3, BorderLayout.SOUTH);
    final Spacer spacer4 = new Spacer();
    panel1.add(spacer4, BorderLayout.NORTH);
    final JPanel panel2 = new JPanel();
    panel2.setLayout(new FormLayout(
            "left:max(d;4px):noGrow,left:4dlu:noGrow,center:max(d;50px):grow,left:4dlu:noGrow,fill:max(d;4px):noGrow,left:5dlu:noGrow,fill:max(d;4px):noGrow",
            "top:d:grow,top:4dlu:noGrow,top:d:noGrow,top:4dlu:noGrow,center:max(d;25px):noGrow,top:6dlu:noGrow,top:max(d;4px):noGrow,top:4dlu:noGrow,top:max(d;25px):noGrow,top:7dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,bottom:d:grow"));
    panel2.putClientProperty("html.disable", Boolean.FALSE);
    panel1.add(panel2, BorderLayout.CENTER);
    final Spacer spacer5 = new Spacer();
    CellConstraints cc = new CellConstraints();
    panel2.add(spacer5, cc.xy(3, 1, CellConstraints.DEFAULT, CellConstraints.FILL));
    browseButton = new JButton();
    browseButton.setText("Browse");
    panel2.add(browseButton, cc.xy(5, 5));
    comparedFileLabel = new JLabel();
    comparedFileLabel.setText("Compared file :");
    panel2.add(comparedFileLabel, cc.xy(3, 7, CellConstraints.LEFT, CellConstraints.TOP));
    browseButton1 = new JButton();
    browseButton1.setText("Browse");
    panel2.add(browseButton1, cc.xy(5, 9, CellConstraints.DEFAULT, CellConstraints.TOP));
    final Spacer spacer6 = new Spacer();
    panel2.add(spacer6, cc.xy(3, 13, CellConstraints.DEFAULT, CellConstraints.FILL));
    final Spacer spacer7 = new Spacer();
    panel2.add(spacer7, cc.xy(1, 9, CellConstraints.FILL, CellConstraints.DEFAULT));
    final Spacer spacer8 = new Spacer();
    panel2.add(spacer8, cc.xy(7, 7, CellConstraints.FILL, CellConstraints.DEFAULT));
    final JPanel panel3 = new JPanel();
    panel3.setLayout(new FormLayout("fill:d:grow", "center:d:grow"));
    panel2.add(panel3, cc.xyw(3, 11, 3, CellConstraints.FILL, CellConstraints.FILL));
    compareButton = new JButton();
    compareButton.setPreferredSize(new Dimension(100, 29));
    compareButton.setText("Compare");
    panel3.add(compareButton, cc.xy(1, 1, CellConstraints.CENTER, CellConstraints.CENTER));
    baseFileLabel = new JLabel();
    baseFileLabel.setText("Base file :");
    panel2.add(baseFileLabel, cc.xy(3, 3, CellConstraints.FILL, CellConstraints.FILL));
    baseFileTxt = new JTextField();
    baseFileTxt.setMinimumSize(new Dimension(50, 27));
    baseFileTxt.setPreferredSize(new Dimension(50, 27));
    panel2.add(baseFileTxt, cc.xy(3, 5, CellConstraints.FILL, CellConstraints.DEFAULT));
    comparedFileTxt = new JTextField();
    comparedFileTxt.setMinimumSize(new Dimension(50, 27));
    comparedFileTxt.setPreferredSize(new Dimension(100, 27));
    panel2.add(comparedFileTxt, cc.xy(3, 9, CellConstraints.FILL, CellConstraints.DEFAULT));
    outputField = new JTextField();
    outputField.setMinimumSize(new Dimension(50, 27));
    outputField.setPreferredSize(new Dimension(100, 27));
    panel2.add(outputField, cc.xy(3, 15, CellConstraints.FILL, CellConstraints.DEFAULT));
}

From source file:com.supermap.desktop.icloud.CloudLicenseDialog.java

private void initLayout() {
    this.setLayout(new GridBagLayout());

    JPanel panelButton = new JPanel();
    panelButton.setLayout(new GridBagLayout());
    panelButton.add(this.buttonLogin, new GridBagConstraintsHelper(0, 0, 1, 1)
            .setAnchor(GridBagConstraints.EAST).setWeight(0, 0).setInsets(2, 0, 10, 10));
    panelButton.add(this.buttonClose, new GridBagConstraintsHelper(1, 0, 1, 1)
            .setAnchor(GridBagConstraints.EAST).setWeight(0, 0).setInsets(2, 0, 10, 10));

    this.add(panelCloudImage, new GridBagConstraintsHelper(0, 0, 6, 3).setAnchor(GridBagConstraints.NORTH)
            .setFill(GridBagConstraints.BOTH).setWeight(1, 1));
    this.add(panelUserImage, new GridBagConstraintsHelper(0, 3, 1, 3).setInsets(10, 0, 0, 0)
            .setAnchor(GridBagConstraints.NORTH).setFill(GridBagConstraints.BOTH).setWeight(1, 1));
    this.add(labelWarning, new GridBagConstraintsHelper(1, 3, 2, 1).setInsets(20, 5, 10, 5)
            .setAnchor(GridBagConstraints.WEST).setFill(GridBagConstraints.NONE).setWeight(0, 0));
    this.add(labelUserName, new GridBagConstraintsHelper(1, 4, 1, 1).setInsets(10, 5, 10, 5)
            .setAnchor(GridBagConstraints.WEST).setFill(GridBagConstraints.NONE).setWeight(0, 0));
    this.add(textFieldUserName, new GridBagConstraintsHelper(2, 4, 3, 1).setInsets(10, 0, 10, 5)
            .setAnchor(GridBagConstraints.WEST).setFill(GridBagConstraints.HORIZONTAL).setWeight(1, 0));
    this.add(labelRegister, new GridBagConstraintsHelper(5, 4, 1, 1).setInsets(10, 5, 5, 16)
            .setAnchor(GridBagConstraints.WEST).setFill(GridBagConstraints.BOTH).setWeight(1, 1));
    this.add(labelPassWord, new GridBagConstraintsHelper(1, 5, 1, 1).setInsets(0, 5, 0, 5)
            .setAnchor(GridBagConstraints.WEST).setFill(GridBagConstraints.NONE).setWeight(0, 0));
    this.add(fieldPassWord, new GridBagConstraintsHelper(2, 5, 3, 1).setInsets(0, 0, 0, 5)
            .setAnchor(GridBagConstraints.WEST).setFill(GridBagConstraints.HORIZONTAL).setWeight(1, 0));
    this.add(labelFindPassword, new GridBagConstraintsHelper(5, 5, 1, 1).setInsets(0, 5, 0, 16)
            .setAnchor(GridBagConstraints.WEST).setFill(GridBagConstraints.BOTH).setWeight(1, 1));
    this.add(checkBoxSavePassword, new GridBagConstraintsHelper(2, 6, 1, 1).setInsets(0, 5, 5, 5)
            .setAnchor(GridBagConstraints.WEST).setFill(GridBagConstraints.NONE).setWeight(0, 0));
    this.add(checkBoxAutoLogin, new GridBagConstraintsHelper(3, 6, 1, 1).setInsets(0, 0, 5, 5)
            .setAnchor(GridBagConstraints.WEST).setFill(GridBagConstraints.NONE).setWeight(0, 0));
    this.add(panelButton,
            new GridBagConstraintsHelper(0, 7, 6, 1).setAnchor(GridBagConstraints.EAST).setWeight(0, 0));
    this.labelRegister.setPreferredSize(new Dimension(100, 23));
    this.labelFindPassword.setPreferredSize(new Dimension(100, 23));
}

From source file:de.fhbingen.wbs.wpOverview.tabs.APCalendarPanel.java

/**
 * Initialize the work package calendar panel inclusive the listeners.
 *//* www.j  a va2s.  c  om*/
private void init() {
    List<Workpackage> userWp = new ArrayList<Workpackage>(WpManager.getUserWp(WPOverview.getUser()));

    Collections.sort(userWp, new APLevelComparator());

    dataset = createDataset(userWp);
    chart = createChart(dataset);

    final ChartPanel chartPanel = new ChartPanel(chart);

    final JPopupMenu popup = new JPopupMenu();
    JMenuItem miSave = new JMenuItem(LocalizedStrings.getButton().save(LocalizedStrings.getWbs().timeLine()));
    miSave.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent arg0) {

            JFileChooser chooser = new JFileChooser();
            chooser.setFileFilter(new ExtensionAndFolderFilter("jpg", "jpeg")); //NON-NLS
            chooser.setSelectedFile(new File("chart-" //NON-NLS
                    + System.currentTimeMillis() + ".jpg"));
            int returnVal = chooser.showSaveDialog(reference);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                try {
                    File outfile = chooser.getSelectedFile();
                    ChartUtilities.saveChartAsJPEG(outfile, chart, chartPanel.getWidth(),
                            chartPanel.getWidth());
                    Controller.showMessage(
                            LocalizedStrings.getMessages().timeLineSaved(outfile.getCanonicalPath()));
                } catch (IOException e) {
                    Controller.showError(LocalizedStrings.getErrorMessages().timeLineExportError());
                }
            }
        }

    });
    popup.add(miSave);

    chartPanel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(final MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
                popup.show(e.getComponent(), e.getX(), e.getY());
            }
        }

    });
    chartPanel.setMinimumDrawHeight(50 + 15 * userWp.size());
    chartPanel.setMaximumDrawHeight(50 + 15 * userWp.size());
    chartPanel.setMaximumDrawWidth(9999);
    chartPanel.setPreferredSize(
            new Dimension((int) chartPanel.getPreferredSize().getWidth(), 50 + 15 * userWp.size()));

    chartPanel.setPopupMenu(null);

    this.setLayout(new BorderLayout());

    this.removeAll();

    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1;
    constraints.weighty = 1;
    constraints.anchor = GridBagConstraints.NORTHWEST;
    panel.add(chartPanel, constraints);

    panel.setBackground(Color.white);
    this.add(panel, BorderLayout.CENTER);

    GanttRenderer.setDefaultShadowsVisible(false);
    GanttRenderer.setDefaultBarPainter(new BarPainter() {

        @Override
        public void paintBar(final Graphics2D g, final BarRenderer arg1, final int row, final int col,
                final RectangularShape rect, final RectangleEdge arg5) {

            String wpName = (String) dataset.getColumnKey(col);
            int i = 0;
            int spaceCount = 0;
            while (wpName.charAt(i++) == ' ' && spaceCount < 17) {
                spaceCount++;
            }

            g.setColor(new Color(spaceCount * 15, spaceCount * 15, spaceCount * 15));
            g.fill(rect);
            g.setColor(Color.black);
            g.setStroke(new BasicStroke());
            g.draw(rect);
        }

        @Override
        public void paintBarShadow(final Graphics2D arg0, final BarRenderer arg1, final int arg2,
                final int arg3, final RectangularShape arg4, final RectangleEdge arg5, final boolean arg6) {

        }

    });

    ((CategoryPlot) chart.getPlot()).setRenderer(new GanttRenderer() {
        private static final long serialVersionUID = -6078915091070733812L;

        public void drawItem(final Graphics2D g2, final CategoryItemRendererState state,
                final Rectangle2D dataArea, final CategoryPlot plot, final CategoryAxis domainAxis,
                final ValueAxis rangeAxis, final CategoryDataset dataset, final int row, final int column,
                final int pass) {
            super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column, pass);
        }
    });

}

From source file:com.floreantpos.bo.ui.explorer.ModifierExplorer.java

private JPanel buildSearchForm() {
    List<MenuModifierGroup> grpName;
    JPanel panel = new JPanel();
    panel.setLayout(new MigLayout("", "[][]30[][]30[]", "[]20[]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    JLabel nameLabel = new JLabel(Messages.getString("ModifierExplorer.3")); //$NON-NLS-1$
    JLabel groupLabel = new JLabel(Messages.getString("ModifierExplorer.4")); //$NON-NLS-1$
    final JTextField nameField = new JTextField(15);
    grpName = MenuModifierGroupDAO.getInstance().findAll();
    final JComboBox cbGroup = new JComboBox();
    cbGroup.addItem(Messages.getString("ModifierExplorer.5")); //$NON-NLS-1$
    for (MenuModifierGroup s : grpName) {
        cbGroup.addItem(s);/*from  w  w w.  j  av a  2s. c  o m*/
    }

    JButton searchBttn = new JButton(Messages.getString("ModifierExplorer.6")); //$NON-NLS-1$
    panel.add(nameLabel, "align label"); //$NON-NLS-1$
    panel.add(nameField);
    panel.add(groupLabel);
    panel.add(cbGroup);
    panel.add(searchBttn);

    TitledBorder title;
    Border loweredetched;
    loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    title = BorderFactory.createTitledBorder(loweredetched, Messages.getString("ModifierExplorer.8")); //$NON-NLS-1$
    title.setTitleJustification(TitledBorder.LEFT);
    panel.setBorder(title);
    searchBttn.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            List<MenuModifier> modifierList;
            String txName = nameField.getText();
            Object selectedItem = cbGroup.getSelectedItem();
            if (selectedItem instanceof MenuModifierGroup) {
                modifierList = ModifierDAO.getInstance().findModifier(txName, (MenuModifierGroup) selectedItem);
            } else {
                modifierList = ModifierDAO.getInstance().findModifier(txName, null);
            }

            setModifierList(modifierList);
        }
    });
    return panel;
}

From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectAdd.java

/**
 * This method initializes this/*from w w  w . j  a  va 2 s .  c om*/
 * 
 * @return void
 */
private void initialize() {
    GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
    gridBagConstraints10.gridx = 1;
    gridBagConstraints10.anchor = GridBagConstraints.NORTH;
    gridBagConstraints10.insets = new Insets(10, 0, 0, 0);
    gridBagConstraints10.fill = GridBagConstraints.NONE;
    gridBagConstraints10.gridy = 0;
    GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
    gridBagConstraints9.gridx = 0;
    gridBagConstraints9.insets = new Insets(10, 10, 10, 0);
    gridBagConstraints9.fill = GridBagConstraints.BOTH;
    gridBagConstraints9.weightx = 0.1;
    gridBagConstraints9.weighty = 0.1;
    gridBagConstraints9.gridheight = 1;
    gridBagConstraints9.gridy = 0;

    JPanel p = new JPanel();
    p.setSize(600, 300);
    p.setLayout(new GridBagLayout());
    p.add(getJPanelPjtList(), gridBagConstraints9);
    p.add(getJPanelButton(), gridBagConstraints10);

    getContentPane().add(p);
}

From source file:com.emental.mindraider.ui.dialogs.OpenConceptByTagJDialog.java

public OpenConceptByTagJDialog(String dialogTitle, String selectionLabel, String buttonLabel,
        boolean showCancel) {
    super(dialogTitle);

    JPanel framePanel = new JPanel();
    framePanel.setBorder(new EmptyBorder(5, 10, 0, 10));
    framePanel.setLayout(new BorderLayout());

    // NORTH panel
    JPanel northPanel = new JPanel();
    northPanel.setLayout(new BorderLayout());
    northPanel.add(new JLabel(selectionLabel), BorderLayout.NORTH);

    final JTextField tagLabel = new JTextField(TEXTFIELD_WIDTH);

    // data/*w w w . j a v  a  2  s  .  c  o m*/
    tags = MindRaider.tagCustodian.getAllTags();
    ;
    if (tags == null) {
        tagLabel.setEnabled(false);
    }
    tagLabel.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) {
                logger.debug("Openning selected tag...");
                openTagSearchDialog();
            }
        }

        public void keyReleased(KeyEvent keyEvent) {
            getListModel().clear();
            shownTags.clear();
            if (tagLabel.getText().length() > 0) {
                for (TagEntry tag : tags) {
                    if (tag.getTagLabel().toLowerCase().startsWith(tagLabel.getText().toLowerCase())) {
                        getListModel().addElement(tag.getTagLabel() + " (" + tag.getCardinality() + ")");
                        shownTags.add(tag);
                    }
                }
            } else {
                // show all tags
                for (TagEntry tag : tags) {
                    getListModel().addElement(tag.getTagLabel() + " (" + tag.getCardinality() + ")");
                    shownTags.add(tag);
                }
            }
        }

        public void keyTyped(KeyEvent keyEvent) {
        }
    });
    northPanel.add(tagLabel, BorderLayout.SOUTH);
    framePanel.add(northPanel, BorderLayout.NORTH);

    // CENTER panel
    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new BorderLayout());
    centerPanel.add(new JLabel(Messages.getString("OpenConceptByTagJDialog.matchingTags")), BorderLayout.NORTH);

    defaultListModel = new DefaultListModel();
    list = new JList(defaultListModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);
    // list.addListSelectionListener(this);
    list.setVisibleRowCount(15);
    JScrollPane listScrollPane = new JScrollPane(list);
    centerPanel.add(listScrollPane, BorderLayout.SOUTH);
    framePanel.add(centerPanel, BorderLayout.CENTER);

    JPanel southPanel = new JPanel();
    southPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
    JButton openButton = new JButton(buttonLabel);
    southPanel.add(openButton);
    openButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            openTagSearchDialog();
        }
    });

    if (showCancel) {
        JButton cancelButton = new JButton(Messages.getString("OpenNotebookJDialog.cancel"));
        southPanel.add(cancelButton);
        cancelButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                OpenConceptByTagJDialog.this.dispose();
            }
        });
    }

    framePanel.add(southPanel, BorderLayout.SOUTH);

    getContentPane().add(framePanel, BorderLayout.CENTER);

    // show
    pack();
    Gfx.centerAndShowWindow(this);
}