Example usage for javax.swing JButton setEnabled

List of usage examples for javax.swing JButton setEnabled

Introduction

In this page you can find the example usage for javax.swing JButton setEnabled.

Prototype

public void setEnabled(boolean b) 

Source Link

Document

Enables (or disables) the button.

Usage

From source file:org.executequery.gui.scriptgenerators.GenerateScriptsPanelThree.java

private JPanel createFileOutputPanel() {

    pathField = WidgetFactory.createTextField();

    final JButton browseButton = new DefaultPanelButton("Browse");
    browseButton.setMnemonic('B');
    browseButton.addActionListener(this);

    final DefaultFieldLabel label = new DefaultFieldLabel("Save Path:");

    writeToFileCheck = new JCheckBox("Write to file");
    writeToFileCheck.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            boolean enable = writeToFileCheck.isSelected();
            browseButton.setEnabled(enable);
            pathField.setEnabled(enable);
            label.setEnabled(enable);//from  w w  w . j  av a  2s .co  m
        }
    });

    browseButton.setEnabled(false);
    pathField.setEnabled(false);
    label.setEnabled(false);

    ComponentTitledPanel panel = new ComponentTitledPanel(writeToFileCheck);
    JPanel fileOutputPanel = panel.getContentPane();
    fileOutputPanel.setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx++;
    gbc.gridy++;
    gbc.insets = new Insets(7, 5, 5, 5);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    fileOutputPanel.add(label, gbc);
    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    fileOutputPanel.add(pathField, gbc);
    gbc.fill = GridBagConstraints.NONE;
    gbc.gridx = 2;
    gbc.weightx = 0;
    gbc.insets.top = 3;
    gbc.insets.right = 5;
    fileOutputPanel.add(browseButton, gbc);

    return panel;
}

From source file:org.geopublishing.atlasStyler.swing.AtlasStylerGUI.java

/**
 * A button to export all layers in form of one SLD XML file (starting a
 * StyledLayerDescriptor tag)/*ww  w. jav a2 s  . com*/
 */
private JButton getJTButtonExportAsSLD() {
    final JButton jButtonExportAsSLD = new JButton(ASUtil.R("AtlasStylerGUI.toolbarButton.exportSLD"));

    jButtonExportAsSLD.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                File saveDir = null;
                String lastPath = ASProps.get(ASProps.Keys.lastExportDirectory);
                if (lastPath != null)
                    saveDir = new File(lastPath);

                File exportSLDFile = AsSwingUtil.chooseFileSave(AtlasStylerGUI.this, saveDir,
                        ASUtil.R("AtlasStylerGUI.saveStyledLayerDescFileDialogTitle"),
                        new FileExtensionFilter(ASUtil.FILTER_SLD));

                // File exportSLDFile = chooser.getSelectedFile();
                if (exportSLDFile == null
                        // || result != JFileChooser.APPROVE_OPTION
                        || exportSLDFile.isDirectory())
                    return;

                ASProps.set(ASProps.Keys.lastExportDirectory, exportSLDFile.getParentFile().getAbsolutePath());

                // If the file exists, the user will be asked about
                // overwriting it
                if (exportSLDFile.exists()) {
                    if (!AVSwingUtil.askOKCancel(AtlasStylerGUI.this,
                            AtlasStylerVector.R(
                                    "AtlasStylerGUI.saveStyledLayerDescFileDialogTitle.OverwriteQuestion",
                                    exportSLDFile.getName())))
                        return;
                }

                // Evt. wird .sld angehangen.
                String filenamelc = exportSLDFile.getName().toLowerCase();
                if (!filenamelc.endsWith(".sld") && !filenamelc.endsWith(".xml")
                        && !filenamelc.endsWith(".se")) {
                    exportSLDFile = new File(exportSLDFile.getParentFile(), filenamelc + ".sld");
                    JOptionPane.showMessageDialog(AtlasStylerGUI.this,
                            AsSwingUtil.R("AtlasStylerGUI.FileNameChangeTo.msg", exportSLDFile.getName()));
                }

                // // Export
                // Charset charset = Charset.forName("UTF-8");
                StyledLayerDescriptor sldTag = CommonFactoryFinder.getStyleFactory(null)
                        .createStyledLayerDescriptor();

                /*******
                 * Export aller Styles als ein SLD Tag
                 */
                for (StyledLayerInterface smi : getMapManager().getStyledObjects()) {

                    try {
                        // if (!(smi instanceof StyledFS)) {
                        // LOGGER.info("Ein Layer aus dem MapContextManagerInterface ist kein StyledFeatureSourceInterface. Es wird ignoriert: "
                        // + smi.getTitle());
                        // continue;
                        // }

                        String name = null;
                        if (smi instanceof StyledFeatureSourceInterface) {
                            StyledFeatureSourceInterface featureGeoObj = (StyledFeatureSourceInterface) smi;
                            name = featureGeoObj.getGeoObject().getSchema().getTypeName();
                        } else if (smi instanceof StyledRasterInterface) {
                            StyledRasterInterface ri = (StyledRasterInterface) smi;
                            if (ri.getGeoObject() instanceof AbstractGridCoverage2DReader) {
                                AbstractGridCoverage2DReader agcr = (AbstractGridCoverage2DReader) ri
                                        .getGeoObject();
                                if (agcr.getSource() instanceof File) {
                                    File rfile = (File) agcr.getSource();
                                    name = IOUtil.changeFileExt(rfile, "").getName();
                                } else
                                    name = "someraster";
                            } else
                                name = "someraster";
                        }

                        NamedLayer namedLayer = CommonFactoryFinder.getStyleFactory(null).createNamedLayer();
                        namedLayer.setName(name);
                        namedLayer.addStyle(smi.getStyle());

                        sldTag.addStyledLayer(namedLayer);
                    } catch (Exception e1) {
                        ExceptionDialog.show(AtlasStylerGUI.this, e1);
                    }
                }

                Writer w = null;
                final SLDTransformer aTransformer = new SLDTransformer();
                // if (charset != null) {
                // aTransformer.setEncoding(charset);
                // }
                aTransformer.setIndentation(2);
                final String xml = aTransformer.transform(sldTag);
                w = new FileWriter(exportSLDFile);
                w.write(xml);
                w.close();
            } catch (IOException e1) {
                ExceptionDialog.show(AtlasStylerGUI.this, e1);
            } catch (TransformerException e2) {
                ExceptionDialog.show(AtlasStylerGUI.this, e2);
            }

        }

    });

    /**
     * Activate the button when more than one layer is available
     */
    jButtonExportAsSLD.setEnabled(getMapManager().getMapContext().getLayerCount() > 0);
    getMapManager().addMapLayerListListener(new MapLayerListAdapter() {

        @Override
        public void layerRemoved(MapLayerListEvent arg0) {
            jButtonExportAsSLD.setEnabled(getMapManager().getMapContext().getLayerCount() > 0);
        }

        @Override
        public void layerAdded(MapLayerListEvent arg0) {
            jButtonExportAsSLD.setEnabled(true);
        }
    });

    return jButtonExportAsSLD;
}

From source file:org.graphwalker.GUI.App.java

private JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText,
        boolean enabled) {
    // Look for the image.
    String imgLocation = "resources/icons/" + imageName + ".png";
    URL imageURL = App.class.getResource(imgLocation);

    // Create and initialize the button.
    JButton button = new JButton();
    button.setActionCommand(actionCommand);
    button.setToolTipText(toolTipText);//  w ww  .  j a v  a  2  s .  co m
    button.addActionListener(this);
    button.setEnabled(enabled);

    if (imageURL != null) { // image found
        button.setIcon(new ImageIcon(imageURL, altText));
    } else { // no image found
        button.setText(altText);
        logger.error("Resource not found: " + imgLocation);
    }

    return button;
}

From source file:org.jab.docsearch.DocSearch.java

private JToolBar createToolBar() {

    // tool bar//from  w  w  w . j ava  2s.  co m
    JToolBar toolBar = new JToolBar();

    // file open
    JButton buttonOpen = new JButton(new ImageIcon(getClass().getResource("/icons/fileopen.png")));
    buttonOpen.setToolTipText(I18n.getString("tooltip.open"));
    buttonOpen.setActionCommand("ac_open");
    buttonOpen.addActionListener(this);
    buttonOpen.setMnemonic(KeyEvent.VK_O);
    buttonOpen.setEnabled(!env.isWebStart()); // disable in WebStart
    toolBar.add(buttonOpen);

    // file save
    JButton buttonSave = new JButton(new ImageIcon(getClass().getResource("/icons/filesave.png")));
    buttonSave.setToolTipText(I18n.getString("tooltip.save"));
    buttonSave.setActionCommand("ac_save");
    buttonSave.addActionListener(this);
    buttonSave.setMnemonic(KeyEvent.VK_S);
    buttonSave.setEnabled(!env.isWebStart()); // disable in WebStart
    toolBar.add(buttonSave);
    toolBar.addSeparator();

    // open browser
    JButton buttonBrowser = new JButton(new ImageIcon(getClass().getResource("/icons/html.png")));
    buttonBrowser.setToolTipText(I18n.getString("tooltip.open_in_browser"));
    buttonBrowser.setActionCommand("ac_openinbrowser");
    buttonBrowser.addActionListener(this);
    buttonBrowser.setMnemonic(KeyEvent.VK_E);
    buttonBrowser.setEnabled(!env.isWebStart()); // disable in WebStart
    toolBar.add(buttonBrowser);
    toolBar.addSeparator();

    // home
    JButton buttonHome = new JButton(new ImageIcon(getClass().getResource("/icons/home.png")));
    buttonHome.setToolTipText(I18n.getString("tooltip.home"));
    buttonHome.setActionCommand("ac_home");
    buttonHome.addActionListener(this);
    buttonHome.setMnemonic(KeyEvent.VK_H);
    toolBar.add(buttonHome);

    // refresh
    JButton buttonRefresh = new JButton(new ImageIcon(getClass().getResource("/icons/refresh.png")));
    buttonRefresh.setToolTipText(I18n.getString("tooltip.refresh"));
    buttonRefresh.setActionCommand("ac_refresh");
    buttonRefresh.addActionListener(this);
    buttonRefresh.setMnemonic(KeyEvent.VK_L);
    toolBar.add(buttonRefresh);
    toolBar.addSeparator();

    // result
    JButton buttonResult = new JButton(new ImageIcon(getClass().getResource("/icons/search_results.png")));
    buttonResult.setToolTipText(I18n.getString("tooltip.results"));
    buttonResult.setActionCommand("ac_result");
    buttonResult.addActionListener(this);
    buttonResult.setMnemonic(KeyEvent.VK_R);
    toolBar.add(buttonResult);
    toolBar.addSeparator();

    // bookmark
    JButton buttonBookMark = new JButton(new ImageIcon(getClass().getResource("/icons/bookmark.png")));
    buttonBookMark.setToolTipText(I18n.getString("tooltip.add_bookmark"));
    buttonBookMark.setActionCommand("ac_addbookmark");
    buttonBookMark.addActionListener(this);
    buttonBookMark.setMnemonic(KeyEvent.VK_M);
    toolBar.add(buttonBookMark);
    toolBar.addSeparator();

    // print
    JButton buttonPrint = new JButton(new ImageIcon(getClass().getResource("/icons/fileprint.png")));
    buttonPrint.setToolTipText(I18n.getString("tooltip.print"));
    buttonPrint.setActionCommand("ac_print");
    buttonPrint.addActionListener(this);
    buttonPrint.setMnemonic(KeyEvent.VK_P);
    toolBar.add(buttonPrint);
    toolBar.addSeparator();

    // setting
    JButton buttonSetting = new JButton(new ImageIcon(getClass().getResource("/icons/configure.png")));
    buttonSetting.setToolTipText(I18n.getString("tooltip.settings"));
    buttonSetting.setActionCommand("ac_settings");
    buttonSetting.addActionListener(this);
    buttonSetting.setMnemonic(KeyEvent.VK_HOME);
    toolBar.add(buttonSetting);
    toolBar.addSeparator();

    // stop
    buttonStop = new JButton(new ImageIcon(getClass().getResource("/icons/stop.png")));
    buttonStop.setToolTipText(I18n.getString("tooltip.stop"));
    buttonStop.setActionCommand("ac_stop");
    buttonStop.addActionListener(this);
    buttonStop.setMnemonic(KeyEvent.VK_X);
    toolBar.add(buttonStop);
    toolBar.addSeparator();

    //
    toolBar.setFloatable(false);

    // finished
    return toolBar;
}

From source file:org.jtrfp.trcl.gui.ConfigWindow.java

public ConfigWindow() {
    setTitle("Settings");
    setSize(340, 540);//  w  ww.  j a v  a2s .  c o m
    if (config == null)
        config = new TRConfiguration();
    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    getContentPane().add(tabbedPane, BorderLayout.CENTER);

    JPanel generalTab = new JPanel();
    tabbedPane.addTab("General",
            new ImageIcon(ConfigWindow.class
                    .getResource("/org/freedesktop/tango/22x22/mimetypes/application-x-executable.png")),
            generalTab, null);
    GridBagLayout gbl_generalTab = new GridBagLayout();
    gbl_generalTab.columnWidths = new int[] { 0, 0 };
    gbl_generalTab.rowHeights = new int[] { 0, 188, 222, 0 };
    gbl_generalTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_generalTab.rowWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE };
    generalTab.setLayout(gbl_generalTab);

    JPanel settingsLoadSavePanel = new JPanel();
    GridBagConstraints gbc_settingsLoadSavePanel = new GridBagConstraints();
    gbc_settingsLoadSavePanel.insets = new Insets(0, 0, 5, 0);
    gbc_settingsLoadSavePanel.anchor = GridBagConstraints.WEST;
    gbc_settingsLoadSavePanel.gridx = 0;
    gbc_settingsLoadSavePanel.gridy = 0;
    generalTab.add(settingsLoadSavePanel, gbc_settingsLoadSavePanel);
    settingsLoadSavePanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null),
            "Overall Settings", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    FlowLayout flowLayout_1 = (FlowLayout) settingsLoadSavePanel.getLayout();
    flowLayout_1.setAlignment(FlowLayout.LEFT);

    JButton btnSave = new JButton("Export...");
    btnSave.setToolTipText("Export these settings to an external file");
    settingsLoadSavePanel.add(btnSave);
    btnSave.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            exportSettings();
        }
    });

    JButton btnLoad = new JButton("Import...");
    btnLoad.setToolTipText("Import an external settings file");
    settingsLoadSavePanel.add(btnLoad);
    btnLoad.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            importSettings();
        }
    });

    JButton btnConfigReset = new JButton("Reset");
    btnConfigReset.setToolTipText("Reset all settings to defaults");
    settingsLoadSavePanel.add(btnConfigReset);
    btnConfigReset.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            defaultSettings();
        }
    });

    JPanel registeredPODsPanel = new JPanel();
    registeredPODsPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null),
            "Registered PODs", TitledBorder.LEFT, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_registeredPODsPanel = new GridBagConstraints();
    gbc_registeredPODsPanel.insets = new Insets(0, 0, 5, 0);
    gbc_registeredPODsPanel.fill = GridBagConstraints.BOTH;
    gbc_registeredPODsPanel.gridx = 0;
    gbc_registeredPODsPanel.gridy = 1;
    generalTab.add(registeredPODsPanel, gbc_registeredPODsPanel);
    GridBagLayout gbl_registeredPODsPanel = new GridBagLayout();
    gbl_registeredPODsPanel.columnWidths = new int[] { 272, 0 };
    gbl_registeredPODsPanel.rowHeights = new int[] { 76, 0, 0 };
    gbl_registeredPODsPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_registeredPODsPanel.rowWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE };
    registeredPODsPanel.setLayout(gbl_registeredPODsPanel);

    JPanel podListPanel = new JPanel();
    GridBagConstraints gbc_podListPanel = new GridBagConstraints();
    gbc_podListPanel.insets = new Insets(0, 0, 5, 0);
    gbc_podListPanel.fill = GridBagConstraints.BOTH;
    gbc_podListPanel.gridx = 0;
    gbc_podListPanel.gridy = 0;
    registeredPODsPanel.add(podListPanel, gbc_podListPanel);
    podListPanel.setLayout(new BorderLayout(0, 0));

    JScrollPane podListScrollPane = new JScrollPane();
    podListPanel.add(podListScrollPane, BorderLayout.CENTER);

    podList = new JList(podLM);
    podList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    podListScrollPane.setViewportView(podList);

    JPanel podListOpButtonPanel = new JPanel();
    podListOpButtonPanel.setBorder(null);
    GridBagConstraints gbc_podListOpButtonPanel = new GridBagConstraints();
    gbc_podListOpButtonPanel.anchor = GridBagConstraints.NORTH;
    gbc_podListOpButtonPanel.gridx = 0;
    gbc_podListOpButtonPanel.gridy = 1;
    registeredPODsPanel.add(podListOpButtonPanel, gbc_podListOpButtonPanel);
    FlowLayout flowLayout = (FlowLayout) podListOpButtonPanel.getLayout();
    flowLayout.setAlignment(FlowLayout.LEFT);

    JButton addPodButton = new JButton("Add...");
    addPodButton.setIcon(
            new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png")));
    addPodButton.setToolTipText("Add a POD to the registry to be considered when running a game.");
    podListOpButtonPanel.add(addPodButton);
    addPodButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            addPOD();
        }
    });

    JButton removePodButton = new JButton("Remove");
    removePodButton.setIcon(new ImageIcon(
            ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png")));
    removePodButton.setToolTipText("Remove a POD file from being considered when playing a game");
    podListOpButtonPanel.add(removePodButton);
    removePodButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            podLM.removeElement(podList.getSelectedValue());
        }
    });

    JButton podEditButton = new JButton("Edit...");
    podEditButton.setIcon(null);
    podEditButton.setToolTipText("Edit the selected POD path");
    podListOpButtonPanel.add(podEditButton);
    podEditButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            editPODPath();
        }
    });

    JPanel missionPanel = new JPanel();
    GridBagConstraints gbc_missionPanel = new GridBagConstraints();
    gbc_missionPanel.fill = GridBagConstraints.BOTH;
    gbc_missionPanel.gridx = 0;
    gbc_missionPanel.gridy = 2;
    generalTab.add(missionPanel, gbc_missionPanel);
    missionPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Missions",
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagLayout gbl_missionPanel = new GridBagLayout();
    gbl_missionPanel.columnWidths = new int[] { 0, 0 };
    gbl_missionPanel.rowHeights = new int[] { 0, 0, 0 };
    gbl_missionPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_missionPanel.rowWeights = new double[] { 1.0, 0.0, Double.MIN_VALUE };
    missionPanel.setLayout(gbl_missionPanel);

    JScrollPane scrollPane = new JScrollPane();
    GridBagConstraints gbc_scrollPane = new GridBagConstraints();
    gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
    gbc_scrollPane.fill = GridBagConstraints.BOTH;
    gbc_scrollPane.gridx = 0;
    gbc_scrollPane.gridy = 0;
    missionPanel.add(scrollPane, gbc_scrollPane);

    missionList = new JList(missionLM);
    missionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    scrollPane.setViewportView(missionList);

    JPanel missionListOpButtonPanel = new JPanel();
    GridBagConstraints gbc_missionListOpButtonPanel = new GridBagConstraints();
    gbc_missionListOpButtonPanel.anchor = GridBagConstraints.NORTH;
    gbc_missionListOpButtonPanel.gridx = 0;
    gbc_missionListOpButtonPanel.gridy = 1;
    missionPanel.add(missionListOpButtonPanel, gbc_missionListOpButtonPanel);

    JButton addVOXButton = new JButton("Add...");
    addVOXButton.setIcon(
            new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png")));
    addVOXButton.setToolTipText("Add an external VOX file as a mission");
    missionListOpButtonPanel.add(addVOXButton);
    addVOXButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            addVOX();
        }
    });

    final JButton removeVOXButton = new JButton("Remove");
    removeVOXButton.setIcon(new ImageIcon(
            ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png")));
    removeVOXButton.setToolTipText("Remove the selected mission");
    missionListOpButtonPanel.add(removeVOXButton);
    removeVOXButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            missionLM.remove(missionList.getSelectedIndex());
        }
    });

    final JButton editVOXButton = new JButton("Edit...");
    editVOXButton.setToolTipText("Edit the selected Mission's VOX path");
    missionListOpButtonPanel.add(editVOXButton);
    editVOXButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            editVOXPath();
        }
    });

    missionList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent evt) {
            final String val = (String) missionList.getSelectedValue();
            if (val == null)
                missionList.setSelectedIndex(0);
            else if (isBuiltinVOX(val)) {
                removeVOXButton.setEnabled(false);
                editVOXButton.setEnabled(false);
            } else {
                removeVOXButton.setEnabled(true);
                editVOXButton.setEnabled(true);
            }
        }
    });

    JPanel soundTab = new JPanel();
    tabbedPane.addTab("Sound",
            new ImageIcon(
                    ConfigWindow.class.getResource("/org/freedesktop/tango/22x22/devices/audio-card.png")),
            soundTab, null);
    GridBagLayout gbl_soundTab = new GridBagLayout();
    gbl_soundTab.columnWidths = new int[] { 0, 0 };
    gbl_soundTab.rowHeights = new int[] { 65, 51, 70, 132, 0, 0, 0 };
    gbl_soundTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_soundTab.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
    soundTab.setLayout(gbl_soundTab);

    JPanel checkboxPanel = new JPanel();
    GridBagConstraints gbc_checkboxPanel = new GridBagConstraints();
    gbc_checkboxPanel.insets = new Insets(0, 0, 5, 0);
    gbc_checkboxPanel.fill = GridBagConstraints.BOTH;
    gbc_checkboxPanel.gridx = 0;
    gbc_checkboxPanel.gridy = 0;
    soundTab.add(checkboxPanel, gbc_checkboxPanel);

    chckbxLinearInterpolation = new JCheckBox("Linear Filtering");
    chckbxLinearInterpolation.setToolTipText("Use the GPU's TMU to smooth playback of low-rate samples.");
    chckbxLinearInterpolation.setHorizontalAlignment(SwingConstants.LEFT);
    checkboxPanel.add(chckbxLinearInterpolation);

    chckbxLinearInterpolation.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            needRestart = true;
        }
    });

    chckbxBufferLag = new JCheckBox("Buffer Lag");
    chckbxBufferLag.setToolTipText("Improves efficiency, doubles latency.");
    checkboxPanel.add(chckbxBufferLag);

    JPanel modStereoWidthPanel = new JPanel();
    FlowLayout flowLayout_2 = (FlowLayout) modStereoWidthPanel.getLayout();
    flowLayout_2.setAlignment(FlowLayout.LEFT);
    modStereoWidthPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null),
            "MOD Stereo Width", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_modStereoWidthPanel = new GridBagConstraints();
    gbc_modStereoWidthPanel.anchor = GridBagConstraints.NORTH;
    gbc_modStereoWidthPanel.insets = new Insets(0, 0, 5, 0);
    gbc_modStereoWidthPanel.fill = GridBagConstraints.HORIZONTAL;
    gbc_modStereoWidthPanel.gridx = 0;
    gbc_modStereoWidthPanel.gridy = 1;
    soundTab.add(modStereoWidthPanel, gbc_modStereoWidthPanel);

    modStereoWidthSlider = new JSlider();
    modStereoWidthSlider.setPaintTicks(true);
    modStereoWidthSlider.setMinorTickSpacing(25);
    modStereoWidthPanel.add(modStereoWidthSlider);

    final JLabel modStereoWidthLbl = new JLabel("NN%");
    modStereoWidthPanel.add(modStereoWidthLbl);

    JPanel bufferSizePanel = new JPanel();
    FlowLayout flowLayout_3 = (FlowLayout) bufferSizePanel.getLayout();
    flowLayout_3.setAlignment(FlowLayout.LEFT);
    bufferSizePanel.setBorder(
            new TitledBorder(null, "Buffer Size", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_bufferSizePanel = new GridBagConstraints();
    gbc_bufferSizePanel.anchor = GridBagConstraints.NORTH;
    gbc_bufferSizePanel.insets = new Insets(0, 0, 5, 0);
    gbc_bufferSizePanel.fill = GridBagConstraints.HORIZONTAL;
    gbc_bufferSizePanel.gridx = 0;
    gbc_bufferSizePanel.gridy = 2;
    soundTab.add(bufferSizePanel, gbc_bufferSizePanel);

    audioBufferSizeCB = new JComboBox();
    audioBufferSizeCB.setModel(new DefaultComboBoxModel(AudioBufferSize.values()));
    bufferSizePanel.add(audioBufferSizeCB);

    soundOutputSelectorGUI = new SoundOutputSelectorGUI();
    soundOutputSelectorGUI.setBorder(
            new TitledBorder(null, "Output Driver", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_soundOutputSelectorGUI = new GridBagConstraints();
    gbc_soundOutputSelectorGUI.anchor = GridBagConstraints.NORTH;
    gbc_soundOutputSelectorGUI.insets = new Insets(0, 0, 5, 0);
    gbc_soundOutputSelectorGUI.fill = GridBagConstraints.HORIZONTAL;
    gbc_soundOutputSelectorGUI.gridx = 0;
    gbc_soundOutputSelectorGUI.gridy = 3;
    soundTab.add(soundOutputSelectorGUI, gbc_soundOutputSelectorGUI);

    modStereoWidthSlider.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent arg0) {
            modStereoWidthLbl.setText(modStereoWidthSlider.getValue() + "%");
            needRestart = true;
        }
    });

    JPanel okCancelPanel = new JPanel();
    getContentPane().add(okCancelPanel, BorderLayout.SOUTH);
    okCancelPanel.setLayout(new BorderLayout(0, 0));

    JButton btnOk = new JButton("OK");
    btnOk.setToolTipText("Apply these settings and close the window");
    okCancelPanel.add(btnOk, BorderLayout.WEST);
    btnOk.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            applySettings();
            ConfigWindow.this.setVisible(false);
        }
    });

    JButton btnCancel = new JButton("Cancel");
    btnCancel.setToolTipText("Close the window without applying settings");
    okCancelPanel.add(btnCancel, BorderLayout.EAST);

    JLabel lblConfigpath = new JLabel(TRConfiguration.getConfigFilePath().getAbsolutePath());
    lblConfigpath.setIcon(null);
    lblConfigpath.setToolTipText("Default config file path");
    lblConfigpath.setHorizontalAlignment(SwingConstants.CENTER);
    lblConfigpath.setFont(new Font("Dialog", Font.BOLD, 6));
    okCancelPanel.add(lblConfigpath, BorderLayout.CENTER);
    btnCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            ConfigWindow.this.setVisible(false);
        }
    });
}

From source file:org.mbs3.juniuploader.gui.frmMain.java

public static void doAllUploads(final JButton btn) {
    log.trace("RemoteSystem: doAllUpload() called");
    org.mbs3.juniuploader.StatusThread.addMessage("Spinning off upload threads for every rule");

    //final Vector urs = uploadRules;
    Runnable go = new Runnable() {
        public void run() {

            if (btn.isEnabled())
                btn.setEnabled(false);

            for (int i = 0; i < uploadRules.getSize(); i++) {
                final UploadRule ur = (UploadRule) uploadRules.getElementAt(i);
                log.trace("doAllUpload() calling upload on " + ur.getUploadSite().getUrl());

                if (ur.isValid()) {
                    org.mbs3.juniuploader.StatusThread
                            .addMessage("Uploading selected file to " + ur.getUploadSite().getUrl());
                    Util.postFileUpload(ur);
                    org.mbs3.juniuploader.StatusThread
                            .addMessage("Completed an upload to " + ur.getUploadSite().getUrl());
                }//w  w  w .j  a va 2 s . c  o  m
            }

            org.mbs3.juniuploader.StatusThread.addMessage("All uploads threads completed!");
            if (!btn.isEnabled())
                btn.setEnabled(true);
        }
    };
    Thread t = new Thread(go);
    t.start();

    log.trace("doAllUpload() completed");
}

From source file:org.mbs3.juniuploader.gui.frmMain.java

public static void syncInterface(final JButton btn) {
    log.debug("syncInterface() called");
    StatusThread.addMessage("Synchronizing with remote UniAdmin interface");

    btn.setEnabled(false);

    Runnable go = new Runnable() {
        public void run() {

            UAInterface.remotePrefstoLocal();
            UAInterface.syncImages();/*w ww.jav  a  2  s  . c o m*/
            for (int i = 0; i < wowDirectories.getSize(); i++) {
                WDirectory currentWowDir = (WDirectory) wowDirectories.getElementAt(i);
                UAInterface.compareAddonsLocalRemote(currentWowDir);
            }
            btn.setEnabled(true);
        }
    };
    Thread t = new Thread(go);
    t.start();

    log.debug("syncInterface() completed");
    StatusThread.addMessage("Synchronizing with remote UniAdmin interface completed");
}

From source file:org.mbs3.juniuploader.gui.pnlMainMenu.java

private void btnSyncUAInterfaceActionPerformed(ActionEvent evt) {
    log.trace("pnlMainMenu: btnSyncUAInterfaceActionPerformed called");
    JButton btn = (JButton) evt.getSource();
    if (btn == this.btnSyncUAInterface) {
        btn.setEnabled(false);
        frmMain.syncInterface(btn);//from   w w w . j  av a 2 s.c  o  m
    }
}

From source file:org.n52.ifgicopter.spf.input.DummyInputPlugin.java

@Override
public void init() throws Exception {
    this.gui = new ModuleGUI();
    JPanel panel = new JPanel(new FlowLayout());
    JLabel label = new JLabel("<html><h1>Dummy InputPlugin</h1><p>Running time: " + LOOP_SEC
            + " seconds with a new value interval of " + this.sleeptime
            + " milliseconds.</p><p></p><p>Once started, you cannot stop it.</p></html>");
    panel.add(label);/* ww w  .ja  v  a  2 s. c o  m*/

    final JButton startbut = new JButton("Start");
    startbut.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            start();
            startbut.setEnabled(false);
        }
    });
    panel.add(startbut);

    this.gui.setGui(panel);

    new Thread(new Runnable() {

        @Override
        public void run() {
            while (!DummyInputPlugin.this.initialized) {
                try {
                    Thread.sleep(THREAD_SLEEP_TIME_MASTER_WHILE_LOOP);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

            try {
                while (true) {
                    if (DummyInputPlugin.this.running) {

                        innerRun();

                    } else {
                        try {
                            Thread.sleep(THREAD_SLEEP_TIME_MASTER_WHILE_LOOP);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            } catch (Exception e) {
                log.error("error in run()", e);
            }
        }

        private void innerRun() {
            double altDelta = 0.5;
            int humicount = 0;
            Random rand = new Random();

            Map<String, Object> posData = null;
            Map<String, Object> sensorData = null;

            long start = System.currentTimeMillis();
            posData = new HashMap<String, Object>();

            /*
             * do loop of LOOP_SEC seconds
             */
            log.debug("starting time series for " + LOOP_SEC + " seconds.");
            while (System.currentTimeMillis() - start < LOOP_SEC * 1000) {

                posData.put("time", Long.valueOf(System.currentTimeMillis()));
                posData.put("latitude", Double.valueOf(52.0 + rand.nextDouble() * 0.0025));
                posData.put("longitude", Double.valueOf(7.0 + rand.nextDouble() * 0.0025));
                posData.put("altitude", Double.valueOf((altDelta * humicount) + 34.0 + rand.nextDouble() * 7));

                DummyInputPlugin.this.populateNewData(posData);

                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    log.error(e);
                }

                /*
                 * now with humidity
                 */
                sensorData = new HashMap<String, Object>();

                sensorData.put("time", Long.valueOf(System.currentTimeMillis()));
                sensorData.put("humidity", Double.valueOf(70.2 + (rand.nextInt(200) / 10.0)));
                sensorData.put("humiditay", Double.valueOf(70.2 + (rand.nextInt(200) / 10.0)));
                sensorData.put("temperature", Double.valueOf(20.0 + (rand.nextInt(40) / 10.0)));
                humicount++;

                DummyInputPlugin.this.populateNewData(sensorData);

                try {
                    Thread.sleep(DummyInputPlugin.this.sleeptime);
                } catch (InterruptedException e) {
                    log.error(e);
                }

            }

            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                log.error(e);
            }

            posData.put("time", Long.valueOf(System.currentTimeMillis()));
            DummyInputPlugin.this.populateNewData(posData);

            log.info("humicount=" + humicount);

            // just one run!
            stop();
        }

    }).start();

    this.initialized = true;
}

From source file:org.nuclos.client.dbtransfer.DBTransferImport.java

private PanelWizardStep newStep1(final MainFrameTab ifrm) {
    final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate();
    final PanelWizardStep step = new PanelWizardStep(
            localeDelegate.getMessage("dbtransfer.import.step1.1", "Konfigurationsdatei"),
            localeDelegate.getMessage("dbtransfer.import.step1.2",
                    "Bitte w\u00e4hlen Sie eine Konfigurationsdatei aus."));

    final JLabel lbFile = new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.3", "Datei"));

    utils.initJPanel(step,/*from ww w. j  a  v a  2  s.com*/
            new double[] { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED,
                    TableLayout.FILL },
            new double[] { 20, TableLayout.PREFERRED, lbFile.getPreferredSize().height, TableLayout.FILL });

    final JButton btnBrowse = new JButton("...");
    //final JProgressBar progressBar = new JProgressBar(0, 230);
    final JCheckBox chbxImportAsNuclon = new JCheckBox(
            localeDelegate.getMessage("configuration.transfer.import.as.nuclon", "Import als Nuclon"));
    chbxImportAsNuclon.setEnabled(false);
    final JEditorPane editWarnings = new JEditorPane();
    editWarnings.setContentType("text/html");
    editWarnings.setEditable(false);
    editWarnings.setBackground(Color.WHITE);

    final JScrollPane scrollWarn = new JScrollPane(editWarnings);
    scrollWarn.setPreferredSize(new Dimension(680, 250));
    scrollWarn.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    scrollWarn.getVerticalScrollBar().setUnitIncrement(20);
    scrollWarn.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollWarn.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    final JScrollPane scrollPrev = new JScrollPane(jpnPreviewContent);
    scrollPrev.setPreferredSize(new Dimension(680, 250));
    scrollPrev.setBorder(new LineBorder(Color.LIGHT_GRAY, 1));
    scrollPrev.getVerticalScrollBar().setUnitIncrement(20);
    scrollPrev.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPrev.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    final JPanel jpnPreview = new JPanel(new BorderLayout());
    jpnPreview.add(jpnPreviewHeader, BorderLayout.NORTH);
    jpnPreview.add(scrollPrev, BorderLayout.CENTER);
    jpnPreview.add(jpnPreviewFooter, BorderLayout.SOUTH);
    jpnPreview.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    jpnPreview.setBackground(Color.WHITE);
    jpnPreviewHeader.setBackground(Color.WHITE);
    jpnPreviewContent.setBackground(Color.WHITE);
    jpnPreviewFooter.setBackground(Color.WHITE);

    final JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab(localeDelegate.getMessage("configuration.transfer.prepare.warnings.tab", "Warnungen"),
            scrollWarn);
    final String sDefaultPreparePreviewTabText = localeDelegate
            .getMessage("configuration.transfer.prepare.preview.tab", "Vorschau der Schema Aenderungen");
    tabbedPane.addTab(sDefaultPreparePreviewTabText, jpnPreview);

    final JLabel lbNewUser = new JLabel();

    step.add(lbFile, "0,0");
    step.add(tfTransferFile, "1,0");
    step.add(btnBrowse, "2,0");
    step.add(chbxImportAsNuclon, "1,1");//step.add(progressBar, "1,1");
    step.add(lbNewUser, "0,2,3,2");
    step.add(tabbedPane, "0,3,3,3");

    tfTransferFile.setEditable(false);

    final ActionListener prepareImportAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            ifrm.lockLayerWithProgress(Transfer.TOPIC_CORRELATIONID_PREPARE);

            Thread t = new Thread() {
                @Override
                public void run() {
                    step.setComplete(false);
                    boolean blnTransferWithWarnings = false;
                    //progressBar.setValue(0);
                    //progressBar.setVisible(true);
                    try {
                        String fileName = tfTransferFile.getText();
                        if (StringUtils.isNullOrEmpty(fileName)) {
                            return;
                        }
                        File f = new File(fileName);
                        long size = f.length();

                        final InputStream fin = new BufferedInputStream(new FileInputStream(f));
                        final byte[] transferFile;
                        try {
                            transferFile = utils.getBytes(fin, (int) size);
                        } finally {
                            fin.close();
                        }

                        resetStep2();
                        importTransferObject = getTransferFacadeRemote().prepareTransfer(isNuclon,
                                transferFile);
                        chbxImportAsNuclon.setEnabled(importTransferObject.getTransferOptions()
                                .containsKey(TransferOption.IS_NUCLON_IMPORT_ALLOWED));

                        step.setComplete(!importTransferObject.result.hasCriticals());

                        if (!importTransferObject.result.hasCriticals()
                                && !importTransferObject.result.hasWarnings()) {
                            editWarnings.setText(localeDelegate.getMessage(
                                    "configuration.transfer.prepare.no.warnings", "Keine Warnungen"));
                        } else {
                            editWarnings.setText("<html><body><font color=\"#800000\">"
                                    + importTransferObject.result.getCriticals() + "</font>"
                                    + (importTransferObject.result.hasCriticals() ? "<br />" : "")
                                    + importTransferObject.result.getWarnings() + "</body></html>");
                        }

                        int iPreviewSize = importTransferObject.getPreviewParts().size();
                        blnTransferWithWarnings = setupPreviewPanel(importTransferObject.getPreviewParts());
                        tabbedPane.setTitleAt(1, sDefaultPreparePreviewTabText
                                + (iPreviewSize == 0 ? "" : " (" + iPreviewSize + ")"));
                        lbNewUser.setText(
                                "Neue Benutzer" + ": " + (importTransferObject.getNewUserCount() == 0 ? "keine"
                                        : importTransferObject.getNewUserCount()));
                    } catch (Exception e) {
                        //                              progressBar.setVisible(false);
                        Errors.getInstance().showExceptionDialog(ifrm, e);
                    } finally {
                        btnBrowse.setEnabled(true);
                        //                              progressBar.setVisible(false);
                        ifrm.unlockLayer();
                    }
                    if (blnTransferWithWarnings) {
                        JOptionPane.showMessageDialog(jpnPreviewContent, localeDelegate.getMessage(
                                "dbtransfer.import.step1.19",
                                "Nicht alle Statements knnen durchgefhrt werden!\nBitte kontrollieren Sie die mit rot markierten Eintrge!",
                                "Warning", JOptionPane.WARNING_MESSAGE));
                    }
                }

            };

            t.start();
        }
    };
    final ActionListener browseAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            final JFileChooser filechooser = utils.getFileChooser(
                    localeDelegate.getMessage("configuration.transfer.file.nuclet", "Nuclet-Dateien"),
                    ".nuclet");
            final int iBtn = filechooser.showOpenDialog(ifrm);

            if (iBtn == JFileChooser.APPROVE_OPTION) {

                final File file = filechooser.getSelectedFile();
                if (file != null) {
                    tfTransferFile.setText("");
                    btnBrowse.setEnabled(false);
                    //progressBar.setVisible(true);

                    String fileName = file.getPath();
                    if (StringUtils.isNullOrEmpty(fileName)) {
                        return;
                    }

                    tfTransferFile.setText(fileName);

                    prepareImportAction.actionPerformed(new ActionEvent(this, 0, "prepare"));
                }
            }
        }
    };
    final ActionListener importAsNuclonAction = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            isNuclon = chbxImportAsNuclon.isSelected();
            prepareImportAction.actionPerformed(new ActionEvent(this, 0, "prepare"));
        }
    };
    btnBrowse.addActionListener(browseAction);
    chbxImportAsNuclon.addActionListener(importAsNuclonAction);

    //      progressBar.setVisible(false);

    return step;
}