Example usage for javax.swing JRadioButton JRadioButton

List of usage examples for javax.swing JRadioButton JRadioButton

Introduction

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

Prototype

public JRadioButton(String text) 

Source Link

Document

Creates an unselected radio button with the specified text.

Usage

From source file:org.accretegb.modules.germplasm.stockannotation.StockAnnotationPanel.java

private JPanel addStockPanelToolButtons() {
    JPanel panel = new JPanel();
    panel.setLayout(new MigLayout("insets 0 0 0 0, gapx 0"));
    List<Integer> editableColumns = new ArrayList<Integer>();
    editableColumns.add(stockTablePanel.getTable().getIndexOf(ColumnConstants.ACCESSION));
    editableColumns.add(stockTablePanel.getTable().getIndexOf(ColumnConstants.PEDIGREE));
    editableColumns.add(stockTablePanel.getTable().getIndexOf(ColumnConstants.GENERATION));
    stockTablePanel.getTable().setEditableColumns(editableColumns);
    ;//from  w w  w.j  av a 2 s  .c o  m
    JButton importStockList = new JButton("Import Stocks By Search");
    JButton importHarvestGroup = new JButton("Import Stocks From Harvest Group");
    JPanel subPanel1 = new JPanel();
    subPanel1.setLayout(new MigLayout("insets 0 0 0 0, gapx 0"));
    subPanel1.add(importStockList, "gapRight 10");
    subPanel1.add(importHarvestGroup, "gapRight 10, wrap");
    panel.add(subPanel1, "gapLeft 10, spanx,wrap");
    importStockList.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            StocksInfoPanel stockInfoPanel = CreateStocksInfoPanel
                    .createStockInfoPanel("stock annotation popup");
            stockInfoPanel.setSize(new Dimension(500, 400));
            int option = JOptionPane.showConfirmDialog(null, stockInfoPanel, "Search Stock Packets",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
            ArrayList<Integer> stockIds = new ArrayList<Integer>();

            if (option == JOptionPane.OK_OPTION) {
                DefaultTableModel model = (DefaultTableModel) stockTablePanel.getTable().getModel();
                CheckBoxIndexColumnTable stocksOutputTable = stockInfoPanel.getSaveTablePanel().getTable();
                for (int row = 0; row < stocksOutputTable.getRowCount(); ++row) {
                    int stockId = (Integer) stocksOutputTable.getValueAt(row,
                            stocksOutputTable.getIndexOf(ColumnConstants.STOCK_ID));
                    stockIds.add(stockId);
                }
                List<Stock> stocks = StockDAO.getInstance().getStocksByIds(stockIds);
                for (Stock stock : stocks) {
                    Object[] rowData = new Object[stockTablePanel.getTable().getColumnCount()];
                    rowData[0] = new Boolean(false);
                    Passport passport = stock.getPassport();
                    StockGeneration generation = stock.getStockGeneration();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.STOCK_NAME)] = stock
                            .getStockName();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.STOCK_ID)] = stock
                            .getStockId();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.GENERATION)] = generation == null ? null
                                    : generation.getGeneration();
                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.PASSPORT_ID)] = passport == null ? null : passport.getPassportId();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.ACCESSION)] = passport == null
                            ? null
                            : passport.getAccession_name();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.PEDIGREE)] = passport == null
                            ? null
                            : passport.getPedigree();
                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.CLASSIFICATION_CODE)] = passport.getClassification() == null ? null
                                    : passport.getClassification().getClassificationCode();
                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.CLASSIFICATION_ID)] = passport.getClassification() == null ? null
                                    : passport.getClassification().getClassificationId();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.POPULATION)] = passport.getTaxonomy() == null ? null
                                    : passport.getTaxonomy().getPopulation();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.TAXONOMY_ID)] = passport.getTaxonomy() == null ? null
                                    : passport.getTaxonomy().getTaxonomyId();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.MODIFIED)] = new Boolean(
                            false);
                    model.addRow(rowData);
                }

            }

        }

    });

    importHarvestGroup.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            ArrayList<PMProject> projects = TokenRelationDAO.getInstance()
                    .findProjectObjects(LoginScreen.loginUserId);
            HashMap<String, Harvesting> name_tap = new HashMap<String, Harvesting>();
            for (PMProject project : projects) {
                List<HarvestingGroup> HarvestingGroups = HarvestingGroupDAO.getInstance()
                        .findByProjectid(project.getProjectId());
                for (HarvestingGroup hg : HarvestingGroups) {
                    Harvesting harvestingPanel = (Harvesting) getContext()
                            .getBean("Harvesting - " + project.getProjectId() + hg.getHarvestingGroupName());
                    name_tap.put(project.getProjectName() + "-" + hg.getHarvestingGroupName(), harvestingPanel);
                }

            }
            JPanel popup = new JPanel(new MigLayout("insets 0, gap 5"));
            JScrollPane jsp = new JScrollPane(popup) {
                @Override
                public Dimension getPreferredSize() {
                    return new Dimension(250, 320);
                }
            };
            ButtonGroup group = new ButtonGroup();
            for (String name : name_tap.keySet()) {
                JRadioButton button = new JRadioButton(name);
                group.add(button);
                popup.add(button, "wrap");

                button.setSelected(true);
            }
            String selected_group = null;
            int option = JOptionPane.showConfirmDialog(null, jsp, "Select Harvesting Group Name: ",
                    JOptionPane.OK_CANCEL_OPTION);
            if (option == JOptionPane.OK_OPTION) {
                for (Enumeration<AbstractButton> buttons = group.getElements(); buttons.hasMoreElements();) {
                    AbstractButton button = buttons.nextElement();
                    if (button.isSelected()) {
                        selected_group = button.getText();

                    }
                }
            }
            if (selected_group != null) {
                Harvesting harvestingPanel = name_tap.get(selected_group);
                DefaultTableModel model = (DefaultTableModel) stockTablePanel.getTable().getModel();
                ArrayList<String> stocknames = harvestingPanel.getStickerGenerator().getCreatedStocks();
                List<Stock> stocks = StockDAO.getInstance().getStocksByNames(stocknames);
                for (Stock stock : stocks) {
                    Object[] rowData = new Object[stockTablePanel.getTable().getColumnCount()];
                    rowData[0] = new Boolean(false);
                    Passport passport = stock.getPassport();
                    StockGeneration generation = stock.getStockGeneration();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.STOCK_NAME)] = stock
                            .getStockName();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.STOCK_ID)] = stock
                            .getStockId();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.GENERATION)] = generation == null ? null
                                    : generation.getGeneration();
                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.PASSPORT_ID)] = passport == null ? null : passport.getPassportId();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.ACCESSION)] = passport == null
                            ? null
                            : passport.getAccession_name();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.PEDIGREE)] = passport == null
                            ? null
                            : passport.getPedigree();

                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.CLASSIFICATION_CODE)] = passport.getClassification() == null ? null
                                    : passport.getClassification().getClassificationCode();
                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.CLASSIFICATION_ID)] = passport.getClassification() == null ? null
                                    : passport.getClassification().getClassificationId();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.POPULATION)] = passport.getTaxonomy() == null ? null
                                    : passport.getTaxonomy().getPopulation();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.TAXONOMY_ID)] = passport.getTaxonomy() == null ? null
                                    : passport.getTaxonomy().getTaxonomyId();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.MODIFIED)] = new Boolean(
                            false);
                    model.addRow(rowData);
                }
            }

        }

    });
    getstockTablePanel().getTable().addFocusListener(new FocusAdapter() {
        public void focusLost(FocusEvent e) {
            int row = getstockTablePanel().getTable().getSelectionModel().getAnchorSelectionIndex();
            getstockTablePanel().getTable().setValueAt(true, row,
                    getstockTablePanel().getTable().getIndexOf(ColumnConstants.MODIFIED));
        }
    });
    JPanel subPanel2 = new JPanel();
    subPanel2.setLayout(new MigLayout("insets 0 0 0 0 , gapx 0"));
    subPanel2.add(new JLabel("Pedigree: "));
    this.pedigreeField = new JTextField(10);
    subPanel2.add(pedigreeField);
    JButton setPedigree = new JButton("set");
    setPedigree.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            for (int row : getstockTablePanel().getTable().getSelectedRows()) {
                getstockTablePanel().getTable().setValueAt(pedigreeField.getText(), row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.PEDIGREE));
                getstockTablePanel().getTable().setValueAt(true, row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.MODIFIED));
            }
        }
    });
    subPanel2.add(setPedigree, "gapRight 15");

    subPanel2.add(new JLabel("Accession: "));
    this.accessionField = new JTextField(10);
    subPanel2.add(accessionField);
    JButton setAccession = new JButton("set");
    setAccession.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            for (int row : getstockTablePanel().getTable().getSelectedRows()) {
                getstockTablePanel().getTable().setValueAt(accessionField.getText(), row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.ACCESSION));
                getstockTablePanel().getTable().setValueAt(true, row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.MODIFIED));

            }
        }
    });
    subPanel2.add(setAccession, "gapRight 15");

    subPanel2.add(new JLabel("Generarion: "));
    this.generarionField = new JTextField(10);
    subPanel2.add(generarionField);
    JButton setGeneration = new JButton("set");
    setGeneration.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            for (int row : getstockTablePanel().getTable().getSelectedRows()) {
                getstockTablePanel().getTable().setValueAt(generarionField.getText(), row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.GENERATION));
                getstockTablePanel().getTable().setValueAt(true, row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.MODIFIED));
            }
        }
    });
    subPanel2.add(setGeneration);

    panel.add(subPanel2, "gapLeft 10,spanx");
    return panel;

}

From source file:org.apache.uima.tools.docanalyzer.DBAnnotationViewerDialog.java

/**
 * Create an AnnotationViewer Dialog//from   w  w  w . j av a 2  s  .  com
 * 
 * @param aParentFrame
 *          frame containing this panel
 * @param aTitle
 *          title to display for the dialog
 * @param aInputDir
 *          directory containing input files (in XCAS foramt) to read
 * @param aStyleMapFile
 *          filename of style map to be used to view files in HTML
 * @param aPerformanceStats
 *          string representaiton of performance statistics, optional.
 * @param aTypeSystem
 *          the CAS Type System to which the XCAS files must conform.
 * @param aTypesToDisplay
 *          array of types that should be highlighted in the viewer. This can be set to the output
 *          types of the Analysis Engine. A value of null means to display all types.
 */
/*public DBAnnotationViewerDialog(JFrame aParentFrame, String aDialogTitle, DBPrefsMediator med,
  File aStyleMapFile, String aPerformanceStats, TypeSystem aTypeSystem,
  final String[] aTypesToDisplay, String interactiveTempFN, boolean javaViewerRBisSelected,
  boolean javaViewerUCRBisSelected, boolean xmlRBisSelected, CAS cas) {
  super(aParentFrame, aDialogTitle);
  // create the AnnotationViewGenerator (for HTML view generation)
  this.med1 = med;
  this.cas = cas;
  annotationViewGenerator = new AnnotationViewGenerator(tempDir);
        
  launchThatViewer(med.getOutputDir(), interactiveTempFN, aTypeSystem, aTypesToDisplay,
    javaViewerRBisSelected, javaViewerUCRBisSelected, xmlRBisSelected, aStyleMapFile,
    tempDir);
}*/

public DBAnnotationViewerDialog(JFrame aParentFrame, String aDialogTitle, DBPrefsMediator med,
        File aStyleMapFile, String aPerformanceStats, TypeSystem aTypeSystem, final String[] aTypesToDisplay,
        boolean generatedStyleMap, CAS cas) {

    super(aParentFrame, aDialogTitle);

    this.xmiDAO = med.getXmiDAO();

    this.med1 = med;
    this.cas = cas;

    styleMapFile = aStyleMapFile;
    final String performanceStats = aPerformanceStats;
    typeSystem = aTypeSystem;
    typesToDisplay = aTypesToDisplay;

    // create the AnnotationViewGenerator (for HTML view generation)
    annotationViewGenerator = new AnnotationViewGenerator(tempDir);

    // create StyleMapEditor dialog
    styleMapEditor = new StyleMapEditor(aParentFrame, cas);
    JPanel resultsTitlePanel = new JPanel();
    resultsTitlePanel.setLayout(new BoxLayout(resultsTitlePanel, BoxLayout.Y_AXIS));

    resultsTitlePanel.add(new JLabel("These are the Analyzed Documents."));
    resultsTitlePanel.add(new JLabel("Select viewer type and double-click file to open."));

    try {

        String[] documents = this.xmiDAO.getXMIList();
        analyzedResultsList = new JList(documents);
    } catch (DAOException e) {

        displayError(e.getMessage());
    }

    /*
     * File[] documents = dir.listFiles(); Vector docVector = new Vector(); for (int i = 0; i <
     * documents.length; i++) { if (documents[i].isFile()) { docVector.add(documents[i].getName()); } }
     * final JList analyzedResultsList = new JList(docVector);
     */
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.getViewport().add(analyzedResultsList, null);

    JPanel southernPanel = new JPanel();
    southernPanel.setLayout(new BoxLayout(southernPanel, BoxLayout.Y_AXIS));

    JPanel controlsPanel = new JPanel();
    controlsPanel.setLayout(new SpringLayout());

    Caption displayFormatLabel = new Caption("Results Display Format:");
    controlsPanel.add(displayFormatLabel);

    JPanel displayFormatPanel = new JPanel();
    displayFormatPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    displayFormatPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    javaViewerRB = new JRadioButton("Java Viewer");
    javaViewerUCRB = new JRadioButton("JV user colors");
    htmlRB = new JRadioButton("HTML");
    xmlRB = new JRadioButton("XML");

    ButtonGroup displayFormatButtonGroup = new ButtonGroup();
    displayFormatButtonGroup.add(javaViewerRB);
    displayFormatButtonGroup.add(javaViewerUCRB);
    displayFormatButtonGroup.add(htmlRB);
    displayFormatButtonGroup.add(xmlRB);

    // select the appropraite viewer button according to user's prefs
    javaViewerRB.setSelected(true); // default, overriden below
    if ("Java Viewer".equals(med.getViewType())) {
        javaViewerRB.setSelected(true);
    } else if ("JV User Colors".equals(med.getViewType())) {
        javaViewerUCRB.setSelected(true);
    } else if ("HTML".equals(med.getViewType())) {
        htmlRB.setSelected(true);
    } else if ("XML".equals(med.getViewType())) {
        xmlRB.setSelected(true);
    }

    displayFormatPanel.add(javaViewerRB);
    displayFormatPanel.add(javaViewerUCRB);
    displayFormatPanel.add(htmlRB);
    displayFormatPanel.add(xmlRB);

    controlsPanel.add(displayFormatPanel);

    SpringUtilities.makeCompactGrid(controlsPanel, 1, 2, // rows, cols
            4, 4, // initX, initY
            0, 0); // xPad, yPad

    JButton editStyleMapButton = new JButton("Edit Style Map");

    // event for the editStyleMapButton button
    editStyleMapButton.addActionListener(this);

    southernPanel.add(controlsPanel);

    // southernPanel.add( new JSeparator() );

    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    // APL: edit style map feature disabled for SDK
    buttonsPanel.add(editStyleMapButton);

    if (performanceStats != null) {
        JButton perfStatsButton = new JButton("Performance Stats");
        perfStatsButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                JOptionPane.showMessageDialog((Component) ae.getSource(), performanceStats, null,
                        JOptionPane.PLAIN_MESSAGE);
            }
        });
        buttonsPanel.add(perfStatsButton);
    }

    JButton closeButton = new JButton("Close");
    buttonsPanel.add(closeButton);

    southernPanel.add(buttonsPanel);

    // add jlist and panel container to Dialog
    getContentPane().add(resultsTitlePanel, BorderLayout.NORTH);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
    getContentPane().add(southernPanel, BorderLayout.SOUTH);

    // event for the closeButton button
    closeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            DBAnnotationViewerDialog.this.setVisible(false);
        }
    });

    // event for analyzedResultsDialog window closing
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setLF(); // set default look and feel
    analyzedResultsList.setCellRenderer(new MyListCellRenderer());

    // doubleclicking on document shows the annotated result
    MouseListener mouseListener = new ListMouseAdapter();
    // styleMapFile, analyzedResultsList,
    // inputDirPath,typeSystem , typesToDisplay ,
    // javaViewerRB , javaViewerUCRB ,xmlRB ,
    // viewerDirectory , this);

    // add mouse Listener to the list
    analyzedResultsList.addMouseListener(mouseListener);
}

From source file:org.barcelonamedia.uima.tools.docanalyzer.DBAnnotationViewerDialog.java

/**
 * Create an AnnotationViewer Dialog// ww w  .j av  a 2 s .  c o m
 * 
 * @param aParentFrame
 *          frame containing this panel
 * @param aTitle
 *          title to display for the dialog
 * @param aInputDir
 *          directory containing input files (in XCAS foramt) to read
 * @param aStyleMapFile
 *          filename of style map to be used to view files in HTML
 * @param aPerformanceStats
 *          string representaiton of performance statistics, optional.
 * @param aTypeSystem
 *          the CAS Type System to which the XCAS files must conform.
 * @param aTypesToDisplay
 *          array of types that should be highlighted in the viewer. This can be set to the output
 *          types of the Analysis Engine. A value of null means to display all types.
 */
/*public DBAnnotationViewerDialog(JFrame aParentFrame, String aDialogTitle, DBPrefsMediator med,
  File aStyleMapFile, String aPerformanceStats, TypeSystem aTypeSystem,
  final String[] aTypesToDisplay, String interactiveTempFN, boolean javaViewerRBisSelected,
  boolean javaViewerUCRBisSelected, boolean xmlRBisSelected, CAS cas) {
  super(aParentFrame, aDialogTitle);
  // create the AnnotationViewGenerator (for HTML view generation)
  this.med1 = med;
  this.cas = cas;
  annotationViewGenerator = new AnnotationViewGenerator(tempDir);
        
  launchThatViewer(med.getOutputDir(), interactiveTempFN, aTypeSystem, aTypesToDisplay,
    javaViewerRBisSelected, javaViewerUCRBisSelected, xmlRBisSelected, aStyleMapFile,
    tempDir);
}*/

public DBAnnotationViewerDialog(JFrame aParentFrame, String aDialogTitle, DBPrefsMediator med,
        File aStyleMapFile, String aPerformanceStats, TypeSystem aTypeSystem, final String[] aTypesToDisplay,
        boolean generatedStyleMap, CAS cas) {

    super(aParentFrame, aDialogTitle);

    this.xmiDAO = med.getXmiDAO();

    this.med1 = med;
    this.cas = cas;

    styleMapFile = aStyleMapFile;
    final String performanceStats = aPerformanceStats;
    typeSystem = aTypeSystem;
    typesToDisplay = aTypesToDisplay;

    // create the AnnotationViewGenerator (for HTML view generation)
    annotationViewGenerator = new AnnotationViewGenerator(tempDir);

    // create StyleMapEditor dialog
    styleMapEditor = new StyleMapEditor(aParentFrame, cas);
    JPanel resultsTitlePanel = new JPanel();
    resultsTitlePanel.setLayout(new BoxLayout(resultsTitlePanel, BoxLayout.Y_AXIS));

    resultsTitlePanel.add(new JLabel("These are the Analyzed Documents."));
    resultsTitlePanel.add(new JLabel("Select viewer type and double-click file to open."));

    try {

        String[] documents = this.xmiDAO.getXMIList();
        analyzedResultsList = new JList(documents);

        JScrollPane scrollPane = new JScrollPane();
        scrollPane.getViewport().add(analyzedResultsList, null);

        JPanel southernPanel = new JPanel();
        southernPanel.setLayout(new BoxLayout(southernPanel, BoxLayout.Y_AXIS));

        JPanel controlsPanel = new JPanel();
        controlsPanel.setLayout(new SpringLayout());

        Caption displayFormatLabel = new Caption("Results Display Format:");
        controlsPanel.add(displayFormatLabel);

        JPanel displayFormatPanel = new JPanel();
        displayFormatPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
        displayFormatPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
        javaViewerRB = new JRadioButton("Java Viewer");
        javaViewerUCRB = new JRadioButton("JV user colors");
        htmlRB = new JRadioButton("HTML");
        xmlRB = new JRadioButton("XML");

        ButtonGroup displayFormatButtonGroup = new ButtonGroup();
        displayFormatButtonGroup.add(javaViewerRB);
        displayFormatButtonGroup.add(javaViewerUCRB);
        displayFormatButtonGroup.add(htmlRB);
        displayFormatButtonGroup.add(xmlRB);

        // select the appropraite viewer button according to user's prefs
        javaViewerRB.setSelected(true); // default, overriden below

        if ("Java Viewer".equals(med.getViewType())) {
            javaViewerRB.setSelected(true);
        } else if ("JV User Colors".equals(med.getViewType())) {
            javaViewerUCRB.setSelected(true);
        } else if ("HTML".equals(med.getViewType())) {
            htmlRB.setSelected(true);
        } else if ("XML".equals(med.getViewType())) {
            xmlRB.setSelected(true);
        }

        displayFormatPanel.add(javaViewerRB);
        displayFormatPanel.add(javaViewerUCRB);
        displayFormatPanel.add(htmlRB);
        displayFormatPanel.add(xmlRB);

        controlsPanel.add(displayFormatPanel);

        SpringUtilities.makeCompactGrid(controlsPanel, 1, 2, // rows, cols
                4, 4, // initX, initY
                0, 0); // xPad, yPad

        JButton editStyleMapButton = new JButton("Edit Style Map");

        // event for the editStyleMapButton button
        editStyleMapButton.addActionListener(this);

        southernPanel.add(controlsPanel);

        // southernPanel.add( new JSeparator() );

        JPanel buttonsPanel = new JPanel();
        buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

        // APL: edit style map feature disabled for SDK
        buttonsPanel.add(editStyleMapButton);

        if (performanceStats != null) {
            JButton perfStatsButton = new JButton("Performance Stats");
            perfStatsButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    JOptionPane.showMessageDialog((Component) ae.getSource(), performanceStats, null,
                            JOptionPane.PLAIN_MESSAGE);
                }
            });
            buttonsPanel.add(perfStatsButton);
        }

        JButton closeButton = new JButton("Close");
        buttonsPanel.add(closeButton);

        southernPanel.add(buttonsPanel);

        // add list and panel container to Dialog
        getContentPane().add(resultsTitlePanel, BorderLayout.NORTH);
        getContentPane().add(scrollPane, BorderLayout.CENTER);
        getContentPane().add(southernPanel, BorderLayout.SOUTH);

        // event for the closeButton button
        closeButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                DBAnnotationViewerDialog.this.setVisible(false);
            }
        });

        // event for analyzedResultsDialog window closing
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setLF(); // set default look and feel
        analyzedResultsList.setCellRenderer(new MyListCellRenderer());

        // doubleclicking on document shows the annotated result
        MouseListener mouseListener = new ListMouseAdapter();
        // styleMapFile, analyzedResultsList,
        // inputDirPath,typeSystem , typesToDisplay ,
        // javaViewerRB , javaViewerUCRB ,xmlRB ,
        // viewerDirectory , this);

        // add mouse Listener to the list
        analyzedResultsList.addMouseListener(mouseListener);
    } catch (DAOException e) {

        displayError(e.getMessage());

        this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
    }
}

From source file:org.eclipse.wb.internal.swing.preferences.laf.LafPreferencePage.java

/**
 * Creates {@link EmbeddedSwingComposite} with some Swing components to show it using different
 * LAFs.// w ww  .  j  a v a  2 s  .  c  om
 */
private void createPreviewArea(Group previewGroup) {
    try {
        LookAndFeel currentLookAndFeel = UIManager.getLookAndFeel();
        EmbeddedSwingComposite awtComposite = new EmbeddedSwingComposite(previewGroup, SWT.NONE) {
            @Override
            protected JComponent createSwingComponent() {
                // create the JRootPane
                JRootPane rootPane = new JRootPane();
                {
                    JMenuBar menuBar = new JMenuBar();
                    rootPane.setJMenuBar(menuBar);
                    {
                        JMenu mnFile = new JMenu(Messages.LafPreferencePage_previewFile);
                        menuBar.add(mnFile);
                        {
                            JMenuItem mntmNew = new JMenuItem(Messages.LafPreferencePage_previewNew);
                            mnFile.add(mntmNew);
                        }
                        {
                            JMenuItem mntmExit = new JMenuItem(Messages.LafPreferencePage_previewExit);
                            mnFile.add(mntmExit);
                        }
                    }
                    {
                        JMenu mnView = new JMenu(Messages.LafPreferencePage_previewView);
                        menuBar.add(mnView);
                        {
                            JMenuItem mntmCommon = new JMenuItem(Messages.LafPreferencePage_previewCommon);
                            mnView.add(mntmCommon);
                        }
                    }
                }
                GridBagLayout gridBagLayout = new GridBagLayout();
                gridBagLayout.columnWidths = new int[] { 0, 0, 0 };
                gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0 };
                gridBagLayout.columnWeights = new double[] { 0.0, 0.0, 1.0E-4 };
                gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0E-4 };
                rootPane.getContentPane().setLayout(gridBagLayout);
                {
                    JLabel lblLabel = new JLabel(Messages.LafPreferencePage_previewLabel);
                    GridBagConstraints gbc = new GridBagConstraints();
                    gbc.insets = new Insets(0, 0, 5, 5);
                    gbc.gridx = 0;
                    gbc.gridy = 0;
                    rootPane.getContentPane().add(lblLabel, gbc);
                }
                {
                    JButton btnPushButton = new JButton(Messages.LafPreferencePage_previewButton);
                    GridBagConstraints gbc = new GridBagConstraints();
                    gbc.insets = new Insets(0, 0, 5, 0);
                    gbc.gridx = 1;
                    gbc.gridy = 0;
                    rootPane.getContentPane().add(btnPushButton, gbc);
                }
                {
                    JComboBox comboBox = new JComboBox();
                    comboBox.setModel(new DefaultComboBoxModel(new String[] {
                            Messages.LafPreferencePage_previewCombo, "ComboBox Item 1", "ComboBox Item 2" }));
                    GridBagConstraints gbc = new GridBagConstraints();
                    gbc.insets = new Insets(0, 0, 5, 5);
                    gbc.fill = GridBagConstraints.HORIZONTAL;
                    gbc.gridx = 0;
                    gbc.gridy = 1;
                    rootPane.getContentPane().add(comboBox, gbc);
                }
                {
                    JRadioButton rdbtnRadioButton = new JRadioButton(Messages.LafPreferencePage_previewRadio);
                    GridBagConstraints gbc = new GridBagConstraints();
                    gbc.insets = new Insets(0, 0, 5, 0);
                    gbc.gridx = 1;
                    gbc.gridy = 1;
                    rootPane.getContentPane().add(rdbtnRadioButton, gbc);
                }
                {
                    JCheckBox chckbxCheckbox = new JCheckBox(Messages.LafPreferencePage_previewCheck);
                    GridBagConstraints gbc = new GridBagConstraints();
                    gbc.insets = new Insets(0, 0, 0, 5);
                    gbc.gridx = 0;
                    gbc.gridy = 2;
                    rootPane.getContentPane().add(chckbxCheckbox, gbc);
                }
                {
                    JTextField textField = new JTextField();
                    textField.setText(Messages.LafPreferencePage_previewTextField);
                    GridBagConstraints gbc = new GridBagConstraints();
                    gbc.fill = GridBagConstraints.HORIZONTAL;
                    gbc.gridx = 1;
                    gbc.gridy = 2;
                    rootPane.getContentPane().add(textField, gbc);
                }
                return rootPane;
            }
        };
        awtComposite.populate();
        // restore current laf
        UIManager.put("ClassLoader", currentLookAndFeel.getClass().getClassLoader());
        UIManager.setLookAndFeel(currentLookAndFeel);
    } catch (Throwable e) {
        DesignerPlugin.log(e);
    }
}

From source file:org.esa.s1tbx.ocean.worldwind.layers.Level2ProductLayer.java

public JPanel getControlPanel(final WorldWindowGLCanvas wwd) {
    theControlLevel2Panel = new JPanel(new GridLayout(7, 1, 5, 5));
    theControlLevel2Panel.setVisible(false);
    final JRadioButton owiBtn = new JRadioButton("OWI");
    owiBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            theSelectedComp = "owi";
            setComponentVisible("owi", wwd);
            theArrowsCB.setEnabled(true);
        }//from   www .j a  va  2s.co  m
    });

    final JRadioButton oswBtn = new JRadioButton("OSW");
    oswBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            theSelectedComp = "osw";
            setComponentVisible("osw", wwd);
            theArrowsCB.setEnabled(false);

            //SystemUtils.LOG.info("theSurfaceProductHash " + theSurfaceProductHash);
            //SystemUtils.LOG.info("theSurfaceSequenceHash " + theSurfaceSequenceHash);
        }
    });

    final JRadioButton rvlBtn = new JRadioButton("RVL");
    rvlBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            theSelectedComp = "rvl";
            //System.out.println("rvl:");
            //setComponentVisible("owi", false, getWwd());
            //setComponentVisible("osw", false, getWwd());
            setComponentVisible("rvl", wwd);
            theArrowsCB.setEnabled(false);
        }
    });

    final ButtonGroup group = new ButtonGroup();
    group.add(owiBtn);
    group.add(oswBtn);
    group.add(rvlBtn);
    owiBtn.setSelected(true);

    theSelectedComp = "owi";

    final JPanel componentTypePanel = new JPanel(new GridLayout(1, 4, 5, 5));
    componentTypePanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    componentTypePanel.add(new JLabel("Component:"));
    componentTypePanel.add(owiBtn);
    componentTypePanel.add(oswBtn);
    componentTypePanel.add(rvlBtn);
    theControlLevel2Panel.add(componentTypePanel);

    final JPanel arrowDisplayPanel = new JPanel(new GridLayout(1, 2, 5, 5));

    theArrowsCB = new JCheckBox(new AbstractAction() {
        public void actionPerformed(ActionEvent actionEvent) {
            // Simply enable or disable the layer based on its toggle button.
            if (((JCheckBox) actionEvent.getSource()).isSelected())
                theOWIArrowsDisplayed = true;
            else
                theOWIArrowsDisplayed = false;

            wwd.redrawNow();
        }
    });

    arrowDisplayPanel.add(new JLabel("Display Wind Vectors:"));
    arrowDisplayPanel.add(theArrowsCB);
    theControlLevel2Panel.add(arrowDisplayPanel);

    /*
    final JPanel subsectionPanel = new JPanel(new GridLayout(1, 2, 5, 5));
    JComboBox sectionDropDown = new JComboBox();
    sectionDropDown.addItem("001");
    sectionDropDown.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        SystemUtils.LOG.info("drop down changed");
    }
    });
            
    subsectionPanel.add(new JLabel("Subsection:"));
    subsectionPanel.add(sectionDropDown);
            
    theControlLevel2Panel.add(subsectionPanel);
    */

    final JPanel maxPanel = new JPanel(new GridLayout(1, 2, 5, 5));
    maxPanel.add(new JLabel("Max OWI Wind Speed:"));

    final JSpinner maxSP = new JSpinner(new SpinnerNumberModel(10, 0, 10, 1));
    maxSP.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            int newValue = (Integer) ((JSpinner) e.getSource()).getValue();

            theOWILimitChanged = true;
        }
    });
    maxPanel.add(maxSP);
    theControlLevel2Panel.add(maxPanel);

    final JPanel minPanel = new JPanel(new GridLayout(1, 2, 5, 5));
    minPanel.add(new JLabel("Min OWI Wind Speed:"));

    final JSpinner minSP = new JSpinner(new SpinnerNumberModel(0, 0, 10, 1));
    minSP.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            theOWILimitChanged = true;
        }
    });
    minPanel.add(minSP);
    theControlLevel2Panel.add(minPanel);

    final JPanel maxRVLPanel = new JPanel(new GridLayout(1, 2, 5, 5));
    maxRVLPanel.add(new JLabel("Max RVL Rad Vel.:"));

    final JSpinner maxRVLSP = new JSpinner(new SpinnerNumberModel(6, 0, 10, 1));
    maxRVLSP.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            int newValue = (Integer) ((JSpinner) e.getSource()).getValue();
            theRVLLimitChanged = true;
        }
    });
    maxRVLPanel.add(maxRVLSP);
    theControlLevel2Panel.add(maxRVLPanel);

    final JButton updateButton = new JButton("Update");
    updateButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {

            if (theOWILimitChanged) {

                //double minValue = ((Integer) minSP.getValue()) * 1.0e4;
                //double maxValue = ((Integer) maxSP.getValue()) * 1.0e4;
                double minValue = ((Integer) minSP.getValue());
                double maxValue = ((Integer) maxSP.getValue());
                recreateColorBarAndGradient(minValue, maxValue, "owi", wwd,
                        theSelectedComp.equalsIgnoreCase("owi"));
            }

            if (theRVLLimitChanged) {
                //SystemUtils.LOG.info("theRVLLimitChanged");

                //double minValue = ((Integer) minSP.getValue()) * 1.0e4;
                //double maxValue = ((Integer) maxSP.getValue()) * 1.0e4;

                double maxValue = ((Integer) maxRVLSP.getValue());
                double minValue = -1 * maxValue;

                recreateColorBarAndGradient(minValue, maxValue, "rvl", wwd,
                        theSelectedComp.equalsIgnoreCase("rvl"));
            }

            theOWILimitChanged = false;
            theRVLLimitChanged = false;
        }
    });
    theControlLevel2Panel.add(updateButton);

    createColorBarLegend(0, 10, "OWI Wind Speed", "owi");
    createColorBarLegend(0, 10, "OSW Wave Height.", "osw");
    createColorBarLegend(-6, 6, "RVL Rad. Vel.", "rvl");
    //addRenderable(theColorBarLegendHash.get("owi"));

    return theControlLevel2Panel;
}

From source file:org.fhaes.gui.ShapeFileDialog.java

@SuppressWarnings("unchecked")
private void initGUI() {

    setBounds(100, 100, 582, 333);/*  w w  w .j ava2s.c o m*/
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new MigLayout("", "[right][grow]", "[][][][grow]"));
    {
        JLabel lblOutputFilename = new JLabel("Output filename:");
        contentPanel.add(lblOutputFilename, "cell 0 0,alignx trailing");
    }
    {
        txtFilename = new JTextField();
        txtFilename.getDocument().addDocumentListener(this);
        contentPanel.add(txtFilename, "flowx,cell 1 0,growx");
        txtFilename.setColumns(10);
    }
    {
        JButton btnBrowse = new JButton("Browse");
        btnBrowse.setActionCommand("Browse");
        btnBrowse.addActionListener(this);
        contentPanel.add(btnBrowse, "cell 1 0");
    }
    {
        JLabel lblAttributeTableStyle = new JLabel("Attribute table style:");
        contentPanel.add(lblAttributeTableStyle, "cell 0 1,alignx trailing");
    }
    {
        radStyle1 = new JRadioButton("One marker per site with multiple year attributes");
        radStyle1.setActionCommand("Style1");
        radStyle1.addActionListener(this);
        // radStyle1.setSelected(true);

        buttonGroup.add(radStyle1);
        contentPanel.add(radStyle1, "cell 1 1");
    }
    {
        radStyle2 = new JRadioButton("Multiple markers per site, one for each year");
        radStyle2.setActionCommand("Style2");
        radStyle2.addActionListener(this);
        buttonGroup.add(radStyle2);

        new RadioButtonWrapper(buttonGroup, PrefKey.SHAPEFILE_OUTPUT_STYLE, "Style1");

        contentPanel.add(radStyle2, "cell 1 2");
    }
    {
        JPanel panel = new JPanel();
        contentPanel.add(panel, "cell 0 3,alignx right,growy");
        panel.setLayout(new MigLayout("insets n n n 0", "[119px]", "[15px]"));
        {
            JLabel lblYearsToInclude = new JLabel("Years to include:");
            panel.add(lblYearsToInclude, "cell 0 0,alignx left,aligny top");
        }
    }
    {
        JPanel panel = new JPanel();
        contentPanel.add(panel, "cell 1 3,alignx left,growy");
        panel.setLayout(new MigLayout("", "[160px:160px][][160px:160px]", "[][grow]"));
        {
            JLabel lblAvailableYears = new JLabel("Available:");
            panel.add(lblAvailableYears, "cell 0 0,alignx center");
        }
        {
            lblSelectedYears = new JLabel("Selected:");
            panel.add(lblSelectedYears, "cell 2 0,alignx center");
        }
        {
            JScrollPane scrollPane = new JScrollPane();
            panel.add(scrollPane, "cell 0 1,grow");
            {

                lstAvailableYears = new JList();
                lstAvailableYears.setModel(availableYearsModel);
                scrollPane.setViewportView(lstAvailableYears);
            }
        }
        {
            JButton btnRemove = new JButton("<");
            btnRemove.setActionCommand("removeYear");
            btnRemove.addActionListener(this);
            {
                JButton btnAdd = new JButton(">");
                btnAdd.setActionCommand("addYear");
                btnAdd.addActionListener(this);
                panel.add(btnAdd, "flowy,cell 1 1");
            }
            panel.add(btnRemove, "cell 1 1");
        }
        {
            JScrollPane scrollPane = new JScrollPane();
            panel.add(scrollPane, "cell 2 1,grow");
            {
                lstSelectedYears = new JList();
                lstSelectedYears.setModel(selectedYearsModel);
                selectedYearsModel.addListDataListener(new ListDataListener() {

                    @Override
                    public void contentsChanged(ListDataEvent arg0) {

                        pingLayout();
                    }

                    @Override
                    public void intervalAdded(ListDataEvent arg0) {

                        pingLayout();

                    }

                    @Override
                    public void intervalRemoved(ListDataEvent arg0) {

                        pingLayout();

                    }

                });
                scrollPane.setViewportView(lstSelectedYears);
            }
        }
    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            btnOK = new JButton("OK");
            btnOK.setActionCommand("OK");
            btnOK.addActionListener(this);
            buttonPane.add(btnOK);
            getRootPane().setDefaultButton(btnOK);
            btnOK.setEnabled(false);
        }
        {
            JButton btnCancel = new JButton("Cancel");
            btnCancel.setActionCommand("Cancel");
            btnCancel.addActionListener(this);
            buttonPane.add(btnCancel);
        }
    }

    this.setLocationRelativeTo(parent);
    this.setIconImage(Builder.getApplicationIcon());
    this.setTitle("Generate shapefile");
    pingLayout();
}

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

/**
 * Constructor/*  w w  w  .  ja  va 2  s .  c o m*/
 */
public DocSearch() {
    super(I18n.getString("ds.windowtitle"));

    // get logger
    logger = Logger.getLogger(getClass().getName());

    //
    File testCDFi = new File(cdRomDefaultHome);
    Properties sys = new Properties(System.getProperties());
    if (testCDFi.exists()) {
        sys.setProperty("disableLuceneLocks", "true");
        logger.info("DocSearch() Disabling Lucene Locks for CDROM indexes");
    } else {
        sys.setProperty("disableLuceneLocks", "false");
    }

    //
    checkCDROMDir();
    defaultHndlr = getBrowserFile();
    loadSettings();

    //
    pPanel = new ProgressPanel("", 100L);
    pPanel.init();

    phrase = new JRadioButton(I18n.getString("label.phrase"));
    searchField = new JComboBox();
    searchIn = new JComboBox(searchOptsLabels);
    JLabel searchTypeLabel = new JLabel(I18n.getString("label.search_type"));
    JLabel searchInLabel = new JLabel(I18n.getString("label.search_in"));
    keywords = new JRadioButton(I18n.getString("label.keyword"));
    //
    searchLabel = new JLabel(I18n.getString("label.search_for"));
    searchButton = new JButton(I18n.getString("button.search"));
    searchButton.setActionCommand("ac_search");
    searchButton.setMnemonic(KeyEvent.VK_A);
    // TODO alt text to resource
    htmlTag = "<img src=\"" + fEnv.getIconURL(FileType.HTML.getIcon())
            + "\" border=\"0\" alt=\"Web Page Document\">";
    wordTag = "<img src=\"" + fEnv.getIconURL(FileType.MS_WORD.getIcon())
            + "\" border=\"0\" alt=\"MS Word Document\">";
    excelTag = "<img src=\"" + fEnv.getIconURL(FileType.MS_EXCEL.getIcon())
            + "\" border=\"0\" alt=\"MS Excel Document\">";
    pdfTag = "<img src=\"" + fEnv.getIconURL(FileType.PDF.getIcon()) + "\" border=\"0\" alt=\"PDF Document\">";
    textTag = "<img src=\"" + fEnv.getIconURL(FileType.TEXT.getIcon())
            + "\" border=\"0\" alt=\"Text Document\">";
    rtfTag = "<img src=\"" + fEnv.getIconURL(FileType.RTF.getIcon()) + "\" border=\"0\" alt=\"RTF Document\">";
    ooImpressTag = "<img src=\"" + fEnv.getIconURL(FileType.OO_IMPRESS.getIcon())
            + "\" border=\"0\" alt=\"OpenOffice Impress Document\">";
    ooWriterTag = "<img src=\"" + fEnv.getIconURL(FileType.OO_WRITER.getIcon())
            + "\" border=\"0\" alt=\"OpenOffice Writer Document\">";
    ooCalcTag = "<img src=\"" + fEnv.getIconURL(FileType.OO_CALC.getIcon())
            + "\" border=\"0\" alt=\"OpenOffice Calc Document\">";
    ooDrawTag = "<img src=\"" + fEnv.getIconURL(FileType.OO_DRAW.getIcon())
            + "\" border=\"0\" alt=\"OpenOffice Draw Document\">";
    openDocumentTextTag = "<img src=\"" + fEnv.getIconURL(FileType.OPENDOCUMENT_TEXT.getIcon())
            + "\" border=\"0\" alt=\"OpenDocument Text Document\">";
    //
    idx = new Index(this);
    colors = new String[2];
    colors[0] = "ffeffa";
    colors[1] = "fdffda";
    if (env.isWebStart()) {
        startPageString = getClass().getResource("/" + FileEnvironment.FILENAME_START_PAGE_WS).toString();
        helpPageString = getClass().getResource("/" + FileEnvironment.FILENAME_HELP_PAGE_WS).toString();
        if (startPageString != null) {
            logger.debug("DocSearch() Start Page is: " + startPageString);
            hasStartPage = true;
        } else {
            logger.error("DocSearch() Start Page NOT FOUND where expected: " + startPageString);
        }
    } else {
        startPageString = FileUtils.addFolder(fEnv.getStartDirectory(), FileEnvironment.FILENAME_START_PAGE);
        helpPageString = FileUtils.addFolder(fEnv.getStartDirectory(), FileEnvironment.FILENAME_HELP_PAGE);
        File startPageFile = new File(startPageString);
        if (startPageFile.exists()) {
            logger.debug("DocSearch() Start Page is: " + startPageString);
            hasStartPage = true;
        } else {
            logger.error("DocSearch() Start Page NOT FOUND where expected: " + startPageString);
        }
    }

    defaultSaveFolder = FileUtils.addFolder(fEnv.getWorkingDirectory(), "saved_searches");
    searchField.setEditable(true);
    searchField.addItem("");

    bg = new ButtonGroup();
    bg.add(phrase);
    bg.add(keywords);
    keywords.setSelected(true);

    keywords.setToolTipText(I18n.getString("tooltip.keyword"));
    phrase.setToolTipText(I18n.getString("tooltip.phrase"));

    int iconInt = 2;
    searchField.setPreferredSize(new Dimension(370, 22));

    // application icon
    Image iconImage = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/ds.gif"));
    this.setIconImage(iconImage);

    // menu bar
    JMenuBar menuBar = createMenuBar();
    // add menu to frame
    setJMenuBar(menuBar);

    // tool bar
    JToolBar toolbar = createToolBar();

    editorPane = new JEditorPane("text/html", lastSearch);
    editorPane.setEditable(false);
    editorPane.addHyperlinkListener(new Hyperactive());
    if (hasStartPage) {
        try {
            editorPane.setContentType("text/html");
            if (setPage("home")) {
                logger.info("DocSearch() loaded start page: " + startPageString);
            }
        } catch (Exception e) {
            editorPane.setText(lastSearch);
        }
    } else {
        logger.warn("DocSearch() no start page loaded");
    }

    scrollPane = new JScrollPane(editorPane);
    scrollPane.setPreferredSize(new Dimension(1024, 720));
    scrollPane.setMinimumSize(new Dimension(900, 670));
    scrollPane.setMaximumSize(new Dimension(1980, 1980));

    // create panels
    // add printing stuff
    vista = new JComponentVista(editorPane, new PageFormat());

    JPanel topPanel = new JPanel();
    topPanel.add(searchLabel);
    topPanel.add(searchField);
    topPanel.add(searchButton);

    JPanel bottomPanel = new JPanel();
    bottomPanel.add(searchTypeLabel);
    bottomPanel.add(keywords);
    bottomPanel.add(phrase);
    bottomPanel.add(searchInLabel);
    bottomPanel.add(searchIn);

    // GUI items for advanced searching
    useDate = new JCheckBox(I18n.getString("label.use_date_property"));
    fromField = new JTextField(11);
    JLabel fromLabel = new JLabel(I18n.getString("label.from"));
    JLabel toLabel = new JLabel(I18n.getString("label.to"));
    toField = new JTextField(11);
    cbl = new CheckBoxListener();
    authorPanel = new JPanel();
    useAuthor = new JCheckBox(I18n.getString("label.use_auth_property"));
    authorField = new JTextField(31);
    JLabel authorLabel = new JLabel(I18n.getString("label.author"));
    authorPanel.add(useAuthor);
    authorPanel.add(authorLabel);
    authorPanel.add(authorField);

    // combine stuff
    JPanel datePanel = new JPanel();
    datePanel.add(useDate);
    datePanel.add(fromLabel);
    datePanel.add(fromField);
    datePanel.add(toLabel);
    datePanel.add(toField);

    JPanel metaPanel = new JPanel();
    metaPanel.setLayout(new BorderLayout());
    metaPanel.setBorder(new TitledBorder(I18n.getString("label.date_and_author")));
    metaPanel.add(datePanel, BorderLayout.NORTH);
    metaPanel.add(authorPanel, BorderLayout.SOUTH);

    useDate.addActionListener(cbl);
    useAuthor.addActionListener(cbl);

    fromField.setText(DateTimeUtils.getLastYear());
    toField.setText(DateTimeUtils.getToday());
    authorField.setText(System.getProperty("user.name"));

    JPanel[] panels = new JPanel[numPanels];
    for (int i = 0; i < numPanels; i++) {
        panels[i] = new JPanel();
    }

    // add giu to panels
    panels[0].setLayout(new BorderLayout());
    panels[0].add(topPanel, BorderLayout.NORTH);
    panels[0].add(bottomPanel, BorderLayout.SOUTH);
    panels[0].setBorder(new TitledBorder(I18n.getString("label.search_critera")));
    searchButton.addActionListener(this);

    JPanel fileTypePanel = new JPanel();
    useType = new JCheckBox(I18n.getString("label.use_filetype_property"));
    useType.addActionListener(cbl);
    fileType = new JComboBox(fileTypesToFindLabel);
    JLabel fileTypeLabel = new JLabel(I18n.getString("label.find_only_these_filetypes"));
    fileTypePanel.add(useType);
    fileTypePanel.add(fileTypeLabel);
    fileTypePanel.add(fileType);

    JPanel sizePanel = new JPanel();
    useSize = new JCheckBox(I18n.getString("label.use_filesize_property"));
    useSize.addActionListener(cbl);
    // TODO l18n kbytes
    JLabel sizeFromLabel = new JLabel(I18n.getString("label.from") + " KByte");
    JLabel sizeToLabel = new JLabel(I18n.getString("label.to") + " KByte");
    sizeFromField = new JTextField(10);
    sizeFromField.setText("0");
    sizeToField = new JTextField(10);
    sizeToField.setText("100");
    sizePanel.add(useSize);
    sizePanel.add(sizeFromLabel);
    sizePanel.add(sizeFromField);
    sizePanel.add(sizeToLabel);
    sizePanel.add(sizeToField);

    JPanel sizeAndTypePanel = new JPanel();
    sizeAndTypePanel.setLayout(new BorderLayout());
    sizeAndTypePanel.setBorder(new TitledBorder(I18n.getString("label.filetype_and_size")));
    sizeAndTypePanel.add(fileTypePanel, BorderLayout.NORTH);
    sizeAndTypePanel.add(sizePanel, BorderLayout.SOUTH);

    // set up the tabbed pane
    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab(I18n.getString("label.general"), null, panels[0],
            I18n.getString("tooltip.general_search_criteria"));
    tabbedPane.addTab(I18n.getString("label.date_and_author"), null, metaPanel,
            I18n.getString("tooltip.date_auth_options"));
    tabbedPane.addTab(I18n.getString("label.filetype_and_size"), null, sizeAndTypePanel,
            I18n.getString("tooltip.filetype_and_size_options"));

    // gridbag
    getContentPane().setLayout(new GridLayout(1, numPanels + iconInt + 1));
    GridBagLayout gridbaglayout = new GridBagLayout();
    GridBagConstraints gridbagconstraints = new GridBagConstraints();
    getContentPane().setLayout(gridbaglayout);

    gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
    gridbagconstraints.insets = new Insets(1, 1, 1, 1);
    gridbagconstraints.gridx = 0;
    gridbagconstraints.gridy = 0;
    gridbagconstraints.gridwidth = 1;
    gridbagconstraints.gridheight = 1;
    gridbagconstraints.weightx = 1.0D;
    gridbagconstraints.weighty = 0.0D;
    gridbaglayout.setConstraints(toolbar, gridbagconstraints);
    getContentPane().add(toolbar);

    int start = 1;
    for (int i = 0; i < numPanels; i++) {
        if (i == 0) {
            gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
            gridbagconstraints.insets = new Insets(1, 1, 1, 1);
            gridbagconstraints.gridx = 0;
            gridbagconstraints.gridy = i + start;
            gridbagconstraints.gridwidth = 1;
            gridbagconstraints.gridheight = 1;
            gridbagconstraints.weightx = 1.0D;
            gridbagconstraints.weighty = 0.0D;
            gridbaglayout.setConstraints(tabbedPane, gridbagconstraints);
            getContentPane().add(tabbedPane);
        } else {
            gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
            gridbagconstraints.insets = new Insets(1, 1, 1, 1);
            gridbagconstraints.gridx = 0;
            gridbagconstraints.gridy = i + start;
            gridbagconstraints.gridwidth = 1;
            gridbagconstraints.gridheight = 1;
            gridbagconstraints.weightx = 1.0D;
            gridbagconstraints.weighty = 0.0D;
            gridbaglayout.setConstraints(panels[i], gridbagconstraints);
            getContentPane().add(panels[i]);
        }
    }

    // now add the results area
    gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
    gridbagconstraints.insets = new Insets(1, 1, 1, 1);
    gridbagconstraints.gridx = 0;
    gridbagconstraints.gridy = iconInt;
    gridbagconstraints.gridwidth = 1;
    gridbagconstraints.gridheight = 1;
    gridbagconstraints.weightx = 1.0D;
    gridbagconstraints.weighty = 1.0D;
    gridbaglayout.setConstraints(scrollPane, gridbagconstraints);
    getContentPane().add(scrollPane);
    JPanel statusP = new JPanel();
    statusP.setLayout(new BorderLayout());
    statusP.add(dirLabel, BorderLayout.WEST);
    statusP.add(pPanel, BorderLayout.EAST);

    // now add the status label
    gridbagconstraints.fill = GridBagConstraints.HORIZONTAL;
    gridbagconstraints.insets = new Insets(1, 1, 1, 1);
    gridbagconstraints.gridx = 0;
    gridbagconstraints.gridy = numPanels + iconInt;
    gridbagconstraints.gridwidth = 1;
    gridbagconstraints.gridheight = 1;
    gridbagconstraints.weightx = 1.0D;
    gridbagconstraints.weighty = 0.0D;
    gridbaglayout.setConstraints(statusP, gridbagconstraints);
    getContentPane().add(statusP);

    //
    File testArchDir = new File(fEnv.getArchiveDirectory());
    if (!testArchDir.exists()) {
        boolean madeDir = testArchDir.mkdir();
        if (!madeDir) {
            logger.warn("DocSearch() Error creating directory: " + fEnv.getArchiveDirectory());
        } else {
            logger.info("DocSearch() Directory created: " + fEnv.getArchiveDirectory());
        }
    }
    loadIndexes();

    // DocTypeHandler
    String handlersFiName;
    if (!isCDSearchTool) {
        handlersFiName = FileUtils.addFolder(fEnv.getWorkingDirectory(), DocTypeHandlerUtils.HANDLER_FILE);
    } else {
        handlersFiName = FileUtils.addFolder(cdRomDefaultHome, DocTypeHandlerUtils.HANDLER_FILE);
    }
    DocTypeHandlerUtils dthUtils = new DocTypeHandlerUtils();
    if (!FileUtils.fileExists(handlersFiName)) {
        logger.warn("DocSearch() Handlers file not found at: " + handlersFiName);
        handlerList = dthUtils.getInitialHandler(env);
    } else {
        handlerList = dthUtils.loadHandler(handlersFiName);
    }
}

From source file:org.jcurl.demo.tactics.BroomPromptSwingBean.java

public BroomPromptSwingBean() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    final Box b = Box.createVerticalBox();
    {// w w w  .j a  va 2s . co  m
        final JPanel tb = new JPanel();
        tb.setLayout(new BoxLayout(tb, BoxLayout.X_AXIS));
        tb.setBorder(BorderFactory.createTitledBorder("Active"));
        tb.add(rock = new JComboBox(new Object[] { 1, 2, 3, 4, 5, 6, 7, 8 }));
        rock.setPrototypeDisplayValue(8);
        rock.addItemListener(this);
        dark = new JRadioButton("dark");
        dark.addActionListener(this);
        light = new JRadioButton("light");
        light.addActionListener(this);
        final ButtonGroup bg = new ButtonGroup();
        bg.add(dark);
        bg.add(light);
        tb.add(dark);
        tb.add(light);
        b.add(tb);
    }
    {
        final JPanel tb = new JPanel();
        tb.setLayout(new BoxLayout(tb, BoxLayout.X_AXIS));
        tb.setBorder(BorderFactory.createTitledBorder("Handle"));
        in = new JRadioButton("In Turn");
        in.addActionListener(this);
        out = new JRadioButton("Out Turn");
        out.addActionListener(this);
        final ButtonGroup bg = new ButtonGroup();
        bg.add(in);
        bg.add(out);
        tb.add(out);
        tb.add(in);
        tb.add(Box.createHorizontalGlue());
        b.add(tb);
    }
    {
        final JPanel tb = new JPanel();
        tb.setLayout(new BoxLayout(tb, BoxLayout.X_AXIS));
        tb.setBorder(BorderFactory.createTitledBorder("Split Time"));

        if (UseJSpinnerBoundedRange) {
            split2 = new JSpinnerBoundedRange();
            split2.addFocusListener(this);
            split = null;
        } else {
            split2 = null;
            split = new JSpinner();
            // log.info(split.getEditor().getClass().getName());
            split.addFocusListener(this);
            final JSpinner.NumberEditor ed = (JSpinner.NumberEditor) split.getEditor();
            ed.addFocusListener(this);
            ed.getTextField().addFocusListener(this);
        }

        tb.add(split2);

        tb.add(dt = new JComboBox(new Object[] { "1/1000 sec", "1/100 sec", "1/10 sec", "sec" }));
        tb.add(Box.createHorizontalGlue());
        b.add(tb);
        dt.setEnabled(false);
    }
    {
        final JPanel p = new JPanel();
        p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
        p.setBorder(BorderFactory.createTitledBorder("Broom Position"));
        {
            x = new JSpinnerNumberUnit();
            x.setLabel("x: ");
            x.setBase(Unit.METER);
            x.setChoose(Unit.FOOT, Unit.INCH, Unit.CENTIMETER, Unit.METER);
            x.setModel(new SpinnerNumberModel(0.0, -IceSize.SIDE_2_CENTER, IceSize.SIDE_2_CENTER, 0.1));
            x.addChangeListener(this);
            x.addPropertyChangeListener(this);
            p.add(x);
        }
        {
            y = new JSpinnerNumberUnit();
            y.setLabel("y: ");
            y.setBase(Unit.METER);
            y.setChoose(Unit.FOOT, Unit.INCH, Unit.CENTIMETER, Unit.METER);
            y.setModel(new SpinnerNumberModel(0.0, -IceSize.BACK_2_TEE, IceSize.HOG_2_TEE, 0.1));
            y.addChangeListener(this);
            y.addPropertyChangeListener(this);
            p.add(y);
        }
        b.add(p);
    }
    this.add(b);
}

From source file:org.jets3t.apps.cockpit.gui.StartupDialog.java

/**
 * Initialises all GUI elements./*from  ww w. j a v  a 2  s  .c o  m*/
 */
private void initGui() {
    this.setResizable(false);
    this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);

    cancelButton = new JButton("Don't log in");
    cancelButton.setActionCommand("Cancel");
    cancelButton.addActionListener(this);
    storeCredentialsButton = new JButton("Store Credentials");
    storeCredentialsButton.setActionCommand("StoreCredentials");
    storeCredentialsButton.addActionListener(this);
    okButton = new JButton("Log in");
    okButton.setActionCommand("LogIn");
    okButton.addActionListener(this);

    // Set default ENTER and ESCAPE buttons.
    this.getRootPane().setDefaultButton(okButton);
    this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"),
            "ESCAPE");
    this.getRootPane().getActionMap().put("ESCAPE", new AbstractAction() {
        private static final long serialVersionUID = -1742280851624947873L;

        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);
        }
    });

    JPanel buttonsPanel = new JPanel(new GridBagLayout());
    buttonsPanel.add(cancelButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, insetsZero, 0, 0));
    buttonsPanel.add(storeCredentialsButton, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.EAST,
            GridBagConstraints.NONE, insetsZero, 0, 0));
    buttonsPanel.add(okButton, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.NONE, insetsZero, 0, 0));

    loginPassphrasePanel = new LoginPassphrasePanel(hyperlinkListener);
    loginLocalFolderPanel = new LoginLocalFolderPanel(ownerFrame, hyperlinkListener);
    loginCredentialsPanel = new LoginCredentialsPanel(false, hyperlinkListener);

    // Target storage service selection
    targetS3 = new JRadioButton("Amazon S3");
    targetS3.setSelected(true);
    targetGS = new JRadioButton("Google Storage");

    ButtonGroup targetButtonGroup = new ButtonGroup();
    targetButtonGroup.add(targetS3);
    targetButtonGroup.add(targetGS);

    JPanel targetServicePanel = new JPanel(new GridBagLayout());
    targetServicePanel.add(targetS3, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.EAST,
            GridBagConstraints.NONE, insetsZero, 0, 0));
    targetServicePanel.add(targetGS, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, insetsZero, 0, 0));

    // Tabbed Pane.
    tabbedPane = new JTabbedPane();
    tabbedPane.addChangeListener(this);
    tabbedPane.add(loginPassphrasePanel, "Online");
    tabbedPane.add(loginLocalFolderPanel, "Local Folder");
    tabbedPane.add(loginCredentialsPanel, "Direct Login");

    int row = 0;
    this.getContentPane().setLayout(new GridBagLayout());
    this.getContentPane().add(targetServicePanel, new GridBagConstraints(0, row++, 2, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));
    this.getContentPane().add(tabbedPane, new GridBagConstraints(0, row++, 2, 1, 1, 1,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0));
    this.getContentPane().add(buttonsPanel, new GridBagConstraints(0, row++, 2, 1, 1, 0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    this.pack();
    this.setSize(500, 430);
    this.setLocationRelativeTo(this.getOwner());
}

From source file:org.languagetool.gui.ConfigurationDialog.java

private void createOfficeElements(GridBagConstraints cons, JPanel portPanel) {
    int numParaCheck = config.getNumParasToCheck();
    JRadioButton[] radioButtons = new JRadioButton[3];
    ButtonGroup numParaGroup = new ButtonGroup();
    radioButtons[0] = new JRadioButton(Tools.getLabel(messages.getString("guiCheckOnlyParagraph")));
    radioButtons[0].setActionCommand("ParagraphCheck");

    radioButtons[1] = new JRadioButton(Tools.getLabel(messages.getString("guiCheckFullText")));
    radioButtons[1].setActionCommand("FullTextCheck");

    radioButtons[2] = new JRadioButton(Tools.getLabel(messages.getString("guiCheckNumParagraphs")));
    radioButtons[2].setActionCommand("NParagraphCheck");
    radioButtons[2].setSelected(true);/*from   ww w .j  a  va2  s  . com*/

    JTextField numParaField = new JTextField(Integer.toString(5), 2);
    numParaField.setEnabled(radioButtons[2].isSelected());
    numParaField.setMinimumSize(new Dimension(30, 25));

    for (int i = 0; i < 3; i++) {
        numParaGroup.add(radioButtons[i]);
    }

    if (numParaCheck == 0) {
        radioButtons[0].setSelected(true);
        numParaField.setEnabled(false);
    } else if (numParaCheck < 0) {
        radioButtons[1].setSelected(true);
        numParaField.setEnabled(false);
    } else {
        radioButtons[2].setSelected(true);
        numParaField.setText(Integer.toString(numParaCheck));
        numParaField.setEnabled(true);
    }

    radioButtons[0].addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            numParaField.setEnabled(false);
            config.setNumParasToCheck(0);
        }
    });

    radioButtons[1].addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            numParaField.setEnabled(false);
            config.setNumParasToCheck(-1);
        }
    });

    radioButtons[2].addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int numParaCheck = Integer.parseInt(numParaField.getText());
            if (numParaCheck < 1)
                numParaCheck = 1;
            else if (numParaCheck > 99)
                numParaCheck = 99;
            config.setNumParasToCheck(numParaCheck);
            numParaField.setForeground(Color.BLACK);
            numParaField.setText(Integer.toString(numParaCheck));
            numParaField.setEnabled(true);
        }
    });

    numParaField.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            try {
                int numParaCheck = Integer.parseInt(numParaField.getText());
                if (numParaCheck > 0 && numParaCheck < 99) {
                    numParaField.setForeground(Color.BLACK);
                    config.setNumParasToCheck(numParaCheck);
                } else {
                    numParaField.setForeground(Color.RED);
                }
            } catch (NumberFormatException ex) {
                numParaField.setForeground(Color.RED);
            }
        }
    });

    JLabel textChangedLabel = new JLabel(Tools.getLabel(messages.getString("guiTextChangeLabel")));
    cons.gridy++;
    portPanel.add(textChangedLabel, cons);

    cons.gridy++;
    cons.insets = new Insets(0, 30, 0, 0);
    for (int i = 0; i < 3; i++) {
        portPanel.add(radioButtons[i], cons);
        if (i < 2)
            cons.gridy++;
    }
    cons.gridx = 1;
    portPanel.add(numParaField, cons);

    JCheckBox noMultiResetbox = new JCheckBox(Tools.getLabel(messages.getString("guiNoMultiReset")));
    noMultiResetbox.setSelected(config.isNoMultiReset());
    noMultiResetbox.setEnabled(config.isResetCheck());
    noMultiResetbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            config.setNoMultiReset(noMultiResetbox.isSelected());
        }
    });

    JCheckBox resetCheckbox = new JCheckBox(Tools.getLabel(messages.getString("guiDoResetCheck")));
    resetCheckbox.setSelected(config.isResetCheck());
    resetCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            config.setDoResetCheck(resetCheckbox.isSelected());
            noMultiResetbox.setEnabled(resetCheckbox.isSelected());
        }
    });
    cons.insets = new Insets(0, 4, 0, 0);
    cons.gridx = 0;
    //    JLabel dummyLabel = new JLabel(" ");
    //    cons.gridy++;
    //    portPanel.add(dummyLabel, cons);
    cons.gridy++;
    portPanel.add(resetCheckbox, cons);

    cons.insets = new Insets(0, 30, 0, 0);
    cons.gridx = 0;
    cons.gridy++;
    portPanel.add(noMultiResetbox, cons);

    JCheckBox fullTextCheckAtFirstBox = new JCheckBox(
            Tools.getLabel(messages.getString("guiCheckFullTextAtFirst")));
    fullTextCheckAtFirstBox.setSelected(config.doFullCheckAtFirst());
    fullTextCheckAtFirstBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            config.setFullCheckAtFirst(fullTextCheckAtFirstBox.isSelected());
        }
    });
    cons.insets = new Insets(0, 4, 0, 0);
    cons.gridx = 0;
    //    cons.gridy++;
    //    JLabel dummyLabel2 = new JLabel(" ");
    //    portPanel.add(dummyLabel2, cons);
    cons.gridy++;
    portPanel.add(fullTextCheckAtFirstBox, cons);

    JCheckBox isMultiThreadBox = new JCheckBox(Tools.getLabel(messages.getString("guiIsMultiThread")));
    isMultiThreadBox.setSelected(config.isMultiThread());
    isMultiThreadBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            config.setMultiThreadLO(isMultiThreadBox.isSelected());
        }
    });
    cons.gridy++;
    JLabel dummyLabel3 = new JLabel(" ");
    portPanel.add(dummyLabel3, cons);
    cons.gridy++;
    portPanel.add(isMultiThreadBox, cons);

}