Search in sources :

Example 76 with ChangeEvent

use of javax.swing.event.ChangeEvent in project JMRI by JMRI.

the class AudioBufferFrame method layoutFrame.

@Override
@SuppressWarnings("UnnecessaryBoxing")
public void layoutFrame() {
    super.layoutFrame();
    JPanel p;
    JPanel p2;
    p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Bundle.getMessage("LabelSample")), BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    p2 = new JPanel();
    p2.setLayout(new FlowLayout());
    p2.add(urlLabel);
    p2.add(url);
    buttonBrowse.addActionListener(this::browsePressed);
    buttonBrowse.setToolTipText(Bundle.getMessage("ToolTipButtonBrowse"));
    p2.add(buttonBrowse);
    p.add(p2);
    p2 = new JPanel();
    p2.setLayout(new FlowLayout());
    p2.add(stream);
    p.add(p2);
    //        p2 = new JPanel(); p2.setLayout(new FlowLayout());
    //        p2.add(formatLabel);
    //        p2.add(format);
    //        p.add(p2);
    main.add(p);
    //        p = new JPanel();
    //        p.setBorder(BorderFactory.createCompoundBorder(
    //                        BorderFactory.createTitledBorder("Waveforms"),
    //                        BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    //
    //        JLabel label = new JLabel("Whole sample");
    //        label.setUI(new VerticalLabelUI());
    //        p.add(label);
    //
    //        waveForm.setPreferredSize(new Dimension(400, 120));
    //        p.add(waveForm);
    //
    //        label = new JLabel("Loop-point detail");
    //        label.setUI(new VerticalLabelUI());
    //        p.add(label);
    //
    //        AudioWaveFormPanel waveFormLoop = new AudioWaveFormPanel();
    //        waveFormLoop.setPreferredSize(new Dimension(80, 120));
    //        p.add(waveFormLoop);
    //
    //        main.add(p);
    //
    p = new JPanel();
    p.setLayout(new FlowLayout());
    p.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Bundle.getMessage("LabelLoopPoints")), BorderFactory.createEmptyBorder(5, 5, 5, 5)));
    p.add(loopStartLabel);
    loopStart.setPreferredSize(new JTextField(8).getPreferredSize());
    loopStart.setModel(new SpinnerNumberModel(Long.valueOf(0), Long.valueOf(0), Long.valueOf(Long.MAX_VALUE), Long.valueOf(1)));
    loopStart.addChangeListener((ChangeEvent e) -> {
        loopEnd.setValue(((Long) loopStart.getValue() < (Long) loopEnd.getValue()) ? loopEnd.getValue() : loopStart.getValue());
    });
    p.add(loopStart);
    p.add(loopEndLabel);
    loopEnd.setPreferredSize(new JTextField(8).getPreferredSize());
    loopEnd.setModel(new SpinnerNumberModel(Long.valueOf(0), Long.valueOf(0), Long.valueOf(Long.MAX_VALUE), Long.valueOf(1)));
    loopEnd.addChangeListener((ChangeEvent e) -> {
        loopStart.setValue(((Long) loopEnd.getValue() < (Long) loopStart.getValue()) ? loopEnd.getValue() : loopStart.getValue());
    });
    p.add(loopEnd);
    main.add(p);
    p = new JPanel();
    JButton apply;
    p.add(apply = new JButton(Bundle.getMessage("ButtonApply")));
    apply.addActionListener((ActionEvent e) -> {
        applyPressed(e);
    });
    JButton ok;
    p.add(ok = new JButton(Bundle.getMessage("ButtonOK")));
    ok.addActionListener((ActionEvent e) -> {
        applyPressed(e);
        frame.dispose();
    });
    JButton cancel;
    p.add(cancel = new JButton(Bundle.getMessage("ButtonCancel")));
    cancel.addActionListener((ActionEvent e) -> {
        frame.dispose();
    });
    frame.getContentPane().add(p);
}
Also used : SpinnerNumberModel(javax.swing.SpinnerNumberModel) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ChangeEvent(javax.swing.event.ChangeEvent) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField)

Example 77 with ChangeEvent

use of javax.swing.event.ChangeEvent in project JMRI by JMRI.

the class MemoryIconCoordinateEdit method initSetXY.

@Override
public void initSetXY() {
    oldX = pl.getOriginalX();
    oldY = pl.getOriginalY();
    textX = new javax.swing.JLabel();
    textX.setText("X: " + pl.getOriginalX());
    textX.setVisible(true);
    textY = new javax.swing.JLabel();
    textY.setText("Y: " + pl.getOriginalY());
    textY.setVisible(true);
    SpinnerNumberModel model = new SpinnerNumberModel(0, 0, 10000, 1);
    ChangeListener listener = new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            int x = ((Number) spinX.getValue()).intValue();
            int y = ((Number) spinY.getValue()).intValue();
            pl.setLocation(x, y);
            textX.setText(" X: " + pl.getOriginalX());
            textY.setText(" Y: " + pl.getOriginalY());
        }
    };
    spinX = new javax.swing.JSpinner(model);
    spinX.setValue(Integer.valueOf(pl.getOriginalX()));
    spinX.setToolTipText(Bundle.getMessage("EnterXcoord"));
    spinX.setMaximumSize(new Dimension(spinX.getMaximumSize().width, spinX.getPreferredSize().height));
    spinX.addChangeListener(listener);
    model = new javax.swing.SpinnerNumberModel(0, 0, 10000, 1);
    spinY = new javax.swing.JSpinner(model);
    spinY.setValue(Integer.valueOf(pl.getOriginalY()));
    spinY.setToolTipText(Bundle.getMessage("EnterYcoord"));
    spinY.setMaximumSize(new Dimension(spinY.getMaximumSize().width, spinY.getPreferredSize().height));
    spinY.addChangeListener(listener);
    getContentPane().setLayout(new GridBagLayout());
    addSpinItems(true);
    okButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            int x = ((Number) spinX.getValue()).intValue();
            int y = ((Number) spinY.getValue()).intValue();
            pl.setLocation(x, y);
            textX.setText(" X: " + pl.getOriginalX());
            textY.setText(" Y: " + pl.getOriginalY());
            dispose();
        }
    });
    okButton.getRootPane().setDefaultButton(okButton);
    cancelButton.addActionListener(new java.awt.event.ActionListener() {

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            pl.setLocation(oldX, oldY);
            dispose();
        }
    });
    // make large enough to easily move
    setMinimumSize(new Dimension(250, 175));
    pack();
}
Also used : GridBagLayout(java.awt.GridBagLayout) SpinnerNumberModel(javax.swing.SpinnerNumberModel) Dimension(java.awt.Dimension) ActionEvent(java.awt.event.ActionEvent) SpinnerNumberModel(javax.swing.SpinnerNumberModel) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 78 with ChangeEvent

use of javax.swing.event.ChangeEvent in project intellij-plugins by JetBrains.

the class JstdServerSettingsTab method listenForChanges.

private void listenForChanges() {
    myPortField.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            update();
        }
    });
    myBrowserTimeoutSpinner.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            update();
        }
    });
    myRunnerModeComboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            update();
        }
    });
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ChangeEvent(javax.swing.event.ChangeEvent) PropertyChangeEvent(java.beans.PropertyChangeEvent) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ChangeListener(javax.swing.event.ChangeListener)

Example 79 with ChangeEvent

use of javax.swing.event.ChangeEvent in project JMRI by JMRI.

the class VSDManagerFrame method initGUI.

/**
     * Build the GUI components
     */
public void initGUI() {
    log.debug("initGUI");
    this.setTitle(Bundle.getMessage("VSDManagerFrameTitle"));
    this.buildMenu();
    this.setLayout(new BoxLayout(this.getContentPane(), BoxLayout.PAGE_AXIS));
    decoderPane = new JPanel();
    decoderPane.setLayout(new BoxLayout(decoderPane, BoxLayout.PAGE_AXIS));
    decoderBlank = VSDControl.generateBlank();
    decoderPane.add(decoderBlank);
    volumePane = new JPanel();
    volumePane.setLayout(new BoxLayout(volumePane, BoxLayout.LINE_AXIS));
    JToggleButton muteButton = new JToggleButton(Bundle.getMessage("MuteButtonLabel"));
    JButton addButton = new JButton(Bundle.getMessage("AddButtonLabel"));
    JButton closeButton = new JButton(Bundle.getMessage("ButtonClose"));
    JSlider volume = new JSlider(0, 100);
    volume.setMinorTickSpacing(10);
    volume.setPaintTicks(true);
    volume.setValue(80);
    volume.setPreferredSize(new Dimension(200, 20));
    volume.setToolTipText(Bundle.getMessage("MgrVolumeToolTip"));
    volume.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            volumeChange(e);
        }
    });
    volumePane.add(new JLabel(Bundle.getMessage("VolumePaneLabel")));
    volumePane.add(volume);
    volumePane.add(muteButton);
    muteButton.setToolTipText(Bundle.getMessage("MgrMuteToolTip"));
    muteButton.setMnemonic(Mnemonics.get("MuteButton"));
    muteButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            muteButtonPressed(e);
        }
    });
    volumePane.add(addButton);
    addButton.setToolTipText(Bundle.getMessage("MgrAddButtonToolTip"));
    addButton.setMnemonic(Mnemonics.get("AddButton"));
    addButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            addButtonPressed(e);
        }
    });
    volumePane.add(closeButton);
    closeButton.setToolTipText(Bundle.getMessage("MgrCloseButtonToolTip"));
    closeButton.setMnemonic(Mnemonics.get("CloseButton"));
    closeButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            closeButtonPressed(e);
        }
    });
    this.add(decoderPane);
    this.add(volumePane);
    log.debug("pane size + " + decoderPane.getPreferredSize());
    this.pack();
    this.setVisible(true);
    log.debug("done...");
}
Also used : JPanel(javax.swing.JPanel) JToggleButton(javax.swing.JToggleButton) PropertyChangeEvent(java.beans.PropertyChangeEvent) ChangeEvent(javax.swing.event.ChangeEvent) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JSlider(javax.swing.JSlider) JLabel(javax.swing.JLabel) ChangeListener(javax.swing.event.ChangeListener) PropertyChangeListener(java.beans.PropertyChangeListener) Dimension(java.awt.Dimension)

Example 80 with ChangeEvent

use of javax.swing.event.ChangeEvent in project JMRI by JMRI.

the class EcosLocoTableTabAction method createModel.

@Override
protected void createModel() {
    dataPanel = new JPanel();
    dataTabs = new JTabbedPane();
    dataPanel.setLayout(new BorderLayout());
    java.util.List<EcosSystemConnectionMemo> list = jmri.InstanceManager.getList(EcosSystemConnectionMemo.class);
    if (list != null) {
        for (EcosSystemConnectionMemo eMemo : list) {
            //We only want to add connections that have an active loco address manager
            if (eMemo.getLocoAddressManager() != null) {
                TabbedTableItem itemModel = new TabbedTableItem(eMemo.getUserName(), true, eMemo.getLocoAddressManager(), getNewTableAction(eMemo.getUserName(), eMemo));
                tabbedTableArray.add(itemModel);
            }
        }
    }
    if (tabbedTableArray.size() == 1) {
        EcosLocoTableAction table = (EcosLocoTableAction) tabbedTableArray.get(0).getAAClass();
        table.addToPanel(this);
        dataPanel.add(tabbedTableArray.get(0).getPanel(), BorderLayout.CENTER);
    } else {
        for (int x = 0; x < tabbedTableArray.size(); x++) {
            EcosLocoTableAction table = (EcosLocoTableAction) tabbedTableArray.get(x).getAAClass();
            table.addToPanel(this);
            dataTabs.addTab(tabbedTableArray.get(x).getItemString(), null, tabbedTableArray.get(x).getPanel(), null);
        }
        dataTabs.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent evt) {
                setMenuBar(f);
            }
        });
        dataPanel.add(dataTabs, BorderLayout.CENTER);
    }
    init = true;
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) ChangeEvent(javax.swing.event.ChangeEvent) EcosSystemConnectionMemo(jmri.jmrix.ecos.EcosSystemConnectionMemo) JTabbedPane(javax.swing.JTabbedPane) ChangeListener(javax.swing.event.ChangeListener)

Aggregations

ChangeEvent (javax.swing.event.ChangeEvent)245 ChangeListener (javax.swing.event.ChangeListener)206 JPanel (javax.swing.JPanel)60 ActionEvent (java.awt.event.ActionEvent)52 ActionListener (java.awt.event.ActionListener)47 JLabel (javax.swing.JLabel)40 Dimension (java.awt.Dimension)30 GridBagConstraints (java.awt.GridBagConstraints)27 GridBagLayout (java.awt.GridBagLayout)24 JCheckBox (javax.swing.JCheckBox)24 Insets (java.awt.Insets)22 JButton (javax.swing.JButton)21 JSlider (javax.swing.JSlider)21 PropertyChangeEvent (java.beans.PropertyChangeEvent)20 JSpinner (javax.swing.JSpinner)19 SpinnerNumberModel (javax.swing.SpinnerNumberModel)19 BorderLayout (java.awt.BorderLayout)18 PropertyChangeListener (java.beans.PropertyChangeListener)17 IOException (java.io.IOException)16 BoxLayout (javax.swing.BoxLayout)16