Search in sources :

Example 76 with BoxLayout

use of javax.swing.BoxLayout in project JMRI by JMRI.

the class YardmasterByTrackPanel method runUpdate.

@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST_OF_RETURN_VALUE", justification = "CarManager only provides Car Objects")
private void runUpdate() {
    log.debug("run update");
    removePropertyChangeListerners();
    // reset the utility car counts
    trainCommon.clearUtilityCarTypes();
    checkBoxes.clear();
    pTrack.removeAll();
    boolean pickup = false;
    boolean setout = false;
    if (_track != null) {
        pTrackPane.setBorder(BorderFactory.createTitledBorder(_track.getName()));
        textTrackCommentPane.setText(_track.getComment());
        textTrackCommentPane.setVisible(!_track.getComment().equals(Track.NONE));
        textTrackCommentWorkPane.setText("");
        for (Train train : trainManager.getTrainsArrivingThisLocationList(_track.getLocation())) {
            JPanel pTrain = new JPanel();
            pTrain.setLayout(new BoxLayout(pTrain, BoxLayout.Y_AXIS));
            pTrain.setBorder(BorderFactory.createTitledBorder(MessageFormat.format(TrainSwitchListText.getStringScheduledWork(), new Object[] { train.getName(), train.getDescription() })));
            // List locos first
            List<Engine> engList = engManager.getByTrainBlockingList(train);
            if (Setup.isPrintHeadersEnabled()) {
                for (Engine engine : engList) {
                    if (engine.getTrack() == _track) {
                        JLabel header = new JLabel(Tab + trainCommon.getPickupEngineHeader());
                        setLabelFont(header);
                        pTrain.add(header);
                        break;
                    }
                }
            }
            for (Engine engine : engList) {
                if (engine.getTrack() == _track) {
                    engine.addPropertyChangeListener(this);
                    rollingStock.add(engine);
                    JCheckBox checkBox = new JCheckBox(trainCommon.pickupEngine(engine));
                    setCheckBoxFont(checkBox);
                    pTrain.add(checkBox);
                    checkBoxes.put(engine.getId(), checkBox);
                    pTrack.add(pTrain);
                }
            }
            // now do locomotive set outs
            if (Setup.isPrintHeadersEnabled()) {
                for (Engine engine : engList) {
                    if (engine.getDestinationTrack() == _track) {
                        JLabel header = new JLabel(Tab + trainCommon.getDropEngineHeader());
                        setLabelFont(header);
                        pTrain.add(header);
                        break;
                    }
                }
            }
            for (Engine engine : engList) {
                if (engine.getDestinationTrack() == _track) {
                    engine.addPropertyChangeListener(this);
                    rollingStock.add(engine);
                    JCheckBox checkBox = new JCheckBox(trainCommon.dropEngine(engine));
                    setCheckBoxFont(checkBox);
                    pTrain.add(checkBox);
                    checkBoxes.put(engine.getId(), checkBox);
                    pTrack.add(pTrain);
                }
            }
            // now cars
            List<Car> carList = carManager.getByTrainDestinationList(train);
            if (Setup.isPrintHeadersEnabled()) {
                for (Car car : carList) {
                    if (car.getTrack() == _track && car.getRouteDestination() != car.getRouteLocation()) {
                        JLabel header = new JLabel(Tab + trainCommon.getPickupCarHeader(!IS_MANIFEST, !TrainCommon.IS_TWO_COLUMN_TRACK));
                        setLabelFont(header);
                        pTrain.add(header);
                        break;
                    }
                }
            }
            // sort car pick ups by their destination
            List<RouteLocation> routeList = train.getRoute().getLocationsBySequenceList();
            for (RouteLocation rl : routeList) {
                for (Car car : carList) {
                    if (car.getTrack() == _track && car.getRouteDestination() != car.getRouteLocation() && car.getRouteDestination() == rl) {
                        car.addPropertyChangeListener(this);
                        rollingStock.add(car);
                        String text;
                        if (car.isUtility()) {
                            text = trainCommon.pickupUtilityCars(carList, car, !IS_MANIFEST, !TrainCommon.IS_TWO_COLUMN_TRACK);
                            if (text == null) {
                                // this car type has already been processed
                                continue;
                            }
                        } else {
                            text = trainCommon.pickupCar(car, !IS_MANIFEST, !TrainCommon.IS_TWO_COLUMN_TRACK);
                        }
                        pickup = true;
                        JCheckBox checkBox = new JCheckBox(text);
                        setCheckBoxFont(checkBox);
                        pTrain.add(checkBox);
                        checkBoxes.put(car.getId(), checkBox);
                        pTrack.add(pTrain);
                    }
                }
            }
            // now do car set outs
            if (Setup.isPrintHeadersEnabled()) {
                for (Car car : carList) {
                    if (car.getDestinationTrack() == _track && car.getRouteDestination() != car.getRouteLocation()) {
                        JLabel header = new JLabel(Tab + trainCommon.getDropCarHeader(!IS_MANIFEST, !TrainCommon.IS_TWO_COLUMN_TRACK));
                        setLabelFont(header);
                        pTrain.add(header);
                        break;
                    }
                }
            }
            for (Car car : carList) {
                if (car.getDestinationTrack() == _track && car.getRouteLocation() != car.getRouteDestination()) {
                    car.addPropertyChangeListener(this);
                    rollingStock.add(car);
                    String text;
                    if (car.isUtility()) {
                        text = trainCommon.setoutUtilityCars(carList, car, !TrainCommon.LOCAL, !IS_MANIFEST);
                        if (text == null) {
                            // this car type has already been processed
                            continue;
                        }
                    } else {
                        text = trainCommon.dropCar(car, !IS_MANIFEST, !TrainCommon.IS_TWO_COLUMN_TRACK);
                    }
                    setout = true;
                    JCheckBox checkBox = new JCheckBox(text);
                    setCheckBoxFont(checkBox);
                    pTrain.add(checkBox);
                    checkBoxes.put(car.getId(), checkBox);
                    pTrack.add(pTrain);
                }
            }
            // now do local car moves
            if (Setup.isPrintHeadersEnabled()) {
                for (Car car : carList) {
                    if ((car.getTrack() == _track || car.getDestinationTrack() == _track) && car.getRouteDestination() == car.getRouteLocation()) {
                        JLabel header = new JLabel(Tab + trainCommon.getLocalMoveHeader(!IS_MANIFEST));
                        setLabelFont(header);
                        pTrain.add(header);
                        break;
                    }
                }
            }
            for (Car car : carList) {
                if ((car.getTrack() == _track || car.getDestinationTrack() == _track) && car.getRouteLocation() != null && car.getRouteLocation() == car.getRouteDestination()) {
                    car.addPropertyChangeListener(this);
                    rollingStock.add(car);
                    String text;
                    if (car.isUtility()) {
                        text = trainCommon.setoutUtilityCars(carList, car, TrainCommon.LOCAL, !IS_MANIFEST);
                        if (text == null) {
                            // this car type has already been processed
                            continue;
                        }
                    } else {
                        text = trainCommon.localMoveCar(car, !IS_MANIFEST);
                    }
                    setout = true;
                    JCheckBox checkBox = new JCheckBox(text);
                    setCheckBoxFont(checkBox);
                    pTrain.add(checkBox);
                    checkBoxes.put(car.getId(), checkBox);
                    pTrack.add(pTrain);
                }
            }
            pTrackPane.validate();
            pTrain.setMaximumSize(new Dimension(2000, pTrain.getHeight()));
            pTrain.revalidate();
        }
        // now do car holds
        // we only need the cars on this track
        List<RollingStock> rsList = carManager.getByTrainList();
        List<Car> carList = new ArrayList<Car>();
        for (RollingStock rs : rsList) {
            if (rs.getTrack() != _track || rs.getRouteLocation() != null)
                continue;
            carList.add((Car) rs);
        }
        JPanel pHoldCars = new JPanel();
        pHoldCars.setLayout(new BoxLayout(pHoldCars, BoxLayout.Y_AXIS));
        pHoldCars.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("HoldCars")));
        for (Car car : carList) {
            String text;
            if (car.isUtility()) {
                String s = trainCommon.pickupUtilityCars(carList, car, !IS_MANIFEST, !TrainCommon.IS_TWO_COLUMN_TRACK);
                if (s == null)
                    continue;
                text = TrainSwitchListText.getStringHoldCar().split("\\{")[0] + s.trim();
            } else {
                text = MessageFormat.format(TrainSwitchListText.getStringHoldCar(), new Object[] { TrainCommon.padAndTruncateString(car.getRoadName(), CarRoads.instance().getMaxNameLength()), TrainCommon.padAndTruncateString(TrainCommon.splitString(car.getNumber()), Control.max_len_string_print_road_number), TrainCommon.padAndTruncateString(car.getTypeName().split("-")[0], CarTypes.instance().getMaxNameLength()), TrainCommon.padAndTruncateString(car.getLength() + TrainCommon.LENGTHABV, Control.max_len_string_length_name), TrainCommon.padAndTruncateString(car.getLoadName(), CarLoads.instance().getMaxNameLength()), TrainCommon.padAndTruncateString(_track.getName(), LocationManager.instance().getMaxTrackNameLength()), TrainCommon.padAndTruncateString(car.getColor(), CarColors.instance().getMaxNameLength()) });
            }
            JCheckBox checkBox = new JCheckBox(text);
            setCheckBoxFont(checkBox);
            pHoldCars.add(checkBox);
            checkBoxes.put(car.getId(), checkBox);
            pTrack.add(pHoldCars);
        }
        pTrackPane.validate();
        pHoldCars.setMaximumSize(new Dimension(2000, pHoldCars.getHeight()));
        pHoldCars.revalidate();
        if (pickup && !setout) {
            textTrackCommentWorkPane.setText(_track.getCommentPickup());
        } else if (!pickup && setout) {
            textTrackCommentWorkPane.setText(_track.getCommentSetout());
        } else if (pickup && setout) {
            textTrackCommentWorkPane.setText(_track.getCommentBoth());
        }
        textTrackCommentWorkPane.setVisible(!textTrackCommentWorkPane.getText().equals(""));
    } else {
        pTrackPane.setBorder(BorderFactory.createTitledBorder(""));
        textTrackCommentPane.setVisible(false);
        textTrackCommentWorkPane.setVisible(false);
    }
}
Also used : JPanel(javax.swing.JPanel) BoxLayout(javax.swing.BoxLayout) ArrayList(java.util.ArrayList) JLabel(javax.swing.JLabel) RouteLocation(jmri.jmrit.operations.routes.RouteLocation) Dimension(java.awt.Dimension) RollingStock(jmri.jmrit.operations.rollingstock.RollingStock) JCheckBox(javax.swing.JCheckBox) Car(jmri.jmrit.operations.rollingstock.cars.Car) Train(jmri.jmrit.operations.trains.Train) Engine(jmri.jmrit.operations.rollingstock.engines.Engine) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 77 with BoxLayout

use of javax.swing.BoxLayout in project JMRI by JMRI.

the class TrackDestinationEditFrame method initComponents.

public void initComponents(Track track) {
    _track = track;
    // property changes
    // the following code sets the frame's initial state
    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
    // Set up the panels
    // Layout the panel by rows
    // row 1
    JPanel p1 = new JPanel();
    p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
    p1.setMaximumSize(new Dimension(2000, 250));
    // row 1a
    JPanel pTrackName = new JPanel();
    pTrackName.setLayout(new GridBagLayout());
    pTrackName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Track")));
    addItem(pTrackName, trackName, 0, 0);
    // row 1b
    JPanel pLocationName = new JPanel();
    pLocationName.setLayout(new GridBagLayout());
    pLocationName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Location")));
    addItem(pLocationName, new JLabel(_track.getLocation().getName()), 0, 0);
    p1.add(pTrackName);
    p1.add(pLocationName);
    // row 3
    JPanel p3 = new JPanel();
    p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
    JScrollPane pane3 = new JScrollPane(p3);
    pane3.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("DestinationTrack")));
    pane3.setMaximumSize(new Dimension(2000, 400));
    JPanel pRadioButtons = new JPanel();
    pRadioButtons.setLayout(new FlowLayout());
    pRadioButtons.add(destinationsAll);
    pRadioButtons.add(destinationsInclude);
    pRadioButtons.add(destinationsExclude);
    p3.add(pRadioButtons);
    // row 4 only for interchange / classification tracks
    JPanel pFD = new JPanel();
    pFD.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Options")));
    pFD.add(onlyCarsWithFD);
    pFD.setMaximumSize(new Dimension(2000, 200));
    // row 5
    panelDestinations.setLayout(new GridBagLayout());
    paneDestinations.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Destinations")));
    ButtonGroup bGroup = new ButtonGroup();
    bGroup.add(destinationsAll);
    bGroup.add(destinationsInclude);
    bGroup.add(destinationsExclude);
    // row 12
    JPanel panelButtons = new JPanel();
    panelButtons.setLayout(new GridBagLayout());
    panelButtons.setBorder(BorderFactory.createTitledBorder(""));
    panelButtons.setMaximumSize(new Dimension(2000, 200));
    // row 13
    addItem(panelButtons, checkDestinationsButton, 0, 0);
    addItem(panelButtons, saveTrackButton, 1, 0);
    getContentPane().add(p1);
    getContentPane().add(pane3);
    getContentPane().add(pFD);
    getContentPane().add(paneDestinations);
    getContentPane().add(panelButtons);
    // setup buttons
    addButtonAction(checkDestinationsButton);
    addButtonAction(saveTrackButton);
    addRadioButtonAction(destinationsAll);
    addRadioButtonAction(destinationsInclude);
    addRadioButtonAction(destinationsExclude);
    // load fields and enable buttons
    if (_track != null) {
        _track.addPropertyChangeListener(this);
        trackName.setText(_track.getName());
        onlyCarsWithFD.setSelected(_track.isOnlyCarsWithFinalDestinationEnabled());
        pFD.setVisible(_track.getTrackType().equals(Track.INTERCHANGE));
        enableButtons(true);
    } else {
        enableButtons(false);
    }
    updateDestinations();
    locationManager.addPropertyChangeListener(this);
    // build menu
    // JMenuBar menuBar = new JMenuBar();
    // _toolMenu = new JMenu(Bundle.getMessage("MenuTools"));
    // menuBar.add(_toolMenu);
    // setJMenuBar(menuBar);
    initMinimumSize(new Dimension(Control.panelWidth400, Control.panelHeight500));
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) ButtonGroup(javax.swing.ButtonGroup) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension)

Example 78 with BoxLayout

use of javax.swing.BoxLayout in project JMRI by JMRI.

the class TrackLoadEditFrame method initComponents.

public void initComponents(Location location, Track track) {
    _location = location;
    _track = track;
    // property changes
    _location.addPropertyChangeListener(this);
    // listen for car load name and type changes
    CarLoads.instance().addPropertyChangeListener(this);
    CarTypes.instance().addPropertyChangeListener(this);
    // the following code sets the frame's initial state
    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
    // Set up the panels
    // Layout the panel by rows
    // row 1
    JPanel p1 = new JPanel();
    p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
    p1.setMaximumSize(new Dimension(2000, 250));
    // row 1a
    JPanel pTrackName = new JPanel();
    pTrackName.setLayout(new GridBagLayout());
    pTrackName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Track")));
    addItem(pTrackName, trackName, 0, 0);
    // row 1b
    JPanel pLocationName = new JPanel();
    pLocationName.setLayout(new GridBagLayout());
    pLocationName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Location")));
    addItem(pLocationName, new JLabel(_location.getName()), 0, 0);
    p1.add(pTrackName);
    p1.add(pLocationName);
    // row 3
    JPanel p3 = new JPanel();
    p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
    JScrollPane pane3 = new JScrollPane(p3);
    pane3.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("LoadsTrack")));
    pane3.setMaximumSize(new Dimension(2000, 400));
    JPanel pLoadRadioButtons = new JPanel();
    pLoadRadioButtons.setLayout(new FlowLayout());
    pLoadRadioButtons.add(loadNameAll);
    pLoadRadioButtons.add(loadNameInclude);
    pLoadRadioButtons.add(loadNameExclude);
    pLoadRadioButtons.add(loadAndTypeCheckBox);
    pLoadControls.setLayout(new FlowLayout());
    pLoadControls.add(comboBoxTypes);
    pLoadControls.add(comboBoxLoads);
    pLoadControls.add(addLoadButton);
    pLoadControls.add(deleteLoadButton);
    pLoadControls.add(deleteAllLoadsButton);
    pLoadControls.setVisible(false);
    p3.add(pLoadRadioButtons);
    p3.add(pLoadControls);
    // row 4
    panelLoads.setLayout(new GridBagLayout());
    paneLoads.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Loads")));
    ButtonGroup loadGroup = new ButtonGroup();
    loadGroup.add(loadNameAll);
    loadGroup.add(loadNameInclude);
    loadGroup.add(loadNameExclude);
    // row 6
    JPanel p6 = new JPanel();
    p6.setLayout(new BoxLayout(p6, BoxLayout.Y_AXIS));
    paneShipLoadControls = new JScrollPane(p6);
    paneShipLoadControls.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("ShipLoadsTrack")));
    paneShipLoadControls.setMaximumSize(new Dimension(2000, 400));
    JPanel pShipLoadRadioButtons = new JPanel();
    pShipLoadRadioButtons.setLayout(new FlowLayout());
    pShipLoadRadioButtons.add(shipLoadNameAll);
    pShipLoadRadioButtons.add(shipLoadNameInclude);
    pShipLoadRadioButtons.add(shipLoadNameExclude);
    pShipLoadRadioButtons.add(shipLoadAndTypeCheckBox);
    pShipLoadControls.setLayout(new FlowLayout());
    pShipLoadControls.add(comboBoxShipTypes);
    pShipLoadControls.add(comboBoxShipLoads);
    pShipLoadControls.add(addShipLoadButton);
    pShipLoadControls.add(deleteShipLoadButton);
    pShipLoadControls.add(deleteAllShipLoadsButton);
    pShipLoadControls.setVisible(false);
    p6.add(pShipLoadRadioButtons);
    p6.add(pShipLoadControls);
    // row 7
    panelShipLoads.setLayout(new GridBagLayout());
    paneShipLoads.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Loads")));
    ButtonGroup shipLoadGroup = new ButtonGroup();
    shipLoadGroup.add(shipLoadNameAll);
    shipLoadGroup.add(shipLoadNameInclude);
    shipLoadGroup.add(shipLoadNameExclude);
    JPanel pOptions = new JPanel();
    pOptions.setLayout(new GridBagLayout());
    pOptions.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Options")));
    pOptions.setMaximumSize(new Dimension(2000, 400));
    addItem(pOptions, holdCars, 0, 0);
    holdCars.setText(Bundle.getMessage("HoldCarsWithCustomLoads"));
    holdCars.setToolTipText(Bundle.getMessage("HoldCarsWithCustomLoadsTip"));
    // row 12
    JPanel panelButtons = new JPanel();
    panelButtons.setLayout(new GridBagLayout());
    panelButtons.setBorder(BorderFactory.createTitledBorder(""));
    panelButtons.setMaximumSize(new Dimension(2000, 200));
    // row 13
    addItem(panelButtons, saveTrackButton, 0, 0);
    getContentPane().add(p1);
    getContentPane().add(pane3);
    getContentPane().add(paneLoads);
    getContentPane().add(paneShipLoadControls);
    getContentPane().add(paneShipLoads);
    getContentPane().add(pOptions);
    getContentPane().add(panelButtons);
    // setup buttons
    addButtonAction(saveTrackButton);
    addButtonAction(deleteLoadButton);
    addButtonAction(deleteAllLoadsButton);
    addButtonAction(addLoadButton);
    addButtonAction(deleteShipLoadButton);
    addButtonAction(deleteAllShipLoadsButton);
    addButtonAction(addShipLoadButton);
    addRadioButtonAction(loadNameAll);
    addRadioButtonAction(loadNameInclude);
    addRadioButtonAction(loadNameExclude);
    addRadioButtonAction(shipLoadNameAll);
    addRadioButtonAction(shipLoadNameInclude);
    addRadioButtonAction(shipLoadNameExclude);
    addComboBoxAction(comboBoxTypes);
    addComboBoxAction(comboBoxShipTypes);
    paneShipLoadControls.setVisible(false);
    paneShipLoads.setVisible(false);
    pOptions.setVisible(false);
    // load fields and enable buttons
    if (_track != null) {
        _track.addPropertyChangeListener(this);
        trackName.setText(_track.getName());
        // only show ship loads for staging tracks
        paneShipLoadControls.setVisible(_track.getTrackType().equals(Track.STAGING));
        paneShipLoads.setVisible(_track.getTrackType().equals(Track.STAGING));
        pOptions.setVisible(_track.getTrackType().equals(Track.SPUR));
        holdCars.setSelected(_track.isHoldCarsWithCustomLoadsEnabled());
        updateButtons(true);
    } else {
        updateButtons(false);
    }
    // build menu
    // JMenuBar menuBar = new JMenuBar();
    // _toolMenu = new JMenu(Bundle.getMessage("MenuTools"));
    // menuBar.add(_toolMenu);
    // setJMenuBar(menuBar);
    // load
    updateTypeComboBoxes();
    updateLoadComboBoxes();
    updateLoadNames();
    updateShipLoadNames();
    loadAndTypeCheckBox.setSelected(loadAndType);
    shipLoadAndTypeCheckBox.setSelected(shipLoadAndType);
    // add help menu to window
    // NOI18N
    addHelpMenu("package.jmri.jmrit.operations.Operations_LoadOptions", true);
    initMinimumSize(new Dimension(Control.panelWidth600, Control.panelHeight400));
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) ButtonGroup(javax.swing.ButtonGroup) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension)

Example 79 with BoxLayout

use of javax.swing.BoxLayout in project JMRI by JMRI.

the class TrackRoadEditFrame method initComponents.

public void initComponents(Location location, Track track) {
    _location = location;
    _track = track;
    // property changes
    // listen for car road name changes
    CarRoads.instance().addPropertyChangeListener(this);
    // the following code sets the frame's initial state
    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
    // Set up the panels
    // Layout the panel by rows
    // row 1
    JPanel p1 = new JPanel();
    p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
    p1.setMaximumSize(new Dimension(2000, 250));
    // row 1a
    JPanel pTrackName = new JPanel();
    pTrackName.setLayout(new GridBagLayout());
    pTrackName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Track")));
    addItem(pTrackName, trackName, 0, 0);
    // row 1b
    JPanel pLocationName = new JPanel();
    pLocationName.setLayout(new GridBagLayout());
    pLocationName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Location")));
    addItem(pLocationName, new JLabel(_location.getName()), 0, 0);
    p1.add(pTrackName);
    p1.add(pLocationName);
    // row 3
    JPanel p3 = new JPanel();
    p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
    JScrollPane pane3 = new JScrollPane(p3);
    pane3.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("RoadsTrack")));
    pane3.setMaximumSize(new Dimension(2000, 400));
    JPanel pRoadRadioButtons = new JPanel();
    pRoadRadioButtons.setLayout(new FlowLayout());
    pRoadRadioButtons.add(roadNameAll);
    pRoadRadioButtons.add(roadNameInclude);
    pRoadRadioButtons.add(roadNameExclude);
    pRoadControls.setLayout(new FlowLayout());
    pRoadControls.add(comboBoxRoads);
    pRoadControls.add(addRoadButton);
    pRoadControls.add(deleteRoadButton);
    pRoadControls.add(deleteAllRoadsButton);
    pRoadControls.setVisible(false);
    p3.add(pRoadRadioButtons);
    p3.add(pRoadControls);
    // row 4
    panelRoads.setLayout(new GridBagLayout());
    paneRoads.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Roads")));
    ButtonGroup roadGroup = new ButtonGroup();
    roadGroup.add(roadNameAll);
    roadGroup.add(roadNameInclude);
    roadGroup.add(roadNameExclude);
    // row 12
    JPanel panelButtons = new JPanel();
    panelButtons.setLayout(new GridBagLayout());
    panelButtons.setBorder(BorderFactory.createTitledBorder(""));
    panelButtons.setMaximumSize(new Dimension(2000, 200));
    // row 13
    addItem(panelButtons, saveTrackButton, 0, 0);
    getContentPane().add(p1);
    getContentPane().add(pane3);
    getContentPane().add(paneRoads);
    getContentPane().add(panelButtons);
    // setup buttons
    addButtonAction(saveTrackButton);
    addButtonAction(deleteRoadButton);
    addButtonAction(deleteAllRoadsButton);
    addButtonAction(addRoadButton);
    addRadioButtonAction(roadNameAll);
    addRadioButtonAction(roadNameInclude);
    addRadioButtonAction(roadNameExclude);
    // road fields and enable buttons
    if (_track != null) {
        _track.addPropertyChangeListener(this);
        trackName.setText(_track.getName());
        enableButtons(true);
    } else {
        enableButtons(false);
    }
    updateRoadComboBox();
    updateRoadNames();
    // add help menu to window
    // NOI18N
    addHelpMenu("package.jmri.jmrit.operations.Operations_RoadOptions", true);
    initMinimumSize(new Dimension(Control.panelWidth500, Control.panelHeight400));
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) ButtonGroup(javax.swing.ButtonGroup) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension)

Example 80 with BoxLayout

use of javax.swing.BoxLayout in project JMRI by JMRI.

the class RouteEditFrame method initComponents.

public void initComponents(Route route) {
    _route = route;
    String routeName = null;
    // load managers
    routeManager = RouteManager.instance();
    // Set up the jtable in a Scroll Pane..
    routePane = new JScrollPane(routeTable);
    routePane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    routePane.setBorder(BorderFactory.createTitledBorder(""));
    routeModel.initTable(this, routeTable, _route);
    if (_route != null) {
        routeName = _route.getName();
        routeNameTextField.setText(routeName);
        commentTextField.setText(_route.getComment());
        enableButtons(true);
    } else {
        setTitle(Bundle.getMessage("TitleRouteAdd"));
        enableButtons(false);
    }
    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
    // Set up the panels
    JPanel p1 = new JPanel();
    p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
    JScrollPane p1Pane = new JScrollPane(p1);
    p1Pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
    p1Pane.setMinimumSize(new Dimension(300, 3 * routeNameTextField.getPreferredSize().height));
    p1Pane.setMaximumSize(new Dimension(2000, 200));
    p1Pane.setBorder(BorderFactory.createTitledBorder(""));
    // name panel
    JPanel pName = new JPanel();
    pName.setLayout(new GridBagLayout());
    pName.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Name")));
    addItem(pName, routeNameTextField, 0, 0);
    // comment panel
    JPanel pComment = new JPanel();
    pComment.setLayout(new GridBagLayout());
    pComment.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Comment")));
    addItem(pComment, commentTextField, 0, 0);
    p1.add(pName);
    p1.add(pComment);
    JPanel p2 = new JPanel();
    p2.setLayout(new BoxLayout(p2, BoxLayout.X_AXIS));
    JScrollPane p2Pane = new JScrollPane(p2);
    p2Pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
    p2Pane.setMinimumSize(new Dimension(300, 3 * routeNameTextField.getPreferredSize().height));
    p2Pane.setMaximumSize(new Dimension(2000, 200));
    p2Pane.setBorder(BorderFactory.createTitledBorder(""));
    // location panel
    JPanel pLoc = new JPanel();
    pLoc.setLayout(new GridBagLayout());
    pLoc.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Location")));
    addItem(pLoc, locationBox, 0, 1);
    addItem(pLoc, addLocationButton, 1, 1);
    addItem(pLoc, addLocAtTop, 2, 1);
    addItem(pLoc, addLocAtMiddle, 3, 1);
    addItem(pLoc, addLocAtBottom, 4, 1);
    // Wait or Depart Time panel
    JPanel pWait = new JPanel();
    pWait.setLayout(new GridBagLayout());
    pWait.setBorder(BorderFactory.createTitledBorder(Bundle.getMessage("Display")));
    addItem(pWait, showWait, 0, 1);
    addItem(pWait, showDepartTime, 1, 1);
    p2.add(pLoc);
    p2.add(pWait);
    // row 12 buttons
    JPanel pB = new JPanel();
    pB.setLayout(new GridBagLayout());
    JScrollPane pBPane = new JScrollPane(pB);
    pBPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
    pBPane.setMinimumSize(new Dimension(300, 3 * routeNameTextField.getPreferredSize().height));
    pBPane.setMaximumSize(new Dimension(2000, 200));
    pBPane.setBorder(BorderFactory.createTitledBorder(""));
    addItem(pB, deleteRouteButton, 0, 0);
    addItem(pB, addRouteButton, 1, 0);
    addItem(pB, saveRouteButton, 3, 0);
    getContentPane().add(p1Pane);
    getContentPane().add(routePane);
    getContentPane().add(p2Pane);
    getContentPane().add(pBPane);
    // setup buttons
    addButtonAction(addLocationButton);
    addButtonAction(deleteRouteButton);
    addButtonAction(addRouteButton);
    addButtonAction(saveRouteButton);
    // setup radio buttons       
    ButtonGroup group = new ButtonGroup();
    group.add(addLocAtTop);
    group.add(addLocAtMiddle);
    group.add(addLocAtBottom);
    addLocAtBottom.setSelected(true);
    // to clear table row sorting
    addRadioButtonAction(addLocAtTop);
    addRadioButtonAction(addLocAtMiddle);
    // to clear table row sorting
    addRadioButtonAction(addLocAtBottom);
    ButtonGroup groupTime = new ButtonGroup();
    groupTime.add(showWait);
    groupTime.add(showDepartTime);
    addRadioButtonAction(showWait);
    addRadioButtonAction(showDepartTime);
    setTimeWaitRadioButtons();
    // build menu
    JMenuBar menuBar = new JMenuBar();
    JMenu toolMenu = new JMenu(Bundle.getMessage("MenuTools"));
    toolMenu.add(new RouteCopyAction(Bundle.getMessage("MenuItemCopy"), routeName));
    toolMenu.add(new SetTrainIconRouteAction(Bundle.getMessage("MenuSetTrainIconRoute"), routeName));
    toolMenu.addSeparator();
    toolMenu.add(new PrintRouteAction(Bundle.getMessage("MenuItemPrint"), false, _route));
    toolMenu.add(new PrintRouteAction(Bundle.getMessage("MenuItemPreview"), true, _route));
    menuBar.add(toolMenu);
    setJMenuBar(menuBar);
    // NOI18N
    addHelpMenu("package.jmri.jmrit.operations.Operations_EditRoute", true);
    // get notified if combo box gets modified
    LocationManager.instance().addPropertyChangeListener(this);
    // set frame size and route for display
    initMinimumSize(new Dimension(Control.panelWidth700, Control.panelHeight400));
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagLayout(java.awt.GridBagLayout) ButtonGroup(javax.swing.ButtonGroup) BoxLayout(javax.swing.BoxLayout) Dimension(java.awt.Dimension) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Aggregations

BoxLayout (javax.swing.BoxLayout)593 JPanel (javax.swing.JPanel)510 JLabel (javax.swing.JLabel)301 Dimension (java.awt.Dimension)189 ActionEvent (java.awt.event.ActionEvent)179 JButton (javax.swing.JButton)173 ActionListener (java.awt.event.ActionListener)155 JScrollPane (javax.swing.JScrollPane)140 FlowLayout (java.awt.FlowLayout)130 JCheckBox (javax.swing.JCheckBox)74 BorderLayout (java.awt.BorderLayout)73 GridBagLayout (java.awt.GridBagLayout)66 ButtonGroup (javax.swing.ButtonGroup)58 JTable (javax.swing.JTable)53 JTextField (javax.swing.JTextField)53 Container (java.awt.Container)51 JmriJFrame (jmri.util.JmriJFrame)45 JComboBox (javax.swing.JComboBox)44 JSeparator (javax.swing.JSeparator)44 Box (javax.swing.Box)41