Example usage for javax.swing WindowConstants DO_NOTHING_ON_CLOSE

List of usage examples for javax.swing WindowConstants DO_NOTHING_ON_CLOSE

Introduction

In this page you can find the example usage for javax.swing WindowConstants DO_NOTHING_ON_CLOSE.

Prototype

int DO_NOTHING_ON_CLOSE

To view the source code for javax.swing WindowConstants DO_NOTHING_ON_CLOSE.

Click Source Link

Document

The do-nothing default window close operation.

Usage

From source file:ch.fork.AdHocRailway.ui.AdHocRailway.java

private void initGUI() {

    setFont(new Font("Verdana", Font.PLAIN, 19));
    setLayout(new BorderLayout(0, 0));
    initMenu();// w  w  w . j a  v  a  2s  .c om
    initToolbar();
    statusBarPanel = initStatusBar();
    mainPanel = new JPanel();

    mainPanel = new JPanel(new MigLayout("", "[][grow]", "[grow][]"));

    final JPanel segmentPanel = new KeyControl(appContext);

    trackControlPanel = new TrackControlPanel(appContext);
    locomotiveControlPanel = new LocomotiveControlPanel(appContext);
    powerControlPanel = new PowerControlPanel(appContext);

    mainPanel.add(segmentPanel, "grow");
    mainPanel.add(trackControlPanel, "grow, wrap");
    mainPanel.add(powerControlPanel, "grow");
    mainPanel.add(locomotiveControlPanel, "shrink 0, wrap");

    add(mainPanel, BorderLayout.CENTER);
    add(statusBarPanel, BorderLayout.PAGE_END);

    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(final WindowEvent e) {
            new ExitAction().actionPerformed(null);
        }
    });
    setRailwayDeviceLabelText();

    initShortcuts();
    appContext.getMainBus().register(this);
    appContext.getMainBus().post(new EditingModeEvent(appContext.isEditingMode()));
}

From source file:net.openbyte.gui.CreateProjectFrame.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Gary Lee
    button1 = new JButton();
    textField1 = new JTextField();
    label1 = new JLabel();
    comboBox1 = new JComboBox<>();
    label2 = new JLabel();
    comboBox2 = new JComboBox<>();
    label3 = new JLabel();
    button2 = new JButton();

    //======== this ========
    setTitle("Project Creation");
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    setResizable(false);/*  ww  w  .j  a  v  a 2s .  co  m*/
    Container contentPane = getContentPane();
    contentPane.setLayout(null);

    //---- button1 ----
    button1.setText("Create project");
    button1.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button1ActionPerformed(e);
        }
    });
    contentPane.add(button1);
    button1.setBounds(new Rectangle(new Point(340, 170), button1.getPreferredSize()));
    contentPane.add(textField1);
    textField1.setBounds(10, 25, 245, textField1.getPreferredSize().height);

    //---- label1 ----
    label1.setText("Project Name");
    contentPane.add(label1);
    label1.setBounds(new Rectangle(new Point(10, 5), label1.getPreferredSize()));

    //---- comboBox1 ----
    comboBox1.setModel(new DefaultComboBoxModel<>(new String[] { "Minecraft Forge", "MCP", "Bukkit" }));
    comboBox1.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            comboBox1ItemStateChanged(e);
        }
    });
    contentPane.add(comboBox1);
    comboBox1.setBounds(10, 70, 245, comboBox1.getPreferredSize().height);

    //---- label2 ----
    label2.setText("Modification API");
    contentPane.add(label2);
    label2.setBounds(new Rectangle(new Point(10, 50), label2.getPreferredSize()));

    //---- comboBox2 ----
    comboBox2.setModel(new DefaultComboBoxModel<>(new String[] { "1.8.9", "1.7.10" }));
    contentPane.add(comboBox2);
    comboBox2.setBounds(10, 120, 245, comboBox2.getPreferredSize().height);

    //---- label3 ----
    label3.setText("Minecraft Version");
    contentPane.add(label3);
    label3.setBounds(new Rectangle(new Point(10, 100), label3.getPreferredSize()));

    //---- button2 ----
    button2.setText("Cancel");
    button2.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button2ActionPerformed(e);
        }
    });
    contentPane.add(button2);
    button2.setBounds(new Rectangle(new Point(10, 170), button2.getPreferredSize()));

    { // compute preferred size
        Dimension preferredSize = new Dimension();
        for (int i = 0; i < contentPane.getComponentCount(); i++) {
            Rectangle bounds = contentPane.getComponent(i).getBounds();
            preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
            preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
        }
        Insets insets = contentPane.getInsets();
        preferredSize.width += insets.right;
        preferredSize.height += insets.bottom;
        contentPane.setMinimumSize(preferredSize);
        contentPane.setPreferredSize(preferredSize);
    }
    setSize(480, 240);
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:cl.almejo.vsim.gui.SimWindow.java

public SimWindow(Circuit circuit) {
    _circuit = circuit;//from ww  w.  j  a v a 2 s . c om
    _circuit.addCircuitEventListener(this);
    _canvas = new CircuitCanvas(_circuit);

    setBounds(100, 100, 800, 800);

    _displaysPane = new JTabbedPane();

    CanvasScrollPane scrollPane = new CanvasScrollPane(_canvas);
    CenterCanvasButton panel = new CenterCanvasButton();
    panel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            SimWindow.this.getCanvas().center();
        }
    });
    scrollPane.addCorner(panel);

    JSplitPane rightSplitpane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scrollPane, _displaysPane);
    rightSplitpane.setOneTouchExpandable(true);
    rightSplitpane.setDividerLocation(600);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
            new JSplitPane(JSplitPane.VERTICAL_SPLIT, getToolsPane(), new JPanel()), rightSplitpane);

    getContentPane().add(splitPane, BorderLayout.CENTER);

    JPanel statusBar = getStatusBar();
    statusBar.add(new ZoomChanger(_canvas));
    getContentPane().add(statusBar, BorderLayout.SOUTH);

    setVisible(true);

    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addComponentListener(this);
    addWindowListener(this);
    _canvas.addMouseListener(this);
    _canvas.setZoom(1.0);
    _canvas.addMouseMotionListener(this);
    _canvas.resizeViewport();

    addMenu();
    addMainToolbar();
    updateActionStates();
    updateTitle();
}

From source file:com.net2plan.gui.GUINet2Plan.java

private void start() {
    setExtendedState(JFrame.MAXIMIZED_BOTH);
    setMinimumSize(new Dimension(800, 600));

    itemObject = new DualHashBidiMap<JMenuItem, Object>();

    URL iconURL = GUINet2Plan.class.getResource("/resources/gui/icon.png");
    ImageIcon icon = new ImageIcon(iconURL);
    setIconImage(icon.getImage());/*w  ww .ja va  2s. c o m*/
    setTitle("Net2Plan");
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(CLOSE_NET2PLAN);

    getContentPane().setLayout(new MigLayout("insets 0 0 0 0", "[grow]", "[grow]"));
    container = new JPanel(new MigLayout("", "[]", "[]"));
    container.setBorder(new LineBorder(Color.BLACK));
    container.setLayout(new MigLayout("fill"));
    getContentPane().add(container, "grow");

    /* Create menu bar */
    menu = new JMenuBar();
    setJMenuBar(menu);

    /* File menu */
    JMenu file = new JMenu("File");
    file.setMnemonic('F');
    menu.add(file);

    optionsItem = new JMenuItem("Options");
    optionsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.ALT_DOWN_MASK));
    optionsItem.addActionListener(this);
    file.add(optionsItem);

    classPathEditorItem = new JMenuItem("Classpath editor");
    classPathEditorItem.addActionListener(this);
    file.add(classPathEditorItem);

    errorConsoleItem = new JMenuItem("Show Java console");
    errorConsoleItem.addActionListener(this);
    errorConsoleItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F12, InputEvent.ALT_DOWN_MASK));
    file.add(errorConsoleItem);

    exitItem = new JMenuItem("Exit");
    exitItem.addActionListener(this);
    exitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_DOWN_MASK));
    file.add(exitItem);

    /* Help menu */
    JMenu help = new JMenu("Help");
    help.setMnemonic('H');
    menu.add(help);

    aboutItem = new JMenuItem("About");
    aboutItem.addActionListener(this);
    help.add(aboutItem);
    itemObject.put(aboutItem, showAbout());

    helpItem = new JMenuItem("User's guide");
    helpItem.addActionListener(this);
    helpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, KeyEvent.VK_UNDEFINED));
    help.add(helpItem);

    javadocItem = new JMenuItem("Library API Javadoc");
    javadocItem.addActionListener(this);
    help.add(javadocItem);

    javadocExamplesItem = new JMenuItem("Built-in Examples Javadoc");
    javadocExamplesItem.addActionListener(this);
    help.add(javadocExamplesItem);

    keyCombinationItem = new JMenuItem("Show tool key combinations");
    keyCombinationItem.addActionListener(this);
    keyCombinationItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_K, KeyEvent.ALT_DOWN_MASK));
    help.add(keyCombinationItem);

    usedKeyStrokes = new LinkedHashSet<KeyStroke>();
    refreshMenu();

    container.add(showAbout(), "align center");
    container.revalidate();

    new JFileChooser(); /* Do not remove! It is used to avoid slow JFileChooser first-time loading once Net2Plan is shown to the user */

    setVisible(true);
}

From source file:edu.ku.brc.specify.dbsupport.cleanuptools.GeoChooserDlg.java

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override/*w  w  w.  j a  va 2s. c o m*/
public void createUI() {
    boolean doStatesOrCounties = doAllCountries[1] || doAllCountries[2] || doInvCountry[1] || doInvCountry[2];
    //this.whichBtns = doStatesOrCounties && !doInvCountry[1] && rankId > 200 ? CustomDialog.OKCANCELAPPLYHELP : CustomDialog.OKCANCELHELP;

    boolean isStCnty = true;//rankId > 200; 

    dataListModel = new DefaultListModel<GeoSearchResultsItem>();
    mainList = new JList<GeoSearchResultsItem>(dataListModel);
    JScrollPane sb = createScrollPane(mainList, true);

    String listDim;
    if (UIHelper.isWindows()) {
        listDim = "250px";
        Dimension sz = new Dimension(250, 250);
        mainList.setPreferredSize(sz);
        sb.setPreferredSize(sz);
    } else {
        listDim = "f:p:g";
    }

    CellConstraints cc = new CellConstraints();
    PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g",
            "p,2px,p,12px,p,2px," + listDim + ",8px,p,4px,p,10px,p" + (isStCnty ? ",8px,p" : "")));

    this.contentPanel = pb.getPanel();

    super.createUI();

    okBtn.setEnabled(false);

    calcProgress();

    try {
        if (coInfoList != null && coInfoList.size() > 0) {
            fillFromLuceneResults();
        } else {
            fillFromQuery();
        }

        mainList.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    getOkBtn().doClick();

                } else if (e.getClickCount() == 1 && !noMatchesFound && !mainList.isSelectionEmpty()) {
                    getOkBtn().setEnabled(true);
                }
            }
        });
        mainList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    listItemSelected();
                }
            }
        });

        updateNameCB = createCheckBox("Update the Name in the Geography tree."); // I18N
        //mergeCB      = createCheckBox("Merge all the geographies with the same name.");
        addISOCodeCB = createCheckBox("Add the ISO Code to the record");
        isoCodeTF = createTextField(8);
        isoCodeTF.setVisible(rankId < 400);

        updateNameCB.setSelected(isUpdateNamesChecked);
        //mergeCB.setSelected(true);
        addISOCodeCB.setSelected(true);

        updateNameCB.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(final ChangeEvent e) {
                isUpdateNamesChecked = updateNameCB.isSelected();
            }
        });

        DocumentListener dl = new DocumentAdaptor() {
            @Override
            protected void changed(DocumentEvent e) {
                okBtn.setEnabled(!isoCodeTF.getText().isEmpty());
            }
        };
        isoCodeTF.getDocument().addDocumentListener(dl);
        //labels.add(nameStr);// + "  (Unknown)");

        PanelBuilder lookPB = null;
        JButton lookupBtn = null;
        if (isStCnty) {
            lookPB = new PanelBuilder(new FormLayout("f:p:g,p", "p"));
            lookupBtn = createI18NButton("CLNUP_GEO_LOOK_UP_ISO");
            lookPB.add(lookupBtn, cc.xy(2, 1));
            lookupBtn.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    globalRankSearch();
                }
            });
        }

        int i = 0;
        ArrayList<String> labels = new ArrayList<String>();
        while (i < parentNames.length && parentRanks[i] > -1) {
            labels.add(i18NLabelsMap.get(parentRanks[i++]));
        }

        PanelBuilder pbTop = new PanelBuilder(
                new FormLayout("p,2px,f:p:g", UIHelper.createDuplicateJGoodiesDef("p", "2px", labels.size())));
        int y = 1;
        for (i = 0; i < labels.size(); i++) {
            JLabel lbl = createLabel(parentNames[i]);
            pbTop.add(createFormLabel(labels.get(i)), cc.xy(1, y));
            pbTop.add(lbl, cc.xy(3, y));
            lbl.setBackground(Color.WHITE);
            lbl.setOpaque(true);
            y += 2;
        }

        pb.add(pbTop.getPanel(), cc.xy(1, 3));
        pb.addSeparator("Possible standard Geography choices", cc.xy(1, 5)); // I18N
        pb.add(sb, cc.xy(1, 7));
        pb.add(updateNameCB, cc.xy(1, 9));

        PanelBuilder pbc = new PanelBuilder(new FormLayout("p,10px,p,f:p:g", "p"));
        pbc.add(addISOCodeCB, cc.xy(1, 1));
        pbc.add(isoCodeTF, cc.xy(3, 1));

        pb.add(pbc.getPanel(), cc.xy(1, 11));

        i = 13;
        if (isStCnty) {
            pb.add(lookPB.getPanel(), cc.xy(1, i));
            i += 2;
        }

        //if (doAllCountries[0])
        if (false) // hidding it for now
        {
            progressBar = new JProgressBar(0, 100);
            progressBar.setStringPainted(true);
            PanelBuilder prgPB = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p"));
            prgPB.add(createFormLabel("Progress"), cc.xy(1, 1));
            prgPB.add(progressBar, cc.xy(3, 1));
            pb.add(prgPB.getPanel(), cc.xy(1, i));
            i += 2;
        }

        mainList.setSelectedIndex(selectedIndex);
        mainList.ensureIndexIsVisible(selectedIndex);

        noMatchesFound = dataListModel.size() == 0;

        // Optional Depending on States / Countries
        if (doStatesOrCounties) {
            if (dataListModel.getSize() == 0) {
                dataListModel.addElement(new GeoSearchResultsItem("No matches found."));// I18N
            }
        }

        pb.setDefaultDialogBorder();

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

    if (UIHelper.isWindows()) {
        setResizable(false);
    }
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); // Must be called at the end 'createUI'
}

From source file:analisis_proyecto1.Ventana_principal.java

private void jButton4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton4MouseClicked
    //Generando el arreglo visual de numeros

    this.HeapSort.setVisible(false);
    heap.setTitle("Laurenn Alecxandra Cruz| 11211190");
    heap.setSize(900, 500);/*from   w w w . j a va 2 s.  c o  m*/
    heap.setVisible(true);
    JLabel titulo = new JLabel("Arreglo Inicial: ");
    titulo.setFont(new Font("Consolas", Font.BOLD, 14));
    Panelarreglo.add(titulo);
    this.panelgenera.setForeground(Color.cyan);

    JButton[] arreglo = new JButton[this.heap_sort_numbers.size()];
    for (int i = 0; i < this.heap_sort_numbers.size(); i++) {
        arreglo[i] = new JButton();
        arreglo[i].setText(Integer.toString(this.heap_sort_numbers.get(i)));
        arreglo[i].setBackground(Color.GREEN);
        Panelarreglo.add(arreglo[i]);
    }

    int[] array = new int[this.heap_sort_numbers.size()];

    //convierte ArreyList a arreglo
    for (int i = 0; i < this.heap_sort_numbers.size(); i++) {
        array[i] = this.heap_sort_numbers.get(i);
    }

    //LLamado a la funcion Heapsort
    Heapsort ordenamiento = new Heapsort(array);
    ordenamiento.ordenar();
    this.arboles = ordenamiento.getArbolesDelegate();
    //Visualizacion del arbol

    //---------------------Antes----------------------
    JButton preview = new JButton("Antes");
    preview.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int x = IncrementarIndice(1);

            if (x >= 0) {
                if (vs != null) {
                    PanelArbol.remove(vs);
                }
                //-----------Dibujar arbol---------
                vs = new BasicVisualizationServer<String, String>(
                        new TreeLayout<String, String>(arboles.get(x)), new Dimension(300, 300));
                Transformer<String, Paint> vertexPaint = new Transformer<String, Paint>() {
                    public Paint transform(String i) {
                        return Color.GREEN;
                    }
                };

                RenderContext<String, String> renderContext = vs.getRenderContext();
                renderContext.setVertexFillPaintTransformer(vertexPaint);
                Transformer<String, String> transformer = new ToStringLabeller<String>();
                renderContext.setEdgeLabelTransformer(transformer);
                Transformer<String, String> vertexTransformer = new ToStringLabeller<String>();
                renderContext.setVertexLabelTransformer(vertexTransformer);
                vs.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
                PanelArbol.add(vs);
                PanelArbol.updateUI();

            } else {
                indice = 0;
            }

        }
    });

    //-------------------Despues------------------------
    JButton next = new JButton("Siguiente");
    next.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int x = IncrementarIndice(0);

            if (x < arboles.size()) {
                if (vs != null) {
                    PanelArbol.remove(vs);
                }
                //-----------Dibujar arbol---------
                vs = new BasicVisualizationServer<String, String>(
                        new TreeLayout<String, String>(arboles.get(x)), new Dimension(250, 250));
                Transformer<String, Paint> vertexPaint = new Transformer<String, Paint>() {
                    public Paint transform(String i) {
                        return Color.GREEN;
                    }
                };

                RenderContext<String, String> renderContext = vs.getRenderContext();
                renderContext.setVertexFillPaintTransformer(vertexPaint);
                Transformer<String, String> transformer = new ToStringLabeller<String>();
                renderContext.setEdgeLabelTransformer(transformer);
                Transformer<String, String> vertexTransformer = new ToStringLabeller<String>();
                renderContext.setVertexLabelTransformer(vertexTransformer);
                vs.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
                PanelArbol.add(vs);
                PanelArbol.updateUI();
                heap.repaint();

            } else {
                indice = arboles.size() - 1;
            }

        }
    });

    //---------------Terminar accion--------------------------
    JButton terminar = new JButton("Salir");
    terminar.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            heap_sort_numbers = new ArrayList();
            arboles = new ArrayList();
            indice = -1;
            PanelArbol = new JPanel();
            grid = new GridLayout(2, 0);
            flow = new FlowLayout();
            panelgenera = new JPanel(grid);
            Panelarreglo = new JPanel(flow);

            heap.dispose();
            HeapSort.dispose();
            heap = new JFrame();
            heap.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

        }
    });

    next.setBackground(Color.BLUE);
    preview.setBackground(Color.BLUE);
    terminar.setBackground(Color.BLUE);
    Panelarreglo.add(preview);
    Panelarreglo.add(next);
    Panelarreglo.add(terminar);

    this.panelgenera.add(Panelarreglo);
    this.panelgenera.add(PanelArbol);
    this.heap.add(panelgenera);
    heap.repaint();
    paintComponents(getGraphics());

    this.heap.setVisible(true);

}

From source file:com.mgmtp.perfload.loadprofiles.ui.AppFrame.java

/**
 * Mostly created by Eclipse WindowBuilder
 *///from  www .  jav a 2 s  . com
private void initComponents() {
    setTitle("perfLoad - Load Profile Configurator");
    setSize(1032, 984);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    SwingUtils.setUIFontStyle(Font.PLAIN);
    {
        JMenuBar menuBar = new JMenuBar();
        menuBar.setName("menuBar");
        setJMenuBar(menuBar);
        initMenuBar(menuBar);
    }

    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(new MigLayout("insets 0", "[grow][]", "[25px][400][grow]"));
    {
        JToolBar toolBar = new JToolBar() {
            @Override
            protected JButton createActionComponent(final Action a) {
                JButton button = super.createActionComponent(a);
                button.setFocusable(false);
                button.setHideActionText(false);
                return button;
            }
        };
        toolBar.setName("toolBar");
        contentPane.add(toolBar, "cell 0 0 2 1,growx,aligny top");
        initToolBar(toolBar);
    }
    {
        JScrollPane spTree = new JScrollPane();
        spTree.setBorder(new CompoundBorder(
                new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Load Profile Elements",
                        TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)),
                new EmptyBorder(4, 4, 4, 4)));
        contentPane.add(spTree, "cell 0 1,grow");
        spTree.setName("spTree");
        {
            tree = new JTree();
            tree.addKeyListener(new TreeKeyListener());
            tree.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
            tree.addTreeSelectionListener(new TreeTreeSelectionListener());
            tree.setShowsRootHandles(true);
            tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
            tree.setName("tree");
            spTree.setViewportView(tree);
        }
    }
    {
        JPanel pnlMain = new JPanel();
        contentPane.add(pnlMain, "cell 1 1");
        pnlMain.setName("pnlMain");
        pnlMain.setLayout(new MigLayout("insets 0", "[664!]", "[grow][]"));
        {
            JPanel pnlLoadProfileProperties = new JPanel();
            pnlLoadProfileProperties.setBorder(new TitledBorder(null, "Load Profile Properties",
                    TitledBorder.LEADING, TitledBorder.TOP, null, null));
            pnlLoadProfileProperties.setName("pnlLoadProfileProperties");
            pnlMain.add(pnlLoadProfileProperties, "flowx,cell 0 0,grow");
            pnlLoadProfileProperties
                    .setLayout(new MigLayout("insets 4", "[270,grow]8[]8[200]8[]8[200]", "[][][][grow]"));
            {
                lblName = new JLabel("Name");
                lblName.setDisplayedMnemonic('N');
                lblName.setHorizontalAlignment(SwingConstants.CENTER);
                lblName.setName("lblName");
                pnlLoadProfileProperties.add(lblName, "cell 0 0");
            }
            {
                JSeparator separator = new JSeparator();
                separator.setPreferredSize(new Dimension(0, 200));
                separator.setOrientation(SwingConstants.VERTICAL);
                separator.setName("separator");
                pnlLoadProfileProperties.add(separator, "cell 1 0 1 4, growy");
            }
            {
                JLabel lblClient = new JLabel("Clients");
                lblClient.setName("lblClient");
                pnlLoadProfileProperties.add(lblClient, "cell 2 0");
            }
            {
                JSeparator separator = new JSeparator();
                separator.setPreferredSize(new Dimension(0, 200));
                separator.setOrientation(SwingConstants.VERTICAL);
                separator.setName("separator");
                pnlLoadProfileProperties.add(separator, "cell 3 0 1 4, growy");
            }
            {
                lblTargets = new JLabel("Targets");
                lblTargets.setName("lblTargets");
                pnlLoadProfileProperties.add(lblTargets, "cell 4 0");
            }
            {
                txtName = new JTextField();
                lblName.setLabelFor(txtName);
                txtName.setColumns(10);
                txtName.setName("txtName");
                txtName.getDocument().addDocumentListener(dirtyListener);
                pnlLoadProfileProperties.add(txtName, "cell 0 1,growx");
            }
            {
                JScrollPane spClients = new JScrollPane();
                spClients.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
                spClients.setName("spClients");
                pnlLoadProfileProperties.add(spClients, "cell 2 1 1 3,grow");
                {
                    tblClients = new JCheckListTable();
                    tblClients.setName("tblClients");
                    spClients.setViewportView(tblClients);
                    spClients.setColumnHeaderView(null);
                }
            }
            {
                JScrollPane spTargets = new JScrollPane();
                spTargets.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
                spTargets.setName("spTargets");
                pnlLoadProfileProperties.add(spTargets, "cell 4 1 1 3,grow");
                {
                    tblTargets = new JCheckListTable();
                    tblTargets.setName("tblTargets");
                    spTargets.setViewportView(tblTargets);
                    spTargets.setColumnHeaderView(null);
                }
            }
            {
                lblDescription = new JLabel("Description");
                lblDescription.setDisplayedMnemonic('D');
                lblDescription.setName("lblDescription");
                pnlLoadProfileProperties.add(lblDescription, "cell 0 2");
            }
            {
                JScrollPane spDescription = new JScrollPane();
                spDescription.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
                spDescription.setName("spDescription");
                pnlLoadProfileProperties.add(spDescription, "cell 0 3,height 50:50:,grow");
                {
                    taDescription = new JTextArea();
                    taDescription.setFont(txtName.getFont());
                    lblDescription.setLabelFor(taDescription);
                    taDescription.setRows(3);
                    taDescription.setName("taDescription");
                    taDescription.getDocument().addDocumentListener(dirtyListener);
                    spDescription.setViewportView(taDescription);
                }
            }
        }
        {
            JPanel pnlCurveAssignment = new JPanel();
            pnlCurveAssignment.setBorder(new TitledBorder(null, "Active Load Curve Assignment",
                    TitledBorder.LEADING, TitledBorder.TOP, null, null));
            pnlMain.add(pnlCurveAssignment, "cell 0 1,grow");
            pnlCurveAssignment.setLayout(new MigLayout("insets 4", "[grow]", "[grow][]"));
            {
                pnlCard = new JPanel();
                pnlCard.setName("pnlCard");
                pnlCurveAssignment.add(pnlCard, "cell 0 0,grow");
                cardLayout = new CardLayout(0, 0);
                pnlCard.setLayout(cardLayout);
                {
                    stairsPanel = new StairsPanel();
                    stairsPanel.setName("stairsPanel");
                    pnlCard.add(stairsPanel, "stairs");
                }
                {
                    oneTimePanel = new OneTimePanel();
                    oneTimePanel.setName("oneTimePanel");
                    pnlCard.add(oneTimePanel, "oneTime");
                }
                {
                    markerPanel = new MarkerPanel();
                    markerPanel.setName("markerPanel");
                    pnlCard.add(markerPanel, "marker");
                }
                {
                    JLabel lblNoActiveCurve = new JLabel("no active curve assignment");
                    lblNoActiveCurve.setHorizontalAlignment(SwingConstants.CENTER);
                    pnlCard.add(lblNoActiveCurve, "none");
                    lblNoActiveCurve.setName("lblNoActiveCurve");
                }
            }
            {
                btnOk = new JButtonExt("OK");
                getRootPane().setDefaultButton(btnOk);
                btnOk.setEnabled(false);
                btnOk.addActionListener(new BtnOkActionListener());
                btnOk.setMnemonic(KeyEvent.VK_O);
                btnOk.setName("btnOk");
                pnlCurveAssignment.add(btnOk, "cell 0 1,alignx right");
            }
            {
                btnCancel = new JButtonExt("Cancel");
                btnCancel.setEnabled(false);
                btnCancel.addActionListener(new BtnCancelActionListener());
                btnCancel.setMnemonic(KeyEvent.VK_C);
                btnCancel.setName("btnCancel");
                pnlCurveAssignment.add(btnCancel, "cell 0 1,alignx right");
            }
        }
    }
}

From source file:SwingTest.java

static protected void registerWindowListener(JFrame frame) {
    // disable automatic close support for Swing frame.
    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

    // adds the window listener
    frame.addWindowListener(new WindowAdapter() {
        // handles the system exit window message
        public void windowClosing(WindowEvent e) {
            System.exit(1);//  w  ww  .  j  av a  2s  .  co  m
        }
    });
}

From source file:net.sf.jabref.gui.FindUnlinkedFilesDialog.java

/**
 * This will start the import of all file of all selected nodes in this
 * dialogs tree view. <br>/*from   w  ww .ja va 2  s. c  om*/
 * <br>
 * The import itself will run in a seperate thread, whilst this dialog will
 * be showing a progress bar, until the thread has finished its work. <br>
 * <br>
 * When the import has finished, the {@link #importFinishedHandler(java.util.List)} is
 * invoked.
 */
private void startImport() {

    if (treeModel == null) {
        return;
    }
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

    CheckableTreeNode root = (CheckableTreeNode) treeModel.getRoot();

    final List<File> fileList = getFileListFromNode(root);

    if ((fileList == null) || fileList.isEmpty()) {
        return;
    }

    progressBarImporting.setVisible(true);
    labelImportingInfo.setVisible(true);
    buttonApply.setVisible(false);
    buttonClose.setVisible(false);
    disOrEnableDialog(false);

    labelImportingInfo.setEnabled(true);

    progressBarImporting.setMinimum(0);
    progressBarImporting.setMaximum(fileList.size());
    progressBarImporting.setValue(0);
    progressBarImporting.setString("");

    final EntryType entryType = ((BibtexEntryTypeWrapper) comboBoxEntryTypeSelection.getSelectedItem())
            .getEntryType();

    threadState.set(true);
    JabRefExecutorService.INSTANCE.execute(() -> {
        List<String> errors = new LinkedList<>();
        creatorManager.addEntriesFromFiles(fileList, database, frame.getCurrentBasePanel(), entryType,
                checkBoxWhyIsThereNoGetSelectedStupidSwing, new ChangeListener() {

                    int counter;

                    @Override
                    public void stateChanged(ChangeEvent e) {
                        counter++;
                        progressBarImporting.setValue(counter);
                        progressBarImporting.setString(counter + " of " + progressBarImporting.getMaximum());
                    }
                }, errors);
        importFinishedHandler(errors);
    });
}

From source file:edu.ku.brc.specify.dbsupport.cleanuptools.GeographyAssignISOs.java

/**
 * @return/*from   w w  w .  j a v a  2  s  .c  o  m*/
 */
@SuppressWarnings("rawtypes")
public boolean buildAsyncOrig(final int earthId) {
    String sql = adjustSQL(
            "SELECT COUNT(*) FROM geography WHERE GeographyCode IS NOT NULL AND RankID = 100 AND GeographyTreeDefID = GEOTREEDEFID");
    int numContinentsWithNames = BasicSQLUtils.getCountAsInt(sql);

    continentsCBX = createCheckBox("All Continents"); // I18N

    CellConstraints cc = new CellConstraints();
    PanelBuilder pb1 = new PanelBuilder(new FormLayout("f:p:g", "p,4px,p,4px,p,8px"));
    countriesCBX = createCheckBox("All Countries");
    stateCBX = createCheckBox("All States");
    countiesCBX = createCheckBox("All Counties");
    pb1.add(countriesCBX, cc.xy(1, 1));
    pb1.add(stateCBX, cc.xy(1, 3));
    //pb1.add(countiesCBX,   cc.xy(1, 5));

    allCountriesRB = new JRadioButton("Choose the Geography level to be processed"); //L18N
    singleCountryRB = new JRadioButton("Choose an individual Country");
    btnGroup = new ButtonGroup();
    btnGroup.add(this.allCountriesRB);
    btnGroup.add(this.singleCountryRB);

    if (numContinentsWithNames == 0) {
        continentsCBX.setEnabled(false);
        continentsCBX.setSelected(true);
    }

    countriesCBX.setEnabled(true);
    stateCBX.setEnabled(false);
    countiesCBX.setEnabled(false);

    countryIds.clear();
    sql = "SELECT g.GeographyID, g.Name, g2.Name FROM geography g LEFT JOIN geography g2 ON g.ParentID = g2.GeographyID "
            + "WHERE g.Name IS NOT NULL && LENGTH(g.Name) > 0 AND g.RankID = 200 AND g.GeographyTreeDefID = GEOTREEDEFID ORDER BY g.Name";
    sql = adjustSQL(sql);

    Vector<Object[]> rows = query(sql);
    Object[] titles = new Object[rows.size() + 1];
    int i = 0;
    titles[i++] = "None"; // I18N
    countryIds.add(-1);
    for (Object[] r : rows) {
        countryIds.add((Integer) r[0]);
        String countryStr = (String) r[1];
        String contStr = (String) r[2];
        titles[i++] = countryStr != null ? (countryStr + " (" + contStr + ")") : countryStr;
    }

    PanelBuilder pb2 = new PanelBuilder(new FormLayout("8px,p,2px,f:p:g", "p,4px,p,8px"));
    spCountriesLbl = createFormLabel("Country"); // I18N
    spCountriesCmbx = createComboBox(titles);
    spStatesCBX = createCheckBox("States (Required)"); // I18N
    spCountiesCBX = createCheckBox("Counties"); // I18N

    pb2.add(spCountriesLbl, cc.xy(2, 1));
    pb2.add(spCountriesCmbx, cc.xy(4, 1));
    pb2.add(spStatesCBX, cc.xyw(1, 3, 4));
    //pb2.add(spCountiesCBX,   cc.xyw(1, 5, 4));

    spCountriesCmbx.setSelectedIndex(0);

    spStatesCBX.setSelected(true);
    spStatesCBX.setEnabled(false);
    spCountiesCBX.setEnabled(false);

    String rowDef = createDuplicateJGoodiesDef("p", "4px", 8);
    PanelBuilder pb = new PanelBuilder(new FormLayout("16px,f:p:g", rowDef));

    pb.addSeparator("Continents to be processed", cc.xyw(1, 1, 2));
    pb.add(continentsCBX, cc.xyw(1, 3, 2));

    pb.addSeparator("Countries to be processed", cc.xyw(1, 5, 2));
    pb.add(allCountriesRB, cc.xyw(1, 7, 2));
    pb.add(pb1.getPanel(), cc.xyw(2, 9, 1));

    pb.add(singleCountryRB, cc.xyw(1, 11, 2));
    pb.add(pb2.getPanel(), cc.xyw(2, 13, 1));

    pb.add(createGeoStatsPanel(), cc.xyw(1, 15, 2));

    pb.setDefaultDialogBorder();
    final CustomDialog dlg = new CustomDialog((Frame) getTopWindow(), "ISO Code Processing", true,
            CustomDialog.OKCANCELHELP, pb.getPanel()); // I18N
    dlg.setHelpContext("GeoCleanUpLevelChooser");

    // Setup actions
    ChangeListener rbChangeListener = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            radioSelected(dlg);
        }
    };
    allCountriesRB.addChangeListener(rbChangeListener);
    singleCountryRB.addChangeListener(null);

    countriesCBX.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            boolean isSel = countriesCBX.isSelected();
            stateCBX.setEnabled(isSel);
            countiesCBX.setEnabled(false);
            if (!isSel) {
                stateCBX.setSelected(false);
                countiesCBX.setSelected(false);
            }
            calcGeoStats();
            dlg.getOkBtn().setEnabled(isSel || spCountriesCmbx.getSelectedIndex() > 0);
        }
    });

    stateCBX.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            countiesCBX.setEnabled(stateCBX.isSelected());
            if (!stateCBX.isSelected()) {
                countiesCBX.setSelected(false);
            }
            calcGeoStats();
        }
    });

    // Special
    spCountriesCmbx.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            boolean isSel = spCountriesCmbx.getSelectedIndex() > 0;
            spStatesCBX.setSelected(isSel);
            spCountiesCBX.setEnabled(isSel);
            if (!isSel) {
                spStatesCBX.setSelected(false);
                spCountiesCBX.setSelected(false);
            }
            calcGeoStats();
            dlg.getOkBtn().setEnabled(isSel || countriesCBX.isSelected());

        }
    });

    spStatesCBX.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            spCountiesCBX.setEnabled(stateCBX.isSelected());
            calcGeoStats();
        }
    });

    allCountriesRB.setSelected(true);

    dlg.createUI();
    dlg.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); // Must be called after 'createUI'
    dlg.getOkBtn().setEnabled(false);

    // AUTO Don't show Dialog because it is automatically setting what to do 
    centerAndShow(dlg);

    if (dlg.isCancelled()) {
        return false;
    }

    connectToDB();

    if (true) // AUTO 
    {
        doAllCountries = new boolean[] { countriesCBX.isSelected(), stateCBX.isSelected(),
                countiesCBX.isSelected(), false };
        doInvCountry = new boolean[] { spCountriesCmbx.getSelectedIndex() > 0, spStatesCBX.isSelected(),
                spCountiesCBX.isSelected(), false };
        doIndvCountryId = doInvCountry[0] ? countryIds.get(spCountriesCmbx.getSelectedIndex()) : null;
    } else {
        int indexOfUSA = getUnitedStatesIndex(titles);
        if (indexOfUSA == -1) {
            Vector<Object> nameList = new Vector<Object>();
            Collections.addAll(nameList, titles);
            JList list = createList(nameList);

            JScrollPane sp = createScrollPane(list);
            pb = new PanelBuilder(new FormLayout("f:p:g", "p,8px,f:p:g"));
            pb.add(createLabel("Select the United States"), cc.xy(1, 1));
            pb.add(sp, cc.xy(1, 3));
            pb.setDefaultDialogBorder();
            final CustomDialog askDlg = new CustomDialog((Frame) getTopWindow(), "Choose", true,
                    CustomDialog.OKCANCELHELP, pb.getPanel()); // I18N
            dlg.setHelpContext("GeoCleanUpLevelChooser");
            centerAndShow(askDlg);
            if (!askDlg.isCancelled()) {
                indexOfUSA = list.getSelectedIndex();
            }
        }

        doAllCountries = new boolean[] { true, false, false, false };
        doInvCountry = new boolean[] { indexOfUSA > -1, true, false, false };
        doIndvCountryId = doInvCountry[0] ? countryIds.get(indexOfUSA) : null;
    }

    // Check to see if it needs indexing.
    boolean shouldIndex = luceneSearch.shouldIndex();

    if (shouldIndex) {
        frame = new ProgressFrame("Building Geography Authority..."); // I18N
        frame.getCloseBtn().setVisible(false);
        frame.turnOffOverAll();
        frame.setDesc("Loading Geonames data..."); // I18N
        frame.pack();
        frame.setSize(450, frame.getBounds().height + 10);
        UIHelper.centerAndShow(frame, 450, frame.getBounds().height + 10);

        luceneSearch.startIndexingProcessAsync(earthId, frame, new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                frame.setVisible(false);
                frame = null;
                if (((Boolean) e.getSource())) {
                    GeographyAssignISOs.this.startTraversal();
                }
            }
        });

    } else {
        sql = "SELECT Name, geonameId, iso_alpha2 FROM countryinfo";
        for (Object[] row : query(sql)) {
            countryInfo.add(new GeoSearchResultsItem((String) row[0], (Integer) row[1], (String) row[2]));
        }
        startTraversal();
    }

    return true;
}