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:edu.ku.brc.af.ui.PasswordStrengthUI.java

/**
 * Hooks up a Password field to the Strength UI
 * @param pwdTF the password text field to be be hooked up to this
 * @param btn optional button that will be enabled when the PasswordText is not empty
 *//*from w ww  .j  a  v  a2  s  .  co m*/
public void setPasswordField(final JTextField pwdTF, final JButton btn) {
    DocumentListener listener = new DocumentAdaptor() {
        @Override
        protected void changed(DocumentEvent e) {
            String txt = ((JTextField) pwdTF).getText();

            if (StringUtils.isEmpty(txt)) {
                initialSet = true;
                doPainting = false;
                for (JCheckBox cbx : cbxs) {
                    cbx.setSelected(false);
                }

            } else if (initialSet) {
                initialSet = false;
            } else {
                doPainting = true;
            }

            if (btn != null) {
                btn.setEnabled(!txt.isEmpty());
            }

            if (doPainting) {
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        checkStrength(pwdTF.getText()); // ignore return boolean
                        colorPanel.repaint();
                    }
                });
            }
        }
    };

    pwdTF.getDocument().addDocumentListener(listener);
}

From source file:sanger.team16.gui.genevar.eqtl.snp.CisEQTLSNPPane2.java

private void setTranscriptPanel(String variationName, ChartPanel regionalLinePlot)
        throws ArrayIndexOutOfBoundsException {
    BaseJPane panel = new BaseJPane(variationName, 10, 20, 10, 20);

    // ------------------ Panel p0 (start) ------------------ //
    BaseJPane p0 = new BaseJPane();

    p0.add(regionalLinePlot);//ww  w . ja  v a 2s  .c o  m

    //p0.setBaseSpringBoxTrailing();
    panel.add(p0);
    // ------------------ Panel p0 (end) ------------------ //

    panel.add(new JLabel(""));
    panel.add(new JLabel(""));
    panel.add(new JLabel(""));

    // ------------------ Panel p1 (start) ------------------ //
    BaseJPane p1 = new BaseJPane();

    JButton bSelectAll = new JButton(" Deselect All ");
    JButton bExport = new JButton("  Export List  ");
    CisSNPPane2Listener cisSNP2Listener = new CisSNPPane2Listener(bSelectAll, bExport);

    //bSelectAll.setForeground(new Color(34,139,34));
    bSelectAll.setForeground(Color.GREEN.darker());
    bSelectAll.addActionListener(cisSNP2Listener);
    p1.add(bSelectAll);

    bExport.addActionListener(cisSNP2Listener);
    p1.add(bExport);

    p1.add(Box.createHorizontalGlue());
    this.setLinkToPanel(p1, assemblyId, snp.getChromosome(), snp.getPosition(), distanceToSNP);

    p1.setBaseSpringBox();
    panel.add(p1);
    // ------------------ Panel p1 (end) ------------------ //

    // ------------------ Panel p2 (start) ------------------ //
    //BaseJTable transcriptTable = this.transcriptTable.getSortedTable();   //TODO
    if (transcriptTable.isEnabled()) {
        bSelectAll.setEnabled(false);
        bExport.setEnabled(false);
    }
    this.setTranscriptTable();

    BaseJPane p2 = new BaseJPane();
    p2.setLayout(new BorderLayout());
    p2.add(transcriptTable.getTableHeader(), BorderLayout.PAGE_START);
    p2.add(transcriptTable, BorderLayout.CENTER);

    //p0.setBaseSpringGrid(1, 1);
    panel.add(p2);
    // ------------------ Panel p2 (end) ------------------ //

    panel.add(new JLabel(" (Use CTRL+C to copy genes of interest)"));

    panel.setBaseSpringGrid(1);
    this.add(panel);
}

From source file:sanger.team16.gui.genevar.mqtl.snp.CisMQTLSNPPane2.java

private void setMofidicationPanel(String variationName, ChartPanel regionalLinePlot)
        throws ArrayIndexOutOfBoundsException {
    BaseJPane panel = new BaseJPane(variationName, 10, 20, 10, 20);

    // ------------------ Panel p0 (start) ------------------ //
    BaseJPane p0 = new BaseJPane();

    p0.add(regionalLinePlot);//  w ww.  j  a  va2 s .com

    //p0.setBaseSpringBoxTrailing();
    panel.add(p0);
    // ------------------ Panel p0 (end) ------------------ //

    panel.add(new JLabel(""));
    panel.add(new JLabel(""));
    panel.add(new JLabel(""));

    // ------------------ Panel p1 (start) ------------------ //
    BaseJPane p1 = new BaseJPane();

    JButton bSelectAll = new JButton(" Deselect All ");
    JButton bExport = new JButton("  Export List  ");
    CisSNPPane2Listener cisSNP2Listener = new CisSNPPane2Listener(bSelectAll, bExport);

    //bSelectAll.setForeground(new Color(34,139,34));
    bSelectAll.setForeground(Color.GREEN.darker());
    bSelectAll.addActionListener(cisSNP2Listener);
    p1.add(bSelectAll);

    bExport.addActionListener(cisSNP2Listener);
    p1.add(bExport);

    p1.add(Box.createHorizontalGlue());
    this.setLinkToPanel(p1, assemblyId, snp.getChromosome(), snp.getPosition(), distanceToSNP);

    p1.setBaseSpringBox();
    panel.add(p1);
    // ------------------ Panel p1 (end) ------------------ //

    // ------------------ Panel p2 (start) ------------------ //
    //BaseJTable transcriptTable = this.transcriptTable.getSortedTable();   //TODO
    if (modificationTable.isEnabled()) {
        bSelectAll.setEnabled(false);
        bExport.setEnabled(false);
    }
    this.setTranscriptTable();

    BaseJPane p2 = new BaseJPane();
    p2.setLayout(new BorderLayout());
    p2.add(modificationTable.getTableHeader(), BorderLayout.PAGE_START);
    p2.add(modificationTable, BorderLayout.CENTER);

    //p0.setBaseSpringGrid(1, 1);
    panel.add(p2);
    // ------------------ Panel p2 (end) ------------------ //

    panel.add(new JLabel(" (Use CTRL+C to copy CpG probes of interest)"));

    panel.setBaseSpringGrid(1);
    this.add(panel);
}

From source file:edu.uci.ics.jung.samples.PerspectiveTransformerDemo.java

/**
 * create an instance of a simple graph with controls to
 * demo the zoom and perspective features.
 * // w ww .  j  a  v a2 s . co  m
 */
@SuppressWarnings("serial")
public PerspectiveTransformerDemo() {

    // create a simple graph for the demo
    graph = TestGraphs.getOneComponentGraph();

    graphLayout = new FRLayout<String, Number>(graph);
    ((FRLayout<String, Number>) graphLayout).setMaxIterations(1000);

    Dimension preferredSize = new Dimension(600, 600);
    Map<String, Point2D> map = new HashMap<String, Point2D>();
    Transformer<String, Point2D> vlf = TransformerUtils.mapTransformer(map);
    grid = this.generateVertexGrid(map, preferredSize, 25);
    gridLayout = new StaticLayout<String, Number>(grid, vlf, preferredSize);

    final VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>(
            graphLayout, preferredSize);
    vv = new VisualizationViewer<String, Number>(visualizationModel, preferredSize);
    PickedState<Number> pes = vv.getPickedEdgeState();
    vv.getRenderContext()
            .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red));
    vv.getRenderContext().setVertexShapeTransformer(new Transformer<String, Shape>() {

        public Shape transform(String v) {
            return new Rectangle2D.Float(-10, -10, 20, 20);
        }
    });
    vv.setBackground(Color.white);

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller<String>());

    Container content = getContentPane();
    GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv);
    content.add(gzsp);

    /**
     * the regular graph mouse for the normal view
     */
    final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>();

    vv.setGraphMouse(graphMouse);

    viewSupport = new PerspectiveViewTransformSupport<String, Number>(vv);
    layoutSupport = new PerspectiveLayoutTransformSupport<String, Number>(vv);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 0.9f, vv.getCenter());
        }
    });
    final JSlider horizontalSlider = new JSlider(-120, 120, 0) {

        /* (non-Javadoc)
         * @see javax.swing.JComponent#getPreferredSize()
         */
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(80, super.getPreferredSize().height);
        }
    };

    final JSlider verticalSlider = new JSlider(-120, 120, 0) {

        /* (non-Javadoc)
         * @see javax.swing.JComponent#getPreferredSize()
         */
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(super.getPreferredSize().width, 80);
        }
    };
    verticalSlider.setOrientation(JSlider.VERTICAL);
    final ChangeListener changeListener = new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            int vval = -verticalSlider.getValue();
            int hval = horizontalSlider.getValue();

            Dimension d = vv.getSize();
            PerspectiveTransform pt = null;
            pt = PerspectiveTransform.getQuadToQuad(vval, hval, d.width - vval, -hval, d.width + vval,
                    d.height + hval, -vval, d.height - hval,

                    0, 0, d.width, 0, d.width, d.height, 0, d.height);

            viewSupport.getPerspectiveTransformer().setPerspectiveTransform(pt);
            layoutSupport.getPerspectiveTransformer().setPerspectiveTransform(pt);
            vv.repaint();
        }
    };
    horizontalSlider.addChangeListener(changeListener);
    verticalSlider.addChangeListener(changeListener);

    JPanel perspectivePanel = new JPanel(new BorderLayout());
    JPanel perspectiveCenterPanel = new JPanel(new BorderLayout());
    perspectivePanel.setBorder(BorderFactory.createTitledBorder("Perspective Controls"));
    final JButton center = new JButton("Center");
    center.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            horizontalSlider.setValue(0);
            verticalSlider.setValue(0);
        }
    });
    ButtonGroup radio = new ButtonGroup();
    JRadioButton normal = new JRadioButton("None");
    normal.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            boolean selected = e.getStateChange() == ItemEvent.SELECTED;
            if (selected) {
                if (viewSupport != null) {
                    viewSupport.deactivate();
                }
                if (layoutSupport != null) {
                    layoutSupport.deactivate();
                }
            }
            center.setEnabled(!selected);
            horizontalSlider.setEnabled(!selected);
            verticalSlider.setEnabled(!selected);
        }
    });

    final JRadioButton perspectiveView = new JRadioButton("In View");
    perspectiveView.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    final JRadioButton perspectiveModel = new JRadioButton("In Layout");
    perspectiveModel.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            layoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    radio.add(normal);
    radio.add(perspectiveModel);
    radio.add(perspectiveView);
    normal.setSelected(true);

    ButtonGroup graphRadio = new ButtonGroup();
    JRadioButton graphButton = new JRadioButton("Graph");
    graphButton.setSelected(true);
    graphButton.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                visualizationModel.setGraphLayout(graphLayout);
                vv.repaint();
            }
        }
    });
    JRadioButton gridButton = new JRadioButton("Grid");
    gridButton.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                visualizationModel.setGraphLayout(gridLayout);
                vv.repaint();
            }
        }
    });
    graphRadio.add(graphButton);
    graphRadio.add(gridButton);

    JPanel modePanel = new JPanel(new GridLayout(2, 1));
    modePanel.setBorder(BorderFactory.createTitledBorder("Display"));
    modePanel.add(graphButton);
    modePanel.add(gridButton);

    JMenuBar menubar = new JMenuBar();
    menubar.add(graphMouse.getModeMenu());
    gzsp.setCorner(menubar);

    Container controls = new JPanel(new BorderLayout());
    JPanel zoomControls = new JPanel(new GridLayout(2, 1));
    zoomControls.setBorder(BorderFactory.createTitledBorder("Zoom"));
    JPanel perspectiveControls = new JPanel(new GridLayout(3, 1));
    zoomControls.add(plus);
    zoomControls.add(minus);
    perspectiveControls.add(normal);
    perspectiveControls.add(perspectiveModel);
    perspectiveControls.add(perspectiveView);

    controls.add(zoomControls, BorderLayout.WEST);
    controls.add(modePanel);
    perspectivePanel.add(perspectiveControls, BorderLayout.WEST);
    perspectiveCenterPanel.add(horizontalSlider, BorderLayout.SOUTH);
    perspectivePanel.add(verticalSlider, BorderLayout.EAST);
    perspectiveCenterPanel.add(center);
    perspectivePanel.add(perspectiveCenterPanel);
    controls.add(perspectivePanel, BorderLayout.EAST);

    content.add(controls, BorderLayout.SOUTH);
}

From source file:es.emergya.ui.gis.popups.ConsultaHistoricos.java

private JButton getConsultar() {
    final JButton jButton = new JButton(LogicConstants.getIcon("historico_button_realizarconsulta"));
    jButton.setText("Consultar");
    jButton.setEnabled(false);
    jButton.addActionListener(new ActionListener() {

        @Override//from ww  w.  j  a  v  a2  s .c om
        public void actionPerformed(ActionEvent e) {
            cargando.setIcon(LogicConstants.getIcon("anim_calculando"));
            cargando.repaint();
            limpiar.setEnabled(false);
            jButton.setEnabled(false);
            consulta = new SwingWorker<Layer, Object>() {

                @Override
                protected Layer doInBackground() throws Exception {

                    publish(new Object[0]);

                    List<String> idRecursos = new ArrayList<String>();
                    List<Long> idZonas = new ArrayList<Long>();
                    for (Object o : recursos.getSelectedValues()) {
                        if (o instanceof Recurso) {
                            idRecursos.add(((Recurso) o).getIdentificador());
                        } else {
                            idRecursos.add(o.toString());
                        }
                    }
                    // for (Object o : zona.getSelectedValues()) {
                    // if (o instanceof Zona) {
                    // idZonas.add(((Zona) o).getId());
                    // }
                    // }

                    List<String> idIncidencias = new ArrayList<String>();
                    for (Object o : incidencias.getSelectedValues()) {
                        if (o instanceof Incidencia) {
                            idIncidencias.add(((Incidencia) o).getId().toString());
                        } else {
                            idIncidencias.add(o.toString());
                        }
                    }
                    if (soloUltimas.isSelected()) {
                        if (idRecursos.size() > 0) {
                            getUltimasPosiciones(Authentication.getUsuario().getNombreUsuario(), idRecursos,
                                    idZonas);
                        }
                        if (idIncidencias.size() > 0) {
                            getPosicionesIncidencias(Authentication.getUsuario().getNombreUsuario(),
                                    idIncidencias, idZonas);
                        }
                    } else {
                        if (idRecursos.size() > 0) {
                            getRutas(Authentication.getUsuario().getNombreUsuario(), idRecursos, getFechaIni(),
                                    getFechaFin());
                        }
                        if (idIncidencias.size() > 0) {
                            getPosicionesIncidencias(Authentication.getUsuario().getNombreUsuario(),
                                    idIncidencias, idZonas);
                        }
                    }
                    return null;
                }

                @Override
                protected void process(List<Object> chunks) {
                    super.process(chunks);
                    cleanLayers();
                    cargando.setIcon(LogicConstants.getIcon("anim_calculando"));
                    cargando.repaint();
                }

                @Override
                protected void done() {
                    HistoryMapViewer.getResultadoHistoricos().setSelected(true);
                    cargando.setIcon(LogicConstants.getIcon("48x48_transparente"));
                    cargando.repaint();
                }
            };
            consulta.execute();
        }
    });
    return jButton;
}

From source file:com.willwinder.ugs.nbp.setupwizard.panels.WizardPanelStepCalibration.java

private KeyListener createKeyListenerChangeSetting(Axis axis, JButton buttonUpdateSettings) {
    return new KeyListener() {
        @Override//from w  w  w  .j  a  va2 s  .c  o m
        public void keyTyped(KeyEvent event) {

        }

        @Override
        public void keyPressed(KeyEvent event) {

        }

        @Override
        public void keyReleased(KeyEvent event) {
            if (getBackend().getController() != null
                    && getBackend().getController().getFirmwareSettings() != null) {
                try {
                    JTextField source = (JTextField) event.getSource();
                    IFirmwareSettings firmwareSettings = getBackend().getController().getFirmwareSettings();

                    int stepsPerMillimeter = firmwareSettings.getStepsPerMillimeter(axis);
                    if (!StringUtils.isNumeric(source.getText())
                            || source.getText().trim().equalsIgnoreCase(String.valueOf(stepsPerMillimeter))) {
                        buttonUpdateSettings.setEnabled(false);
                    } else if (StringUtils.isNumeric(source.getText())) {
                        buttonUpdateSettings.setEnabled(true);
                    }
                } catch (FirmwareSettingsException e) {
                    e.printStackTrace();
                }
            }
        }
    };
}

From source file:edu.ku.brc.specify.plugins.latlon.LatLonUI.java

/**
 * Creates the UI.//  ww w. ja v a2s .c o m
 * @param localityCEP the locality object (can be null)
 */
protected void createEditUI() {
    loadAndPushResourceBundle("specify_plugins");

    PanelBuilder builder = new PanelBuilder(new FormLayout("p", "p, 2px, p"), this);

    Color bgColor = getBackground();
    bgColor = new Color(Math.min(bgColor.getRed() + 20, 255), Math.min(bgColor.getGreen() + 20, 255),
            Math.min(bgColor.getBlue() + 20, 255));
    //System.out.println(bgColor);
    setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(bgColor),
            BorderFactory.createEmptyBorder(4, 4, 4, 4)));

    for (int i = 0; i < types.length; i++) {
        typeMapper.put(types[i], typeStrs[i]);
    }

    currentType = LatLonUIIFace.LatLonType.LLPoint;

    pointImages = new ImageIcon[pointNames.length];
    for (int i = 0; i < pointNames.length; i++) {
        pointImages[i] = IconManager.getIcon(pointNames[i], IconManager.IconSize.Std16);
    }

    String[] formatLabels = new String[formats.length];
    for (int i = 0; i < formats.length; i++) {
        formatLabels[i] = getResourceString(formats[i]);
    }
    cardPanel = new JPanel(cardLayout);
    formatSelector = createComboBox(formatLabels);
    latLonPanes = new JComponent[formatLabels.length];

    formatSelector.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            swapForm(formatSelector.getSelectedIndex(), currentType);

            cardLayout.show(cardPanel, ((JComboBox) ae.getSource()).getSelectedItem().toString());

            //stateChanged(null);
        }
    });

    Dimension preferredSize = new Dimension(0, 0);
    cardSubPanes = new JPanel[formats.length * 2];
    panels = new DDDDPanel[formats.length * 2];
    int paneInx = 0;
    for (int i = 0; i < formats.length; i++) {
        cardSubPanes[i] = new JPanel(new BorderLayout());
        try {
            String packageName = "edu.ku.brc.specify.plugins.latlon.";
            DDDDPanel latLon1 = Class.forName(packageName + formatClass[i]).asSubclass(DDDDPanel.class)
                    .newInstance();
            latLon1.setIsRequired(isRequired);
            latLon1.setViewMode(isViewMode);
            latLon1.init();
            latLon1.setChangeListener(this);

            JPanel panel1 = latLon1;
            panel1.setBorder(panelBorder);
            panels[paneInx++] = latLon1;
            latLonPanes[i] = panel1;

            DDDDPanel latlon2 = Class.forName(packageName + formatClass[i]).asSubclass(DDDDPanel.class)
                    .newInstance();
            latlon2.setIsRequired(isRequired);
            latlon2.setViewMode(isViewMode);
            latlon2.init();
            latlon2.setChangeListener(this);

            panels[paneInx++] = latlon2;

            JTabbedPane tabbedPane = new JTabbedPane(
                    UIHelper.getOSType() == UIHelper.OSTYPE.MacOSX ? SwingConstants.BOTTOM
                            : SwingConstants.RIGHT);
            tabbedPane.addTab(null, pointImages[0], panels[paneInx - 2]);
            tabbedPane.addTab(null, pointImages[0], panels[paneInx - 1]);
            latLonPanes[i] = tabbedPane;

            Dimension size = tabbedPane.getPreferredSize();
            preferredSize.width = Math.max(preferredSize.width, size.width);
            preferredSize.height = Math.max(preferredSize.height, size.height);

            tabbedPane.removeAll();
            cardSubPanes[i].add(panel1, BorderLayout.CENTER);
            cardPanel.add(formatLabels[i], cardSubPanes[i]);

            /*if (locality != null)
            {
            latLon1.set(locality.getLatitude1(), locality.getLongitude1(), locality.getLat1text(), locality.getLong1text());
            latlon2.set(locality.getLatitude2(), locality.getLongitude2(), locality.getLat2text(), locality.getLong2text());
            }*/

        } catch (Exception e) {
            e.printStackTrace();
            edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(LatLonUI.class, e);
        }
    }

    // Makes they are all the same size
    for (int i = 0; i < formats.length; i++) {
        cardSubPanes[i].setPreferredSize(preferredSize);
    }

    //final LatLonPanel thisPanel = this;

    PanelBuilder botBtnBar = new PanelBuilder(new FormLayout("p:g,p,10px,p,10px,p,p:g", "p"));

    ButtonGroup btnGroup = new ButtonGroup();
    botBtns = new JToggleButton[typeNames.length];

    if (UIHelper.isMacOS()) {
        /*for (int i=0;i<botBtns.length;i++)
        {
        ImageIcon selIcon   = IconManager.getIcon(typeNames[i]+"Sel", IconManager.IconSize.Std16);
        ImageIcon unselIcon = IconManager.getIcon(typeNames[i], IconManager.IconSize.Std16);
                
        MacIconRadioButton rb = new MacIconRadioButton(selIcon, unselIcon);
        botBtns[i] = rb;
        rb.setBorder(new MacBtnBorder());
                
        Dimension size = rb.getPreferredSize();
        int max = Math.max(size.width, size.height);
        size.setSize(max, max);
        rb.setPreferredSize(size);
        }*/

        BorderedRadioButton.setSelectedBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
        BorderedRadioButton.setUnselectedBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
        for (int i = 0; i < botBtns.length; i++) {
            BorderedRadioButton rb = new BorderedRadioButton(
                    IconManager.getIcon(typeNames[i], IconManager.IconSize.Std16));
            botBtns[i] = rb;
            rb.makeSquare();
            rb.setBorder(new MacBtnBorder());
        }
    } else {
        BorderedRadioButton.setSelectedBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
        BorderedRadioButton.setUnselectedBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
        for (int i = 0; i < botBtns.length; i++) {
            BorderedRadioButton rb = new BorderedRadioButton(
                    IconManager.getIcon(typeNames[i], IconManager.IconSize.Std16));
            botBtns[i] = rb;
            rb.makeSquare();
        }
    }

    for (int i = 0; i < botBtns.length; i++) {
        botBtns[i].setToolTipText(typeToolTips[i]);
        botBtnBar.add(botBtns[i], cc.xy((i * 2) + 2, 1));
        btnGroup.add(botBtns[i]);
        selectedTypeHash.put(botBtns[i], types[i]);

        botBtns[i].addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ce) {
                stateChanged(null);
                currentType = selectedTypeHash.get(ce.getSource());
                swapForm(formatSelector.getSelectedIndex(), currentType);
            }
        });
    }
    botBtns[0].setSelected(true);

    if (isViewMode) {
        typeLabel = createLabel(" ");
    }

    ActionListener infoAL = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doPrefs();
        }
    };

    JButton infoBtn = UIHelper.createIconBtn("Preferences", IconManager.IconSize.Std16,
            getResourceString("PREFERENCES"), true, infoAL);
    infoBtn.setEnabled(true);

    PanelBuilder topPane = new PanelBuilder(
            new FormLayout("l:p, c:p:g" + (isViewMode ? "" : ",4px,p,8px"), "p"));
    topPane.add(formatSelector, cc.xy(1, 1));
    topPane.add(isViewMode ? typeLabel : botBtnBar.getPanel(), cc.xy(2, 1));
    if (!isViewMode)
        topPane.add(infoBtn, cc.xy(4, 1));

    builder.add(topPane.getPanel(), cc.xy(1, 1));
    builder.add(cardPanel, cc.xy(1, 3));

    prefsPanel = new PrefsPanel(false);
    prefsPanel.add(getResourceString("LatLonUI.LL_SEP"));
    prefsPanel.add(CompType.eCheckbox, getResourceString("LatLonUI.LATDEF_DIR"), LAT_PREF, Boolean.class, true);
    prefsPanel.add(CompType.eCheckbox, getResourceString("LatLonUI.LONDEF_DIR"), LON_PREF, Boolean.class, true);
    prefsPanel.add(CompType.eComboBox, getResourceString("LatLonUI.DEF_TYP"), TYP_PREF, Integer.class,
            typeNamesLabels, 0);
    prefsPanel.add(CompType.eComboBox, getResourceString("LatLonUI.DEF_FMT"), FMT_PREF, Integer.class,
            formatLabels, 0);
    prefsPanel.createForm(null, null);

    popResourceBundle();
}

From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java

/**
 * Invokes the Cluster Shutdown Operation
 *///w  w w  . java  2 s .  co m
protected void doShutdownCluster() {

    // Consider different messages when there are active jobs
    String message = "Are you sure to shutdown the cluster ?";

    int response = JOptionPane.showConfirmDialog(this, message, "Shutdown Cluster", JOptionPane.YES_NO_OPTION);

    // User chose 'No'
    if (response == JOptionPane.NO_OPTION)
        return;
    JButton shutdownButton = getUIElement("general.shutdown");
    shutdownButton.setEnabled(false);

    showBusyIcon();

    // Shutdown
    onShutdown();
}

From source file:com.smanempat.controller.ControllerClassification.java

public void chooseFile(ActionEvent evt, JTextField txtFileDirectory, JTextField txtNumberOfK,
        JLabel labelJumlahData, JButton buttonProses, JTable tablePreview) {
    try {//from ww w .  j av a 2 s.co  m
        JFileChooser fileChooser = new JFileChooser();
        FileNameExtensionFilter fileNameExtensionFilter = new FileNameExtensionFilter("Excel File", "xls",
                "xlsx");
        fileChooser.setFileFilter(fileNameExtensionFilter);

        if (fileChooser.showOpenDialog(fileChooser) == JFileChooser.APPROVE_OPTION) {
            txtFileDirectory.setText(fileChooser.getSelectedFile().getAbsolutePath());
            System.out.println("Good, File Chooser runing well!");
            if (txtFileDirectory.getText().endsWith(".xls") || txtFileDirectory.getText().endsWith(".xlsx")) {
                showOnTable(evt, txtFileDirectory, tablePreview);
                labelJumlahData.setText(tablePreview.getRowCount() + " Data");
                txtNumberOfK.setEnabled(true);
                txtNumberOfK.requestFocus();
                buttonProses.setEnabled(true);
            } else {
                JOptionPane.showMessageDialog(null,
                        "File dataset harus file spreadsheet dengan ekstensi *xls atau *.xlsx!", "Error",
                        JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/com/smanempat/image/fail.png"));
                txtFileDirectory.setText("");
                chooseFile(evt, txtFileDirectory, txtNumberOfK, labelJumlahData, buttonProses, tablePreview);
            }

        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:edu.ku.brc.af.ui.forms.formatters.UIFormatterEditorDlg.java

/**
 * @param type//ww w. j  a  v a 2 s.c om
 * @return
 */
private JButton createClose(final int type) {
    JButton btn = UIHelper.createIconBtn("Close", "", new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            checkForChanges();
            cardLayout.show(cardPanel, "none");
            resetUI();
        }
    });
    btn.setRolloverEnabled(true);
    btn.setRolloverIcon(IconManager.getIcon("CloseHover"));
    btn.setEnabled(true);
    return btn;
}