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:org.jdal.swing.table.TablePanel.java

/**
 * Creates a new Component that holds the ReportListView
 * @return ReportListView Component//from w  w w. j  a va  2s .c  o m
 */
@SuppressWarnings("unused")
private Component createReportListBox() {
    Box tableBox = Box.createHorizontalBox();
    tableBox.add(reportListView.getPanel());
    reportListView.setReportProvider(this);
    return tableBox;
}

From source file:org.jdal.swing.table.TablePanel.java

/**
 * Creates a new Component with PageableTable.
 * @return PageableTableComponent./*from   w  ww .  ja v  a 2  s .c  o  m*/
 */
private Component createTableBox() {
    Box tableBox = Box.createVerticalBox();
    tableBox.add(createControlBox());
    tableBox.add(Box.createVerticalStrut(5));
    table.setAlignmentX(Container.LEFT_ALIGNMENT);
    tableBox.add(table);

    return tableBox;
}

From source file:de.interactive_instruments.ShapeChange.UI.DefaultDialog.java

private Component createTab1() {

    final JPanel mdlPanel = new JPanel();
    mdlField = new JTextField(40);
    String s = options.parameter("inputFile");
    if (s == null)
        s = "";/*from   w ww . ja  va 2 s. co  m*/
    mdlField.setText(s);
    mdlPanel.add(mdlField);
    mdlPanel.add(mdlButton = new JButton("Select File"));
    mdlButton.setActionCommand("MDL");
    mdlButton.addActionListener(this);
    mdlPanel.setBorder(
            new TitledBorder(new LineBorder(Color.black), "Model file", TitledBorder.LEFT, TitledBorder.TOP));

    final JPanel outPanel = new JPanel();
    outField = new JTextField(40);
    s = options.parameter("outputDirectory");
    if (s == null)
        s = ".";
    outField.setText(s);
    outPanel.add(outField);
    outPanel.add(outButton = new JButton("Select File"));
    outButton.setActionCommand("OUT");
    outButton.addActionListener(this);
    outPanel.setBorder(new TitledBorder(new LineBorder(Color.black), "Output directory", TitledBorder.LEFT,
            TitledBorder.TOP));

    final JPanel asPanel = new JPanel();
    asField = new JTextField(49);
    s = options.parameter("appSchemaName");
    if (s == null)
        s = "";
    asField.setText(s);
    asPanel.add(asField);
    asPanel.setBorder(new TitledBorder(new LineBorder(Color.black), "Application schema name (optional)",
            TitledBorder.LEFT, TitledBorder.TOP));

    final JPanel startPanel = new JPanel();
    startButton = new JButton("Process Model");
    startButton.setActionCommand("START");
    startButton.addActionListener(this);
    startPanel.add(startButton);
    logButton = new JButton("View Log");
    logButton.setActionCommand("LOG");
    logButton.addActionListener(this);
    logButton.setEnabled(false);
    startPanel.add(logButton);
    exitButton = new JButton("Exit");
    exitButton.setActionCommand("EXIT");
    exitButton.addActionListener(this);
    exitButton.setEnabled(true);
    startPanel.add(exitButton);

    Box fileBox = Box.createVerticalBox();
    fileBox.add(mdlPanel);
    fileBox.add(asPanel);
    fileBox.add(outPanel);
    fileBox.add(startPanel);

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(fileBox, BorderLayout.CENTER);

    return panel;
}

From source file:org.jdal.swing.form.SimpleBoxFormBuilder.java

public void addBox(Component c) {
    if (rows == 0 && rowsHeight.isEmpty()) {
        log.warn("You must call row() before adding components. I will add a row with default height for you");
        row();// w ww  . j  a  va 2s  . co  m
    }
    Box column = getColumn();

    if (rows > 1)
        column.add(Box.createVerticalStrut(defaultSpace));

    column.add(c);

    // don't add Labels to focus transversal
    if (!(c instanceof JLabel)) {
        focusTransversal.add(c);
    } else { // null or empty labels don't size well
        if (StringUtils.isEmpty(((JLabel) c).getText()))
            ((JLabel) c).setText(" ");
    }

    index++;

}

From source file:SoundPlayer.java

public SoundPlayer(File f, boolean isMidi) throws IOException, UnsupportedAudioFileException,
        LineUnavailableException, MidiUnavailableException, InvalidMidiDataException {
    if (isMidi) { // The file is a MIDI file
        midi = true;/*from   w  w  w  .  j  av  a 2 s .com*/
        // First, get a Sequencer to play sequences of MIDI events
        // That is, to send events to a Synthesizer at the right time.
        sequencer = MidiSystem.getSequencer(); // Used to play sequences
        sequencer.open(); // Turn it on.

        // Get a Synthesizer for the Sequencer to send notes to
        Synthesizer synth = MidiSystem.getSynthesizer();
        synth.open(); // acquire whatever resources it needs

        // The Sequencer obtained above may be connected to a Synthesizer
        // by default, or it may not. Therefore, we explicitly connect it.
        Transmitter transmitter = sequencer.getTransmitter();
        Receiver receiver = synth.getReceiver();
        transmitter.setReceiver(receiver);

        // Read the sequence from the file and tell the sequencer about it
        sequence = MidiSystem.getSequence(f);
        sequencer.setSequence(sequence);
        audioLength = (int) sequence.getTickLength(); // Get sequence length
    } else { // The file is sampled audio
        midi = false;
        // Getting a Clip object for a file of sampled audio data is kind
        // of cumbersome. The following lines do what we need.
        AudioInputStream ain = AudioSystem.getAudioInputStream(f);
        try {
            DataLine.Info info = new DataLine.Info(Clip.class, ain.getFormat());
            clip = (Clip) AudioSystem.getLine(info);
            clip.open(ain);
        } finally { // We're done with the input stream.
            ain.close();
        }
        // Get the clip length in microseconds and convert to milliseconds
        audioLength = (int) (clip.getMicrosecondLength() / 1000);
    }

    // Now create the basic GUI
    play = new JButton("Play"); // Play/stop button
    progress = new JSlider(0, audioLength, 0); // Shows position in sound
    time = new JLabel("0"); // Shows position as a #

    // When clicked, start or stop playing the sound
    play.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (playing)
                stop();
            else
                play();
        }
    });

    // Whenever the slider value changes, first update the time label.
    // Next, if we're not already at the new position, skip to it.
    progress.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            int value = progress.getValue();
            // Update the time label
            if (midi)
                time.setText(value + "");
            else
                time.setText(value / 1000 + "." + (value % 1000) / 100);
            // If we're not already there, skip there.
            if (value != audioPosition)
                skip(value);
        }
    });

    // This timer calls the tick() method 10 times a second to keep
    // our slider in sync with the music.
    timer = new javax.swing.Timer(100, new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            tick();
        }
    });

    // put those controls in a row
    Box row = Box.createHorizontalBox();
    row.add(play);
    row.add(progress);
    row.add(time);

    // And add them to this component.
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    this.add(row);

    // Now add additional controls based on the type of the sound
    if (midi)
        addMidiControls();
    else
        addSampledControls();
}

From source file:org.jcurl.demo.editor.EditorApp.java

public EditorApp() {
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            EditorApp.this.cmdExit();
        }//from  w  w w.  j  av  a  2  s.co m
    });
    master = new RockEditDisplay();
    master.setPos(mod_locations);
    master.setSpeed(mod_speeds);
    final PositionDisplay pnl2 = new PositionDisplay();
    pnl2.setPos(mod_locations);
    pnl2.setZoom(Zoomer.HOG2HACK);

    final Container con = getContentPane();

    con.add(master, "Center");
    con.add(new SumWaitDisplay(mod_locations), "West");
    con.add(new SumShotDisplay(mod_locations), "East");
    {
        final Box b0 = Box.createVerticalBox();
        final Box b1 = Box.createHorizontalBox();
        b1.add(Box.createRigidArea(new Dimension(0, 75)));
        b1.add(pnl2);
        b0.add(b1);
        b0.add(new JSlider(0, 100, 0));
        final Box b2 = Box.createHorizontalBox();
        b2.add(Box.createHorizontalGlue());
        b2.add(bStart = this.newButton("Start", this, "cmdRunStart"));
        b2.add(bPause = this.newButton("Pause", this, "cmdRunPause"));
        b2.add(bStop = this.newButton("Stop", this, "cmdRunStop"));
        b2.add(Box.createHorizontalGlue());
        b0.add(b2);
        con.add(b0, "South");
    }
    bStop.getAction().actionPerformed(null);

    setJMenuBar(createMenu());
    refreshTitle();
    this.setSize(900, 400);

    new SpeedController(mod_locations, mod_speeds, master);
    new LocationController(mod_locations, pnl2);
    lastSaved = mod_locations.getLastChanged();
}

From source file:pcgen.gui2.tabs.spells.SpellBooksTab.java

private void initComponents() {
    availableTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setRowSorter(new SortableTableRowSorter() {

        @Override/* www .  j a va2s .  c o m*/
        public SortableTableModel getModel() {
            return (SortableTableModel) selectedTable.getModel();
        }

    });
    selectedTable.getRowSorter().toggleSortOrder(0);
    FilterBar<CharacterFacade, SuperNode> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    qFilterButton.setText(LanguageBundle.getString("in_igQualFilter")); //$NON-NLS-1$
    filterBar.addDisplayableFilter(qFilterButton);

    FlippingSplitPane upperPane = new FlippingSplitPane("SpellBooksTop");
    JPanel availPanel = FilterUtilities.configureFilteredTreeViewPane(availableTable, filterBar);
    Box box = Box.createVerticalBox();
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(new JLabel(LanguageBundle.getString("InfoSpells.set.auto.book")));
        hbox.add(Box.createHorizontalGlue());
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(defaultBookCombo);
        hbox.add(Box.createHorizontalGlue());
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(addButton);
        hbox.add(Box.createHorizontalStrut(5));
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    availPanel.add(box, BorderLayout.SOUTH);
    upperPane.setLeftComponent(availPanel);

    box = Box.createVerticalBox();
    box.add(new JScrollPane(selectedTable));
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(removeButton);
        hbox.add(Box.createHorizontalGlue());
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    upperPane.setRightComponent(box);
    upperPane.setResizeWeight(0);
    setTopComponent(upperPane);

    FlippingSplitPane bottomPane = new FlippingSplitPane("SpellBooksBottom");
    bottomPane.setLeftComponent(spellsPane);
    bottomPane.setRightComponent(classPane);
    setBottomComponent(bottomPane);
    setOrientation(VERTICAL_SPLIT);
}

From source file:org.jdal.swing.table.TablePanel.java

/**
 * Creates a new Component with FilterView.
 * @return new Component.//from   w w w. ja v  a2s  . c  o  m
 */
private Component createFilterBox() {
    Box header = Box.createVerticalBox();

    if (filterView != null) {
        header.add(Box.createVerticalStrut(10));
        filterView.refresh();
        header.add(filterView.getPanel());
    }

    header.setAlignmentX(Container.LEFT_ALIGNMENT);

    return header;
}

From source file:com.diversityarrays.update.UpdateDialog.java

public UpdateDialog(UpdateCheckRequest updateCheckRequest, UpdateCheckContext ctx, long exp_ms) {
    super(updateCheckRequest.owner, Msg.TITLE_UPDATE_CHECK(), ModalityType.APPLICATION_MODAL);

    this.updateCheckRequest = updateCheckRequest;
    this.updateCheckContext = ctx;

    setKDXploreUpdate(null);//from w  w  w .j  ava2  s.  c  om
    installUpdateAction.setEnabled(false);

    cardPanel.setBorder(new EmptyBorder(20, 20, 20, 20));

    progressBar.setIndeterminate(true);
    cardPanel.add(progressBar, CARD_PROGRESS);
    if (exp_ms > 0) {
        daysToGo = 1 + ChronoUnit.DAYS.between(new Date().toInstant(), new Date(exp_ms).toInstant());
        JPanel tmp = new JPanel(new BorderLayout());
        tmp.add(new JLabel(Msg.HTML_THIS_VERSION_EXPIRES_IN_N_DAYS((int) daysToGo)), BorderLayout.NORTH);
        tmp.add(messageLabel, BorderLayout.CENTER);
        cardPanel.add(tmp, CARD_MESSAGE);
    } else {
        daysToGo = 0;
        cardPanel.add(messageLabel, CARD_MESSAGE);
    }

    cardLayout.show(cardPanel, CARD_PROGRESS);

    Box buttons = Box.createHorizontalBox();
    buttons.add(new JButton(closeAction));
    buttons.add(new JButton(moreAction));
    if (RunMode.getRunMode().isDeveloper()) {
        buttons.add(new JButton(installUpdateAction));
    }
    buttons.add(Box.createHorizontalGlue());
    buttons.add(backupDatabaseButton);
    backupDatabaseButton.setVisible(false);
    backupDatabaseAction.setEnabled(updateCheckContext.canBackupDatabase());

    Container cp = getContentPane();

    cp.add(buttons, BorderLayout.SOUTH);
    cp.add(cardPanel, BorderLayout.CENTER);

    pack();

    GuiUtil.centreOnOwner(this);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent e) {
            removeWindowListener(this);
            checkForUpdates(updateCheckContext.getPrintStream());
        }
    });
}

From source file:com.diversityarrays.kdxplore.vistool.AskForTraitInstances.java

AskForTraitInstances(Window owner, String title, boolean xAndYaxes, String okLabel, TraitNameStyle tns,
        Map<TraitInstance, SimpleStatistics<?>> map, int[] minMax,
        Closure<List<TraitInstance>> onInstancesChosen) {
    super(owner, title, ModalityType.MODELESS);

    this.traitNameStyle = tns;
    this.minInstances = minMax[0];
    this.maxInstances = minMax[1];
    this.onInstancesChosen = onInstancesChosen;

    if (xAndYaxes) {
        tableModel = new TraitInstanceAxisChoiceTableModel();
    } else {/*from  w w  w.ja  va 2s  .  c om*/
        tableModel = new TraitInstanceChoiceTableModel();
    }
    table = new JTable(tableModel);

    okAction.putValue(Action.NAME, okLabel);

    traitInstances = new ArrayList<TraitInstance>(map.keySet());
    Collections.sort(traitInstances, TraitHelper.COMPARATOR);

    table.setAutoCreateRowSorter(true);

    Box box = Box.createHorizontalBox();
    box.add(message);
    box.add(Box.createHorizontalGlue());
    box.add(new JButton(okAction));
    box.add(new JButton(cancelAction));

    getContentPane().add(new JScrollPane(table), BorderLayout.CENTER);
    getContentPane().add(box, BorderLayout.SOUTH);

    pack();

    tableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            updateOkButton();
        }
    });
    updateOkButton();
}