Example usage for javax.swing Box add

List of usage examples for javax.swing Box add

Introduction

In this page you can find the example usage for javax.swing Box add.

Prototype

public Component add(Component comp) 

Source Link

Document

Appends the specified component to the end of this container.

Usage

From source file:com.diversityarrays.kdxplore.trials.TrialSelectionDialog.java

@Override
protected Component createBottomRowComponent() {
    Box buttons = Box.createHorizontalBox();
    buttons.add(Box.createHorizontalStrut(10));
    buttons.add(wantTrialUnits);/*from w w  w  . j a v a2  s  .c o  m*/
    if (RunMode.getRunMode().isDeveloper()) {
        wantTrialUnits.setSelected(true);
    }
    buttons.add(new JButton(findTrialRecords));
    buttons.add(Box.createHorizontalGlue());
    buttons.add(new JButton(getOkAction()));
    buttons.add(new JButton(getCancelAction()));
    buttons.add(Box.createHorizontalStrut(10));

    return buttons;
}

From source file:org.kepler.gui.DialogGeneralTab.java

/**
 * getCenterPanel/* w ww  .  j av  a 2s.  c o m*/
 * 
 * @return Component
 */
protected Component getCenterPanel() {
    Box centerPanel = Box.createHorizontalBox();

    final Border middlePanelPaddingBorder = BorderFactory.createEmptyBorder( // top, left, bottom, right
            StaticResources.getSize("dialogs.tabPanels.padding.top", 0), 0, 0, 0);

    centerPanel.setBorder(middlePanelPaddingBorder);

    JLabel noteLbl = WidgetFactory.makeJLabel(
            StaticResources.getDisplayString("dialogs." + _targetType + ".general.note", "Note"),
            TabbedDialog.jLabelDims);
    centerPanel.add(noteLbl);

    noteTxtArea = WidgetFactory.makeJTextArea(_target != null ? _target.getName() : "");
    JScrollPane scrollPane = new JScrollPane(noteTxtArea);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(scrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setWheelScrollingEnabled(true);
    centerPanel.add(scrollPane);

    return centerPanel;
}

From source file:ImageIOTest.java

/**
 * Open a file and load the images./*from   w  w  w.j a va2  s.  co  m*/
 */
public void openFile() {
    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(new File("."));
    String[] extensions = ImageIO.getReaderFileSuffixes();
    chooser.setFileFilter(new FileNameExtensionFilter("Image files", extensions));
    int r = chooser.showOpenDialog(this);
    if (r != JFileChooser.APPROVE_OPTION)
        return;
    File f = chooser.getSelectedFile();
    Box box = Box.createVerticalBox();
    try {
        String name = f.getName();
        String suffix = name.substring(name.lastIndexOf('.') + 1);
        Iterator<ImageReader> iter = ImageIO.getImageReadersBySuffix(suffix);
        ImageReader reader = iter.next();
        ImageInputStream imageIn = ImageIO.createImageInputStream(f);
        reader.setInput(imageIn);
        int count = reader.getNumImages(true);
        images = new BufferedImage[count];
        for (int i = 0; i < count; i++) {
            images[i] = reader.read(i);
            box.add(new JLabel(new ImageIcon(images[i])));
        }
    } catch (IOException e) {
        JOptionPane.showMessageDialog(this, e);
    }
    setContentPane(new JScrollPane(box));
    validate();
}

From source file:com.diversityarrays.kdxplore.trialmgr.TrialManagerApp.java

public TrialManagerApp(KdxPluginInfo pluginInfo) throws IOException {
    super(new BorderLayout());

    this.messagesPanel = pluginInfo.getMessagePrinter();
    this.backgroundRunner = pluginInfo.getBackgroundRunner();
    this.userDataFolder = pluginInfo.getUserDataFolder();
    this.clientProvider = pluginInfo.getClientProvider();
    this.offlineData = pluginInfo.getSingletonSharedResource(OfflineData.class);

    KDSmartApplication.getInstance().setMessagePrinter(pluginInfo.getMessagePrintStream());

    this.driverType = DriverType.getDriverTypeFromSystemProperties(DriverType.H2);

    offlineData.addOfflineDataChangeListener(offlineDataChangeListener);

    linkedIcon = KDClientUtils.getIcon(ImageId.CONNECTED_24);
    unlinkedIcon = KDClientUtils.getIcon(ImageId.DISCONNECTED_24);
    barcodeIcon = KDClientUtils.getIcon(ImageId.BARCODE_PAGE);

    updateDatabaseUrlLabel();/*from   w  w  w  . j a  v  a  2  s . c o m*/

    this.clientProvider.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            handleClientChanged();
        }
    });

    explorerProperties = ExplorerProperties.getInstance();

    PreferenceCollection pc = TrialManagerPreferences.getInstance().getPreferenceCollection(this,
            Msg.APPNAME_TRIAL_MANAGER());
    KdxplorePreferences.getInstance().addPreferenceCollection(pc);

    TraitValue.DISPLAY_DATE_DIFF_AS_NDAYS = explorerProperties.getDisplayElapsedDaysAsCount();

    ExplorerServices explorerServices = new ExplorerServices(pluginInfo, offlineData
    //              , clientProvider
    );

    trialExplorerPanel = new TrialExplorerPanel(this, // KdxApp
            pluginInfo, explorerServices.getKdxDeviceService(), this, // as TrialExplorerManager
            offlineData, driverType, barcodeIcon, clientUrlChanger, trialsLoadedConsumer, traitRemovalHandler);

    tabbedPane.addTab(TAB_TRIALS, KDClientUtils.getIcon(ImageId.KDS_TRIALS), trialExplorerPanel);

    Transformer<Trial, Boolean> checkIfEditorIsActive = new Transformer<Trial, Boolean>() {
        @Override
        public Boolean transform(Trial trial) {
            return trialExplorerPanel.isEditorActiveForTrial(trial);
        }
    };
    traitExplorerPanel = new TraitExplorerPanel(messagesPanel, offlineData, clientProvider,
            //            uploadHandler,
            backgroundRunner, barcodeIcon, checkIfEditorIsActive);

    tabbedPane.addTab(TAB_TRAITS, KDClientUtils.getIcon(ImageId.KDS_TRAITS), traitExplorerPanel);

    tagExplorerPanel = new TagExplorerPanel(offlineData);
    tabbedPane.addTab(TAB_TAGS, KDClientUtils.getIcon(ImageId.BLACK_TAG), tagExplorerPanel);

    // Now tie together those panels that need to talk to each other
    trialExplorerPanel.setTraitExplorer(traitExplorerPanel);

    Box box = Box.createHorizontalBox();

    explorerServices.addActions(box);
    box.add(Box.createHorizontalGlue());
    box.add(databaseUrlLabel);
    box.add(Box.createHorizontalGlue());
    Action action = offlineData.getOfflineDataAction();
    if (action != null) {
        JButton button = new JButton(pluginInfo.getKdxploreIcon());
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (RunMode.getRunMode().isDeveloper()) {
                    if (0 != (ActionEvent.SHIFT_MASK & e.getModifiers())) {
                        openJdbcExplorer();
                        return;
                    }
                }
                action.actionPerformed(e);
            }
        });
        box.add(button);
    }

    add(box, BorderLayout.NORTH);
    add(tabbedPane, BorderLayout.CENTER);
}

From source file:pcgen.gui2.sources.AdvancedSourceSelectionPanel.java

private void initComponents() {
    FlippingSplitPane mainPane = new FlippingSplitPane(JSplitPane.VERTICAL_SPLIT, "advSrcMain");
    FlippingSplitPane topPane = new FlippingSplitPane("advSrcTop");
    topPane.setResizeWeight(0.6);//from ww w  .j  a  v a2  s.c o  m
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(new JLabel(LanguageBundle.getString("in_src_gameLabel")), BorderLayout.WEST); //$NON-NLS-1$

    FacadeComboBoxModel<GameModeDisplayFacade> gameModes = new FacadeComboBoxModel<>();
    gameModes.setListFacade(FacadeFactory.getGameModeDisplays());
    gameModeList.setModel(gameModes);
    gameModeList.addActionListener(this);
    panel.add(gameModeList, BorderLayout.CENTER);

    FilterBar<Object, CampaignFacade> bar = new FilterBar<>(false);
    bar.add(panel, BorderLayout.WEST);
    bar.addDisplayableFilter(new SearchFilterPanel());
    panel = new JPanel(new BorderLayout());
    panel.add(bar, BorderLayout.NORTH);

    availableTable.setDisplayableFilter(bar);
    availableTable.setTreeViewModel(availTreeViewModel);
    availableTable.getSelectionModel().addListSelectionListener(this);
    availableTable.setTreeCellRenderer(new CampaignRenderer());
    ((DynamicTableColumnModel) availableTable.getColumnModel()).getAvailableColumns().get(2)
            .setCellRenderer(new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));

    JScrollPane pane = new JScrollPane(availableTable);
    pane.setPreferredSize(new Dimension(600, 310));
    panel.add(pane, BorderLayout.CENTER);

    Box box = Box.createHorizontalBox();
    unloadAllButton.setAction(new UnloadAllAction());
    box.add(unloadAllButton);
    box.add(Box.createHorizontalGlue());
    addButton.setHorizontalTextPosition(SwingConstants.LEADING);
    addButton.setAction(new AddAction());
    box.add(addButton);
    box.add(Box.createHorizontalStrut(5));
    box.setBorder(new EmptyBorder(0, 0, 5, 0));
    panel.add(box, BorderLayout.SOUTH);

    topPane.setLeftComponent(panel);

    JPanel selPanel = new JPanel(new BorderLayout());
    FilterBar<Object, CampaignFacade> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    selectedTable.setDisplayableFilter(filterBar);

    selectedTable.setTreeViewModel(selTreeViewModel);
    selectedTable.getSelectionModel().addListSelectionListener(this);
    selectedTable.setTreeCellRenderer(new CampaignRenderer());
    ((DynamicTableColumnModel) selectedTable.getColumnModel()).getAvailableColumns().get(2)
            .setCellRenderer(new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
    JScrollPane scrollPane = new JScrollPane(selectedTable);
    scrollPane.setPreferredSize(new Dimension(300, 350));
    selPanel.add(scrollPane, BorderLayout.CENTER);
    box = Box.createHorizontalBox();
    box.add(Box.createHorizontalStrut(5));
    removeButton.setAction(new RemoveAction());
    box.add(removeButton);
    box.add(Box.createHorizontalGlue());
    box.setBorder(new EmptyBorder(0, 0, 5, 0));
    selPanel.add(box, BorderLayout.SOUTH);

    topPane.setRightComponent(selPanel);
    mainPane.setTopComponent(topPane);

    linkAction.install();
    infoPane.setPreferredSize(new Dimension(800, 150));
    mainPane.setBottomComponent(infoPane);
    mainPane.setResizeWeight(0.7);
    setLayout(new BorderLayout());
    add(mainPane, BorderLayout.CENTER);
}

From source file:com.diversityarrays.kdxplore.design.EntryFileImportDialog.java

public EntryFileImportDialog(Window owner, String title, File inputFile, Predicate<Role> entryHeadingFilter) {
    super(owner, title, ModalityType.APPLICATION_MODAL);

    this.entryHeadingFilter = entryHeadingFilter;
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    setGlassPane(backgroundRunner.getBlockingPane());

    useScrollBarOption.addActionListener(new ActionListener() {
        @Override//from  www . j  a  va2 s  .co m
        public void actionPerformed(ActionEvent e) {
            updateDataPreviewScrolling();
        }
    });

    headingRoleTableModel = createHeadingRoleTableModel();
    headingRoleTable = new HeadingRoleTable<>(headingRoleTableModel);
    headingTableScrollPane = new JScrollPane(headingRoleTable);
    GuiUtil.setVisibleRowCount(headingRoleTable, 10);

    JPanel roleAssignmentPanel = new JPanel(new BorderLayout());
    roleAssignmentPanel.add(headingTableScrollPane, BorderLayout.CENTER);

    headingRoleTable.setTransferHandler(flth);
    headingRoleTableModel.addChangeListener(headingRoleChangeListener);

    GuiUtil.setVisibleRowCount(dataPreviewTable, 10);
    dataPreviewTable.setTransferHandler(flth);
    dataPreviewScrollPane.setTransferHandler(flth);
    updateDataPreviewScrolling();

    dataPreviewScrollPane.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            //                boolean useScrollBar = useScrollBarOption.isSelected();
            GuiUtil.initialiseTableColumnWidths(dataPreviewTable, true);
        }
    });

    Box top = Box.createHorizontalBox();
    top.add(new JLabel("# rows to preview: "));
    top.add(new JSpinner(previewRowCountSpinnerModel));
    top.add(Box.createHorizontalGlue());
    top.add(useScrollBarOption);

    JPanel dataPreviewPanel = new JPanel(new BorderLayout());
    dataPreviewPanel.add(GuiUtil.createLabelSeparator("Data Preview", top), BorderLayout.NORTH);
    dataPreviewPanel.add(dataPreviewScrollPane, BorderLayout.CENTER);

    headingWarning.setForeground(Color.RED);
    JLabel instructions = new JLabel("<HTML>Please assign a <i>Role</i> for each of the headings in your data"
            + "<br>You must specify one as the <i>Entry Name</i>."
            + "<br>Click on one of the <i>Role</i> cells and select from the dropdown"
            + "<br>To assign multiple headings, select the rows for which you wish"
            + "<br>to set the <i>Role</i> then right-click and choose from the dropdown.");
    instructions.setHorizontalAlignment(JLabel.CENTER);
    instructions.setBackground(Toast.PALE_YELLOW);

    JScrollPane instScroll = new JScrollPane(instructions);
    instScroll.setBackground(Toast.PALE_YELLOW);

    normalEntryNameField.getDocument()
            .addDocumentListener(new DocumentChangeListener((e) -> updateAcceptButton()));
    normalEntryNameField.setText(TrialDesignPreferences.getInstance().getNormalEntryTypeName());

    JPanel rolesPanel = new JPanel();
    GBH gbh = new GBH(rolesPanel, 2, 2, 0, 0);
    int y = 0;
    gbh.add(0, y, 1, 1, GBH.NONE, 0, 1, GBH.EAST, "Entry Type Name for non-Checks:");
    gbh.add(1, y, 1, 1, GBH.NONE, 1, 1, GBH.WEST, normalEntryNameField);
    gbh.add(2, y, 1, 1, GBH.NONE, 1, 1, GBH.WEST, saveForFuture);
    ++y;

    gbh.add(0, y, 3, 1, GBH.BOTH, 2, 1, GBH.CENTER, roleAssignmentPanel);
    ++y;

    JSplitPane headingsAndInstructions = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, rolesPanel, instScroll);

    JPanel headingPanel = new JPanel(new BorderLayout());
    headingPanel.add(GuiUtil.createLabelSeparator("Assign Roles for Headings"), BorderLayout.NORTH);
    headingPanel.add(headingsAndInstructions, BorderLayout.CENTER);
    headingPanel.add(headingWarning, BorderLayout.SOUTH);

    errorMessage.setEditable(false);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, dataPreviewPanel, headingPanel);
    splitPane.setResizeWeight(0.5);

    cardPanel.add(new JScrollPane(errorMessage), CARD_ERROR);
    cardPanel.add(splitPane, CARD_DATA);

    Box bot = Box.createHorizontalBox();
    bot.add(Box.createHorizontalGlue());
    bot.add(new JButton(cancelAction));
    bot.add(new JButton(acceptAction));
    acceptAction.setEnabled(false);

    Container cp = getContentPane();
    cp.add(cardPanel, BorderLayout.CENTER);
    cp.add(bot, BorderLayout.SOUTH);
    pack();

    sheetNamesComboBox.addActionListener(sheetNamesActionListener);

    Timer timer = new Timer(true);

    previewRowCountSpinnerModel.addChangeListener(new ChangeListener() {
        int nPreview;
        TimerTask timerTask = null;

        @Override
        public void stateChanged(ChangeEvent e) {
            nPreview = previewRowCountSpinnerModel.getNumber().intValue();

            if (timerTask == null) {
                timerTask = new TimerTask() {
                    int lastPreviewCount = nPreview;

                    @Override
                    public void run() {
                        if (lastPreviewCount == nPreview) {
                            System.err.println("Stable at " + lastPreviewCount);
                            // No change, do it now
                            cancel();
                            try {
                                updateDataPreview(lastPreviewCount);
                            } finally {
                                timerTask = null;
                            }
                        } else {
                            System.err.println("Changing from " + lastPreviewCount + " to " + nPreview);
                            lastPreviewCount = nPreview;
                        }
                    }
                };
                timer.scheduleAtFixedRate(timerTask, 500, 100);
            }
        }
    });

    sheetNamesComboBox.setVisible(false);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent e) {
            removeWindowListener(this);
            setFile(inputFile);
        }
    });
}

From source file:com.diversityarrays.kdxplore.trials.TrialSelectionDialog.java

@SuppressWarnings("rawtypes")
@Override// w  w  w .j a v  a  2s .  c  o  m
protected Component createMainPanel() {

    CheckSelectionButtonsPanel csbp = new CheckSelectionButtonsPanel(CheckSelectionButtonsPanel.ALL,
            trialRecordTable);
    csbp.addUncheckAllActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            trialRecordTableModel.clearChosen();
        }
    });
    csbp.addCheckAllActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            trialRecordTableModel.chooseAll();
        }
    });
    csbp.addCheckSelectedActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            List<Integer> selectedModelRows = GuiUtil.getSelectedModelRows(trialRecordTable);
            trialRecordTableModel.addChosenRows(selectedModelRows);
        }
    });
    csbp.addCheckUnselectedActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Set<Integer> selectedModelRows = new HashSet<>(GuiUtil.getSelectedModelRows(trialRecordTable));
            if (selectedModelRows.isEmpty()) {
                trialRecordTableModel.chooseAll();
            } else {
                List<Integer> rowsToChoose = new ArrayList<>();
                for (int mrow = trialRecordTable.getRowCount(); --mrow >= 0;) {
                    if (!selectedModelRows.contains(mrow)) {
                        rowsToChoose.add(mrow);
                    }
                }
                trialRecordTableModel.addChosenRows(rowsToChoose);
            }
        }
    });

    Box buttons = Box.createHorizontalBox();
    buttons.add(Box.createHorizontalGlue());
    buttons.add(new JLabel("Select one or more and click '" + USE_TRIALS + "'"));
    buttons.add(csbp);
    buttons.add(Box.createHorizontalGlue());

    List<TableColumn> columns = DartEntityTableModel.collectNamedColumns(trialRecordTable,
            trialRecordTableModel, true, "TrialName", "Site", "# Plots", "# Measurements", "Design", "Manager",
            "TrialType", "Project", "Start Date");
    //      List<TableColumn> columns = DartEntityTableModel.collectNonExpertColumns(trialRecordTable, trialRecordTableModel, true);

    Map<String, TableColumn[]> choices = new HashMap<>();
    choices.put(INITIAL_COLUMNS_TAGNAME, columns.toArray(new TableColumn[columns.size()]));

    TableColumnSelectionButton tcsb = new TableColumnSelectionButton(trialRecordTable, choices);
    tcsb.setSelectedColumns(INITIAL_COLUMNS_TAGNAME);

    trialRecordTable.setRowSorter(new TableRowSorter<DartEntityTableModel>(trialRecordTableModel));

    JScrollPane scrollPane = new JScrollPane(trialRecordTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, tcsb);

    JPanel trialsPanel = new JPanel(new BorderLayout());
    trialsPanel.add(messageLabel, BorderLayout.NORTH);
    trialsPanel.add(scrollPane, BorderLayout.CENTER);
    trialsPanel.add(buttons, BorderLayout.SOUTH);

    cardPanel.add(helpInstructions, CARD_HELP);
    cardPanel.add(trialsPanel, CARD_TRIALS);
    cardLayout.show(cardPanel, CARD_HELP);

    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, searchOptionsPanel.getViewComponent(), cardPanel);

    return splitPane;
}

From source file:com.diversityarrays.kdxplore.trials.AddScoringSetDialog.java

public AddScoringSetDialog(Window owner, KdxploreDatabase kdxdb, Trial trial,
        Map<Trait, List<TraitInstance>> instancesByTrait, SampleGroup curatedSampleGroup) {
    super(owner, Msg.TITLE_ADD_SCORING_SET(), ModalityType.APPLICATION_MODAL);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    this.kdxploreDatabase = kdxdb;
    this.trial = trial;
    this.curatedSampleGroupId = curatedSampleGroup == null ? 0 : curatedSampleGroup.getSampleGroupId();

    Map<Trait, List<TraitInstance>> noCalcs = instancesByTrait.entrySet().stream()
            .filter(e -> TraitDataType.CALC != e.getKey().getTraitDataType())
            .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

    Map<Trait, List<TraitInstance>> noCalcsSorted = new TreeMap<>(TRAIT_COMPARATOR);
    noCalcsSorted.putAll(noCalcs);//from   w ww.ja v a2s. c  o m

    BiFunction<Trait, TraitInstance, String> parentNameProvider = new BiFunction<Trait, TraitInstance, String>() {
        @Override
        public String apply(Trait t, TraitInstance ti) {
            if (ti == null) {
                List<TraitInstance> list = noCalcsSorted.get(t);
                if (list == null || list.size() != 1) {
                    OptionalInt opt = traitInstanceChoiceTreeModel.getChildChosenCountIfNotAllChosen(t);
                    StringBuilder sb = new StringBuilder(t.getTraitName());

                    if (opt.isPresent()) {
                        // only some of the children are chosen
                        int childChosenCount = opt.getAsInt();
                        if (childChosenCount > 0) {
                            sb.append(" (").append(childChosenCount).append(" of ").append(list.size())
                                    .append(")");
                        }
                    } else {
                        // all of the children are chosen
                        if (list != null) {
                            sb.append(" (").append(list.size()).append(")");
                        }
                    }
                    return sb.toString();
                }
            }
            return t.getTraitName();
        }
    };

    Optional<List<TraitInstance>> opt = noCalcsSorted.values().stream().filter(list -> list.size() > 1)
            .findFirst();
    String heading1 = opt.isPresent() ? "Trait/Instance" : "Trait";

    traitInstanceChoiceTreeModel = new ChoiceTreeTableModel<>(heading1, "Use?", //$NON-NLS-1$
            noCalcsSorted, parentNameProvider, childNameProvider);

    //        traitInstanceChoiceTreeModel = new TTChoiceTreeTableModel(instancesByTrait);

    traitInstanceChoiceTreeModel.addChoiceChangedListener(new ChoiceChangedListener() {
        @Override
        public void choiceChanged(Object source, ChoiceNode[] changedNodes) {
            updateCreateAction("choiceChanged");
            treeTable.repaint();
        }
    });

    traitInstanceChoiceTreeModel.addTreeModelListener(new TreeModelListener() {
        @Override
        public void treeStructureChanged(TreeModelEvent e) {
        }

        @Override
        public void treeNodesRemoved(TreeModelEvent e) {
        }

        @Override
        public void treeNodesInserted(TreeModelEvent e) {
        }

        @Override
        public void treeNodesChanged(TreeModelEvent e) {
            updateCreateAction("treeNodesChanged");
        }
    });

    warningMsg.setText(PLEASE_PROVIDE_A_DESCRIPTION);
    warningMsg.setForeground(Color.RED);

    Container cp = getContentPane();

    Box sampleButtons = null;
    if (curatedSampleGroup != null && curatedSampleGroup.getAnyScoredSamples()) {
        sampleButtons = createWantSampleButtons(curatedSampleGroup);
    }

    Box top = Box.createVerticalBox();
    if (sampleButtons == null) {
        top.add(new JLabel(Msg.MSG_THERE_ARE_NO_CURATED_SAMPLES()));
    } else {
        top.add(sampleButtons);
    }
    top.add(descriptionField);

    cp.add(top, BorderLayout.NORTH);

    descriptionField.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void removeUpdate(DocumentEvent e) {
            updateCreateAction("documentListener");
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            updateCreateAction("documentListener");
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            updateCreateAction("documentListener");
        }
    });

    updateCreateAction("init");
    //        KDClientUtils.initAction(ImageId.`CHECK_ALL, useAllAction, "Click to Use All");

    treeTable = new JXTreeTable(traitInstanceChoiceTreeModel);
    treeTable.setAutoResizeMode(JXTreeTable.AUTO_RESIZE_ALL_COLUMNS);

    TableCellRenderer renderer = treeTable.getDefaultRenderer(Integer.class);
    if (renderer instanceof JLabel) {
        ((JLabel) renderer).setHorizontalAlignment(JLabel.CENTER);
    }

    Box buttons = Box.createHorizontalBox();

    buttons.add(new JButton(useAllAction));
    buttons.add(new JButton(useNoneAction));

    buttons.add(Box.createHorizontalGlue());
    buttons.add(warningMsg);

    buttons.add(new JButton(cancelAction));
    buttons.add(Box.createHorizontalStrut(10));
    buttons.add(new JButton(createAction));

    cp.add(new JScrollPane(treeTable), BorderLayout.CENTER);
    cp.add(buttons, BorderLayout.SOUTH);

    pack();
}

From source file:com.diversityarrays.kdxplore.field.PlotIdTrialLayoutPane.java

public PlotIdTrialLayoutPane() {
    super(new BorderLayout());

    /*//from w  w w .  jav  a  2s  .  co m
     *  *  .--->           <---.
     *  |    (o)      (o)   |
     *  v                   v
     *   (o)             (o)
     *   
     *                            
     *   (o)             (o)
     *  ^                   ^ 
     *  |    (o)      (o)   |
     *  `--->           <---'
     *  
     *  Traversal: (o) 1-w  (o) 2-w
     *  
     *  (above is in odtPanel)
     *  ---------------------------
     *  
     *  Run Length:     [         ]
     *  Origin Plot Id: [         ]
     */

    JPanel top = new JPanel();

    GBH gbh = new GBH(top);
    int y = 0;

    gbh.add(0, y, 1, 1, GBH.NONE, 1, 1, GBH.EAST, "Plot Ids:");
    gbh.add(1, y, 3, 1, GBH.HORZ, 1, 1, GBH.WEST, plotIdentInfo);
    ++y;

    // - - - - - - -

    JPanel bottom = new JPanel();
    GBH rgbh = new GBH(bottom);
    y = 0;

    rgbh.add(0, y, 1, 1, GBH.NONE, 1, 1, GBH.EAST, "Run Length:");
    rgbh.add(1, y, 1, 1, GBH.HORZ, 1, 1, GBH.CENTER, runLengthSpinner);
    ++y;
    rgbh.add(0, y, 1, 1, GBH.NONE, 1, 1, GBH.EAST, "Origin Plot Id:");
    rgbh.add(1, y, 1, 1, GBH.HORZ, 1, 1, GBH.CENTER, plotSpinner);
    ++y;

    // - - - - - - -
    Box main = Box.createVerticalBox();
    main.add(top);
    main.add(withInsets(new JSeparator(JSeparator.HORIZONTAL), new Insets(0, 20, 0, 20)));
    main.add(odtPanel);
    main.add(withInsets(new JSeparator(JSeparator.HORIZONTAL), new Insets(0, 20, 0, 20)));

    main.add(bottom);

    add(main, BorderLayout.CENTER);

    //         crb_ll_right.doClick();

    ChangeListener changeListener = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            if (initialised) {
                firePropertyChange(PROP_LAYOUT_CHANGED, false, true);
            }
        }
    };
    runLengthModel.addChangeListener(changeListener);
    plotIdModel.addChangeListener(changeListener);

    initialised = true;
}

From source file:org.apache.jmeter.protocol.amf.visualizers.RenderAsXPathAMF.java

/**
 * Create the XPath task pane//from w  w  w.  j  a va2  s. co m
 *
 * @return XPath task pane
 */
private JPanel createXpathExtractorTasksPanel() {
    Box xpathActionPanel = Box.createVerticalBox();

    Box selectorAndButton = Box.createHorizontalBox();

    Border margin = new EmptyBorder(5, 5, 0, 5);
    xpathActionPanel.setBorder(margin);
    xpathExpressionField = new JLabeledTextField(JMeterUtils.getResString("xpath_tester_field")); // $NON-NLS-1$

    JButton xpathTester = new JButton(JMeterUtils.getResString("xpath_tester_button_test")); // $NON-NLS-1$
    xpathTester.setActionCommand(XPATH_TESTER_COMMAND);
    xpathTester.addActionListener(this);

    selectorAndButton.add(xpathExpressionField);
    selectorAndButton.add(xpathTester);

    xpathActionPanel.add(selectorAndButton);
    xpathActionPanel.add(xmlConfPanel);
    xpathActionPanel.add(getFragment);

    xpathResultField = new JTextArea();
    xpathResultField.setEditable(false);
    xpathResultField.setLineWrap(true);
    xpathResultField.setWrapStyleWord(true);

    JPanel xpathTasksPanel = new JPanel(new BorderLayout(0, 5));
    xpathTasksPanel.add(xpathActionPanel, BorderLayout.NORTH);
    xpathTasksPanel.add(GuiUtils.makeScrollPane(xpathResultField), BorderLayout.CENTER);

    return xpathTasksPanel;
}