Example usage for java.awt BorderLayout PAGE_START

List of usage examples for java.awt BorderLayout PAGE_START

Introduction

In this page you can find the example usage for java.awt BorderLayout PAGE_START.

Prototype

String PAGE_START

To view the source code for java.awt BorderLayout PAGE_START.

Click Source Link

Document

The component comes before the first line of the layout's content.

Usage

From source file:com.haskins.cloudtrailviewer.feature.MetricsFeature.java

private void buildUI() {

    // toolbar/*  w w  w . ja  v  a2  s.c  o  m*/
    toolbar.setLayout(new WrapLayout(FlowLayout.CENTER, 1, 1));
    toolbar.setFloatable(false);
    toolbar.setBackground(Color.white);
    toolbar.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 0, Color.black));

    eventTable.setVisible(false);

    jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, chartCards, eventTable);
    jsp.setDividerSize(0);
    jsp.setResizeWeight(1);
    jsp.setDividerLocation(jsp.getSize().height - jsp.getInsets().bottom - jsp.getDividerSize());
    jsp.setBorder(BorderFactory.createEmptyBorder(1, 0, 0, 0));

    this.setLayout(new BorderLayout());
    this.add(toolbar, BorderLayout.PAGE_START);
    this.add(jsp, BorderLayout.CENTER);
}

From source file:org.jax.bham.test.HaplotypeAssociationTestGraphPanel.java

/**
 * a function to initialize the components for this panel
 *//*from   w  w w. j  a v  a  2s .  co  m*/
private void initialize() {
    this.chromosomeComboBox.addItem("All Chromosomes");
    List<Integer> chromoList = SequenceUtilities
            .toIntegerList(this.testToPlot.getHaplotypeDataSource().getAvailableChromosomes());
    Collections.sort(chromoList);
    for (Integer chromoNum : chromoList) {
        this.chromosomeComboBox.addItem(chromoNum);
    }
    if (!chromoList.isEmpty()) {
        this.chromosomeComboBox.setSelectedIndex(1);
    }
    this.chromosomeComboBox.addItemListener(new ItemListener() {
        /**
         * {@inheritDoc}
         */
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                HaplotypeAssociationTestGraphPanel.this.chromosomeSelectionChanged();
            }
        }
    });

    JToolBar toolBar = new JToolBar();
    toolBar.add(new JLabel("Chromosome:"));

    // limit the size or the toolbar will try to make the drop-down huge
    this.chromosomeComboBox.setMaximumSize(this.chromosomeComboBox.getPreferredSize());
    toolBar.add(this.chromosomeComboBox);

    this.add(toolBar, BorderLayout.PAGE_START);

    this.add(this.chartPanel, BorderLayout.CENTER);

    this.chromosomeSelectionChanged();
}

From source file:org.pdfsam.guiclient.gui.frames.JMainFrame.java

/**
 * initialization/*  w  w  w.  jav a2s  .c  o  m*/
 */
private void initialize() {
    try {
        // center(this,800,600);
        URL iconUrl = this.getClass().getResource("/images/pdf_" + GuiClient.getVersionType() + ".png");
        URL iconUrl16 = this.getClass().getResource("/images/pdf_" + GuiClient.getVersionType() + "16.png");
        if (iconUrl == null) {
            iconUrl = this.getClass().getResource(DEFAULT_ICON);
        }
        if (iconUrl16 == null) {
            iconUrl16 = this.getClass().getResource(DEFAULT_ICON_16);
        }
        setIconImage(new ImageIcon(iconUrl).getImage());
        setTitle(GuiClient.getApplicationName() + " Ver. " + GuiClient.getVersion());

        // load plugins
        setSplashStep(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                "Loading plugins.."));
        PlugInsLoader pluginsLoader = new PlugInsLoader(Configuration.getInstance().getPluginAbsolutePath());
        pluginsMap = pluginsLoader.loadPlugins();

        // Info panel
        JInfoPanel infoPanel = new JInfoPanel(pluginsMap);
        PluginDataModel infoDataModel = new PluginDataModel(infoPanel.getPluginName(), infoPanel.getVersion(),
                infoPanel.getPluginAuthor(), infoPanel.getClass().getName());
        mainPanel.add(infoPanel, infoPanel.getPluginName());

        // Settings panel
        JSettingsPanel settingsPanel = new JSettingsPanel();
        PluginDataModel settingsDataModel = new PluginDataModel(settingsPanel.getPluginName(),
                settingsPanel.getVersion(), settingsPanel.getPluginAuthor(),
                settingsPanel.getClass().getName());
        mainPanel.add(settingsPanel, settingsPanel.getPluginName());

        // sets main panel
        mainPanel.setPreferredSize(new Dimension(670, 500));
        for (AbstractPlugablePanel instance : pluginsMap.values()) {
            mainPanel.add(instance, instance.getPluginName());
        }

        // status panel
        setSplashStep(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                "Building status bar.."));
        statusPanel = new JStatusPanel(new ImageIcon(iconUrl16), GuiClient.getApplicationName(),
                WorkDoneDataModel.MAX_PERGENTAGE);
        getContentPane().add(statusPanel, BorderLayout.PAGE_END);
        Configuration.getInstance().getConsoleServicesFacade().addExecutionObserver(statusPanel);

        // tree panel
        setSplashStep(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                "Building tree.."));
        treePanel = new JTreePanel(
                new DefaultMutableTreeNode(GuiClient.UNIXNAME + " " + GuiClient.getVersion()));
        for (PluginDataModel item : pluginsMap.keySet()) {
            treePanel.addToPlugsNode(item);
        }
        treePanel.addToRootNode(settingsDataModel);
        treePanel.addToRootNode(infoDataModel);
        treePanel.getTree().addTreeSelectionListener(new TreeMediator(this));
        treePanel.expand();

        // add info and settings to plugins map
        pluginsMap.put(settingsDataModel, settingsPanel);
        pluginsMap.put(infoDataModel, infoPanel);

        // menu
        setSplashStep(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                "Building menus.."));

        environment = new Environment(pluginsMap, treePanel);
        SaveEnvironmentAction saveAction = new SaveEnvironmentAction(environment, this);
        LoadEnvironmentAction loadAction = new LoadEnvironmentAction(environment, this);
        ApplicationExitMediator exitMediator = new ApplicationExitMediator(new ApplicationCloser(this));
        menuBar = new JMainMenuBar(saveAction, loadAction, exitMediator);
        getRootPane().setJMenuBar(menuBar);
        environment.addObserver(new EnvironmentLoadObserver());

        // buttons bar
        setSplashStep(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                "Building buttons bar.."));
        buttonsPanel = new JButtonsPanel(saveAction, loadAction, exitMediator, new LogActionListener());
        getContentPane().add(buttonsPanel, BorderLayout.PAGE_START);

        initializeUpdateChecker(settingsPanel);

        // final set up
        mainScrollPanel = new JScrollPane(mainPanel);
        mainScrollPanel.setMinimumSize(new Dimension(100, 400));

        logPanel = new JLogPanel();

        horizSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePanel, mainScrollPanel);
        horizSplitPane.setOneTouchExpandable(true);
        horizSplitPane.setDividerLocation(155);

        verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, horizSplitPane, logPanel);
        verticalSplitPane.setOneTouchExpandable(true);
        verticalSplitPane.setResizeWeight(1.0);
        verticalSplitPane.setDividerLocation(0.75);

        // load the default env if set
        String defaultEnvString = Configuration.getInstance().getDefaultEnvironment();
        if (defaultEnvString != null && defaultEnvString.length() > 0) {
            File defaultEnv = new File(defaultEnvString);
            if (defaultEnv != null && defaultEnv.exists() && defaultEnv.isFile()) {
                log.info(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                        "Loading default environment."));
                environment.loadJobs(defaultEnv);
            }
        }
        getContentPane().add(verticalSplitPane, BorderLayout.CENTER);

        setSize(640, 480);
        setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        addWindowListener(new MainWindowListener(this));

    } catch (Exception e) {
        log.fatal(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                "Error starting pdfsam."), e);
    }

}

From source file:org.jax.bham.test.PhylogenyAssociationTestGraphPanel.java

/**
 * a function to initialize the components for this panel
 */// w ww .  j  a  v a  2s .  c  om
private void initialize() {
    this.chromosomeComboBox.addItem("All Chromosomes");
    List<Integer> chromoList = SequenceUtilities
            .toIntegerList(this.testToPlot.getPhylogenyDataSource().getAvailableChromosomes());
    Collections.sort(chromoList);
    for (Integer chromoNum : chromoList) {
        this.chromosomeComboBox.addItem(chromoNum);
    }
    if (!chromoList.isEmpty()) {
        this.chromosomeComboBox.setSelectedIndex(1);
    }
    this.chromosomeComboBox.addItemListener(new ItemListener() {
        /**
         * {@inheritDoc}
         */
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                PhylogenyAssociationTestGraphPanel.this.chromosomeSelectionChanged();
            }
        }
    });

    JToolBar toolBar = new JToolBar();
    toolBar.add(new JLabel("Chromosome:"));

    // limit the size or the toolbar will try to make the drop-down huge
    this.chromosomeComboBox.setMaximumSize(this.chromosomeComboBox.getPreferredSize());
    toolBar.add(this.chromosomeComboBox);

    this.add(toolBar, BorderLayout.PAGE_START);

    this.add(this.chartPanel, BorderLayout.CENTER);

    this.chromosomeSelectionChanged();
}

From source file:eu.apenet.dpt.standalone.gui.dateconversion.DateConversionRulesDialog.java

private void createDataConversionRulesList() {
    Vector<String> columnNames = new Vector<String>();
    columnNames.add(labels.getString("dateConversion.valueRead"));
    columnNames.add(labels.getString("dateConversion.valueConverted"));
    dm = new DefaultTableModel(xmlFilehandler.loadDataFromFile(FILENAME), columnNames);
    dm.addRow(new Vector<String>());
    dm.addTableModelListener(new TableModelListener() {
        public void tableChanged(TableModelEvent e) {
            if (ruleTable.getEditingRow() != ruleTable.getRowCount() - 1
                    && (StringUtils.isEmpty((String) dm.getValueAt(ruleTable.getEditingRow(), 0))
                            && StringUtils.isEmpty((String) dm.getValueAt(ruleTable.getEditingRow(), 1)))) {
                dm.removeRow(ruleTable.getEditingRow());
            }/*from   w ww.j a  v  a  2s. co m*/
            if (ruleTable.getEditingRow() == ruleTable.getRowCount() - 1) {
                if (StringUtils.isNotEmpty((String) dm.getValueAt(ruleTable.getEditingRow(), 0))
                        && StringUtils.isNotEmpty((String) dm.getValueAt(ruleTable.getEditingRow(), 1))) {
                    dm.addRow(new Vector<String>());
                }
            }
            if (ruleTable.getEditingColumn() == 1) {
                if (StringUtils.isNotEmpty((String) dm.getValueAt(ruleTable.getEditingRow(), 1))
                        && !isCorrectDateFormat((String) dm.getValueAt(ruleTable.getEditingRow(), 1))) {
                    createOptionPaneForIsoDate(ruleTable.getEditingRow(), 1);
                }
            }
        }
    });

    ruleTable = new JTable(dm);
    oldModel = new DefaultTableModel(xmlFilehandler.loadDataFromFile(FILENAME), columnNames);

    JButton saveButton = new JButton(labels.getString("saveBtn"));
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (ruleTable.isEditing()) {
                ruleTable.getCellEditor().stopCellEditing();
            }
            Vector<Vector<String>> data = ((DefaultTableModel) ruleTable.getModel()).getDataVector();
            for (int i = 0; i < data.size() - 1; i++) {
                Vector<String> vector = data.elementAt(i);
                if (vector.elementAt(1) != null && !isCorrectDateFormat((String) vector.elementAt(1))) {
                    createOptionPaneForIsoDate(i, 1);
                }
            }
            xmlFilehandler.saveDataToFile(data, FILENAME);
            saveMessage.setText(MessageFormat.format(labels.getString("dateConversion.saveMsg"),
                    new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime())));
        }
    });

    JButton closeButton = new JButton(labels.getString("quit"));
    closeButton.addActionListener(new ActionListener() {
        // boolean cancel = true;

        public void actionPerformed(ActionEvent e) {
            /*System.out.println(Boolean.toString(oldModel.getRowCount() == (ruleTable.getModel().getRowCount() - 1)) + "<<" + oldModel.getRowCount() + ", " + (ruleTable.getModel().getRowCount() - 1));
            if (oldModel.getRowCount() != ruleTable.getModel().getRowCount() - 1) {
            cancel = showUnsavedChangesDialog();
            } else {
            for (int i = 0; i < (ruleTable.getModel().getRowCount() - 1); i++) {
                for (int j = 0; j <= 1; j++) {
                    System.out.println(oldModel.getValueAt(i, j) == ruleTable.getModel().getValueAt(i, j) + " >> " + oldModel.getValueAt(i, j) + ", " + ruleTable.getModel().getValueAt(i, j));
                    if (oldModel.getValueAt(i, j) != ruleTable.getModel().getValueAt(i, j)) {
                        cancel = showUnsavedChangesDialog();
                    }
                }
            }
            }
            if (cancel) {*/
            dispose();
            //  }
        }
    });

    JButton downloadButton = new JButton(labels.getString("downloadBtn"));
    downloadButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (ruleTable.isEditing()) {
                ruleTable.getCellEditor().stopCellEditing();
            }
            Vector<Vector<String>> data = ((DefaultTableModel) ruleTable.getModel()).getDataVector();
            File currentLocation = new File(retrieveFromDb.retrieveOpenLocation());
            JFileChooser fileChooser = new JFileChooser(currentLocation);
            fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
            fileChooser.setFileFilter(new FileNameExtensionFilter("XML file", "xml"));
            int returnedVal = fileChooser.showSaveDialog(getParent());

            if (returnedVal == JFileChooser.APPROVE_OPTION) {
                String fileName = fileChooser.getSelectedFile().toString();
                if (!fileName.endsWith(".xml")) {
                    fileName = fileName + ".xml";
                }
                xmlFilehandler.saveDataToFile(data, fileName);
                //additionally save data to standard file
                xmlFilehandler.saveDataToFile(data, FILENAME);
                saveMessage.setText(MessageFormat.format(labels.getString("dateConversion.saveMsg"),
                        new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime())));
            }
        }
    });

    JPanel contentPanel = new JPanel(new BorderLayout());
    contentPanel.add(new JScrollPane(ruleTable));
    saveMessage = new JLabel();
    contentPanel.add(saveMessage, BorderLayout.SOUTH);

    JPanel buttonPanel = new JPanel(new GridLayout(1, 3));
    buttonPanel.add(saveButton);
    buttonPanel.add(closeButton);
    buttonPanel.add(downloadButton);

    JPanel pane = new JPanel(new BorderLayout());
    pane.add(contentPanel, BorderLayout.PAGE_START);
    pane.add(buttonPanel, BorderLayout.PAGE_END);
    add(pane);
}

From source file:caarray.client.test.gui.GuiMain.java

public GuiMain() throws Exception {
    JFrame frame = new JFrame("API Test Suite");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.getContentPane().setLayout(new BorderLayout(6, 6));

    JPanel topPanel = new JPanel();

    /* ###### Text fields for modifiable parameters ##### */

    final JTextField javaHostText = new JTextField(TestProperties.getJavaServerHostname(), 20);
    JLabel javaHostLabel = new JLabel("Java Service Host");
    JButton save = new JButton("Save");
    save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            TestProperties.setJavaServerHostname(javaHostText.getText());
        }//from www .ja  va  2s .c o m

    });

    JLabel javaPortLabel = new JLabel("Java Port");
    final JTextField javaPortText = new JTextField(Integer.toString(TestProperties.getJavaServerJndiPort()), 5);
    JButton save2 = new JButton("Save");
    save2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                int port = Integer.parseInt(javaPortText.getText());
                TestProperties.setJavaServerJndiPort(port);
            } catch (NumberFormatException e) {
                System.out.println(javaPortText.getText() + " is not a valid port number.");
            }
        }

    });

    JLabel gridHostLabel = new JLabel("Grid Service Host");
    final JTextField gridHostText = new JTextField(TestProperties.getGridServerHostname(), 20);
    JButton save3 = new JButton("Save");
    save3.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            TestProperties.setGridServerHostname(gridHostText.getText());
        }

    });

    JLabel gridPortLabel = new JLabel("Grid Service Port");
    final JTextField gridPortText = new JTextField(Integer.toString(TestProperties.getGridServerPort()), 5);
    JButton save4 = new JButton("Save");
    save4.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            try {
                int port = Integer.parseInt(gridPortText.getText());
                TestProperties.setGridServerPort(port);
            } catch (NumberFormatException e) {
                System.out.println(gridPortText.getText() + " is not a valid port number.");
            }

        }

    });

    JLabel excludeLabel = new JLabel("Exclude test cases (comma-separated list):");
    final JTextField excludeText = new JTextField("", 30);
    JButton save5 = new JButton("Save");
    save5.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            String testString = excludeText.getText();
            if (testString != null) {
                String[] testCases = testString.split(",");
                if (testCases != null && testCases.length > 0) {
                    List<Float> tests = new ArrayList<Float>();
                    for (String test : testCases) {
                        try {
                            tests.add(Float.parseFloat(test));
                        } catch (NumberFormatException e) {
                            System.out.println(test + " is not a valid test case.");
                        }
                    }
                    TestProperties.setExcludedTests(tests);
                }

            }

        }

    });

    JLabel includeLabel = new JLabel("Include only (comma-separated list):");
    final JTextField includeText = new JTextField("", 30);
    JButton save6 = new JButton("Save");
    save6.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            String testString = includeText.getText();
            if (testString != null) {
                String[] testCases = testString.split(",");
                if (testCases != null && testCases.length > 0) {
                    List<Float> tests = new ArrayList<Float>();
                    for (String test : testCases) {
                        try {
                            tests.add(Float.parseFloat(test));
                        } catch (NumberFormatException e) {
                            System.out.println(test + " is not a valid test case.");
                        }
                    }
                    TestProperties.setIncludeOnlyTests(tests);
                }

            }

        }

    });

    JLabel threadLabel = new JLabel("Number of threads:");
    final JTextField threadText = new JTextField(Integer.toString(TestProperties.getNumThreads()), 5);
    JButton save7 = new JButton("Save");
    save7.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            try {
                int threads = Integer.parseInt(threadText.getText());
                TestProperties.setNumThreads(threads);
            } catch (NumberFormatException e) {
                System.out.println(threadText.getText() + " is not a valid thread number.");
            }

        }

    });
    GridBagLayout topLayout = new GridBagLayout();
    topPanel.setLayout(topLayout);

    JLabel[] labels = new JLabel[] { javaHostLabel, javaPortLabel, gridHostLabel, gridPortLabel, excludeLabel,
            includeLabel, threadLabel };
    JTextField[] textFields = new JTextField[] { javaHostText, javaPortText, gridHostText, gridPortText,
            excludeText, includeText, threadText };
    JButton[] buttons = new JButton[] { save, save2, save3, save4, save5, save6, save7 };
    for (int i = 0; i < labels.length; i++) {
        GridBagConstraints c = new GridBagConstraints();
        c.fill = GridBagConstraints.NONE;
        c.gridx = 0;
        c.gridy = i;
        topPanel.add(labels[i], c);
        c.gridx = 1;
        topPanel.add(textFields[i], c);
        c.gridx = 2;
        topPanel.add(buttons[i], c);
    }

    frame.getContentPane().add(topPanel, BorderLayout.PAGE_START);

    GridLayout bottomLayout = new GridLayout(0, 4);
    selectionPanel.setLayout(bottomLayout);
    JCheckBox selectAll = new JCheckBox("Select/Deselect All");
    selectAll.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JCheckBox box = (JCheckBox) e.getSource();
            selectAll(box.isSelected());
        }
    });
    selectionPanel.add(selectAll);
    JCheckBox excludeLongTests = new JCheckBox("Exclude Long Tests");
    excludeLongTests.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JCheckBox box = (JCheckBox) e.getSource();
            if (box.isSelected()) {
                TestProperties.excludeLongTests();
            } else {
                TestProperties.removeExcludedLongTests();
            }
        }
    });
    TestProperties.excludeLongTests();
    excludeLongTests.setSelected(true);
    selectionPanel.add(excludeLongTests);

    //Initialize check boxes corresponding to test categories
    initializeTests();

    centerPanel.setLayout(new GridLayout(0, 1));
    centerPanel.add(selectionPanel);

    //Redirect System messages to gui     
    JScrollPane textScroll = new JScrollPane();
    textScroll.setViewportView(textDisplay);
    System.setOut(new PrintStream(new JTextAreaOutputStream(textDisplay)));
    System.setErr(new PrintStream(new JTextAreaOutputStream(textDisplay)));
    centerPanel.add(textScroll);
    JScrollPane scroll = new JScrollPane(centerPanel);

    frame.getContentPane().add(scroll, BorderLayout.CENTER);

    JButton runButton = new JButton("Run Tests");
    runButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            try {

                runTests();

            } catch (Exception e) {
                System.out.println("An error occured executing the tests: " + e.getClass()
                        + ". Check error log for details.");
                log.error("Exception encountered:", e);
            }
        }

    });

    JPanel bottomPanel = new JPanel();
    bottomPanel.add(runButton);
    frame.getContentPane().add(bottomPanel, BorderLayout.PAGE_END);

    frame.pack();
    frame.setVisible(true);
}

From source file:org.zaproxy.zap.extension.fuzz.httpfuzzer.ui.HttpFuzzResultsContentPanel.java

public HttpFuzzResultsContentPanel() {
    super(new BorderLayout());

    tabbedPane = new JTabbedPane();

    toolbar = new JToolBar();
    toolbar.setFloatable(false);/*from  w w  w  .j  a v a 2  s .c o  m*/
    toolbar.setRollover(true);

    messageCountLabel = new JLabel(Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.messagesSent"));
    messageCountValueLabel = new JLabel("0");

    errorCountLabel = new JLabel(Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.errors"));
    errorCountValueLabel = new JLabel("0");

    showErrorsToggleButton = new ZapToggleButton(
            Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.showErrors.label"));
    showErrorsToggleButton.setEnabled(false);
    showErrorsToggleButton.setToolTipText(
            Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.showErrors.tooltip"));
    showErrorsToggleButton.setSelectedToolTipText(
            Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.showErrors.tooltip.selected"));
    showErrorsToggleButton.setDisabledToolTipText(
            Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.showErrors.tooltip.disabled"));
    showErrorsToggleButton
            .setIcon(new ImageIcon(HttpFuzzResultsContentPanel.class.getResource("/resource/icon/16/050.png")));
    showErrorsToggleButton.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (ItemEvent.SELECTED == e.getStateChange()) {
                showTabs();
            } else {
                hideErrorsTab();
            }
        }
    });

    toolbar.add(Box.createHorizontalStrut(4));
    toolbar.add(messageCountLabel);
    toolbar.add(Box.createHorizontalStrut(4));
    toolbar.add(messageCountValueLabel);
    toolbar.add(Box.createHorizontalStrut(32));

    toolbar.add(errorCountLabel);
    toolbar.add(Box.createHorizontalStrut(4));
    toolbar.add(errorCountValueLabel);

    toolbar.add(Box.createHorizontalStrut(16));
    toolbar.add(showErrorsToggleButton);

    JButton button = new JButton(Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.export"));
    button.setIcon(new ImageIcon(HttpFuzzResultsContentPanel.class.getResource("/resource/icon/16/115.png")));
    button.addActionListener((new AbstractAction() {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            WritableFileChooser chooser = new WritableFileChooser(
                    Model.getSingleton().getOptionsParam().getUserDirectory()) {

                private static final long serialVersionUID = -1660943014924270012L;

                @Override
                public void approveSelection() {
                    File file = getSelectedFile();
                    if (file != null) {
                        String filePath = file.getAbsolutePath();
                        if (!filePath.toLowerCase(Locale.ROOT).endsWith(CSV_EXTENSION)) {
                            setSelectedFile(new File(filePath + CSV_EXTENSION));
                        }
                    }

                    super.approveSelection();
                }
            };
            chooser.setSelectedFile(new File(
                    Constant.messages.getString("fuzz.httpfuzzer.results.toolbar.button.export.defaultName")));
            if (chooser
                    .showSaveDialog(View.getSingleton().getMainFrame()) == WritableFileChooser.APPROVE_OPTION) {

                boolean success = true;
                try (CSVPrinter pw = new CSVPrinter(
                        Files.newBufferedWriter(chooser.getSelectedFile().toPath(), StandardCharsets.UTF_8),
                        CSVFormat.DEFAULT)) {
                    pw.printRecord(currentFuzzer.getMessagesModel().getHeaders());
                    int count = currentFuzzer.getMessagesModel().getRowCount();
                    for (int i = 0; i < count; i++) {
                        List<Object> valueOfRow = currentFuzzer.getMessagesModel().getEntry(i)
                                .getValuesOfHeaders();
                        String customStateValue = fuzzResultTable.getCustomStateValue(
                                currentFuzzer.getMessagesModel().getEntry(i).getCustomStates());
                        valueOfRow.add(13, customStateValue);
                        pw.printRecord(valueOfRow);
                    }
                } catch (Exception ex) {
                    success = false;
                    JOptionPane.showMessageDialog(View.getSingleton().getMainFrame(),
                            Constant.messages
                                    .getString("fuzz.httpfuzzer.results.toolbar.button.export.showMessageError")
                                    + "\n" + ex.getLocalizedMessage());
                    logger.error("Export Failed: " + ex);
                }
                // Delay the presentation of success message, to ensure all the data was
                // already flushed.
                if (success) {
                    JOptionPane.showMessageDialog(View.getSingleton().getMainFrame(), Constant.messages
                            .getString("fuzz.httpfuzzer.results.toolbar.button.export.showMessageSuccessful"));
                }
            }
        }
    }));
    toolbar.add(Box.createHorizontalGlue());
    toolbar.add(button);
    mainPanel = new JPanel(new BorderLayout());

    fuzzResultTable = new HttpFuzzerResultsTable(RESULTS_PANEL_NAME, EMPTY_RESULTS_MODEL);
    errorsTable = new HttpFuzzerErrorsTable(ERRORS_PANEL_NAME, EMPTY_ERRORS_MODEL);

    fuzzResultTableScrollPane = new JScrollPane();
    fuzzResultTableScrollPane.setViewportView(fuzzResultTable);

    errorsTableScrollPane = new JScrollPane();
    errorsTableScrollPane.setViewportView(errorsTable);

    mainPanel.add(fuzzResultTableScrollPane);

    add(toolbar, BorderLayout.PAGE_START);
    add(mainPanel, BorderLayout.CENTER);
}

From source file:com.openbravo.pos.epm.JEmployeeFinder.java

/** This method is called from within the constructor to
 * initialize the form./*from  w  w w. jav a 2s  .c om*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jPanel2 = new javax.swing.JPanel();
    m_jKeys = new com.openbravo.editor.JEditorKeys();
    jPanel3 = new javax.swing.JPanel();
    jPanel5 = new javax.swing.JPanel();
    jPanel7 = new javax.swing.JPanel();
    jLabel5 = new javax.swing.JLabel();
    m_jtxtName = new com.openbravo.editor.JEditorString();
    jPanel6 = new javax.swing.JPanel();
    jButton1 = new javax.swing.JButton();
    jButton3 = new javax.swing.JButton();
    jPanel4 = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jListEmployees = new javax.swing.JList();
    jPanel8 = new javax.swing.JPanel();
    jPanel1 = new javax.swing.JPanel();
    jcmdOK = new javax.swing.JButton();
    jcmdCancel = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle(AppLocal.getIntString("form.customertitle")); // NOI18N

    jPanel2.setLayout(new java.awt.BorderLayout());
    jPanel2.add(m_jKeys, java.awt.BorderLayout.NORTH);

    getContentPane().add(jPanel2, java.awt.BorderLayout.LINE_END);

    jPanel3.setLayout(new java.awt.BorderLayout());

    jPanel5.setLayout(new java.awt.BorderLayout());

    jLabel5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jLabel5.setText(AppLocal.getIntString("label.epm.employee")); // NOI18N

    m_jtxtName.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

    javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
    jPanel7.setLayout(jPanel7Layout);
    jPanel7Layout.setHorizontalGroup(jPanel7Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup().addContainerGap()
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 126,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18).addComponent(m_jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, 220,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(15, Short.MAX_VALUE)));
    jPanel7Layout.setVerticalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup().addContainerGap()
                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 25,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(m_jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, 25,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    jPanel5.add(jPanel7, java.awt.BorderLayout.CENTER);

    jButton1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/reload.png"))); // NOI18N
    jButton1.setText(AppLocal.getIntString("button.clean")); // NOI18N
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });
    jPanel6.add(jButton1);

    jButton3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/ok.png"))); // NOI18N
    jButton3.setText(AppLocal.getIntString("button.executefilter")); // NOI18N
    jButton3.setFocusPainted(false);
    jButton3.setFocusable(false);
    jButton3.setRequestFocusEnabled(false);
    jButton3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton3ActionPerformed(evt);
        }
    });
    jPanel6.add(jButton3);

    jPanel5.add(jPanel6, java.awt.BorderLayout.SOUTH);

    jPanel3.add(jPanel5, java.awt.BorderLayout.PAGE_START);

    jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    jPanel4.setLayout(new java.awt.BorderLayout());

    jListEmployees.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jListEmployees.setFocusable(false);
    jListEmployees.setRequestFocusEnabled(false);
    jListEmployees.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jListEmployeesMouseClicked(evt);
        }
    });
    jListEmployees.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
        public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
            jListEmployeesValueChanged(evt);
        }
    });
    jScrollPane1.setViewportView(jListEmployees);

    jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER);

    jPanel3.add(jPanel4, java.awt.BorderLayout.CENTER);

    jPanel8.setLayout(new java.awt.BorderLayout());

    jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/ok.png"))); // NOI18N
    jcmdOK.setText(AppLocal.getIntString("Button.OK")); // NOI18N
    jcmdOK.setEnabled(false);
    jcmdOK.setFocusPainted(false);
    jcmdOK.setFocusable(false);
    jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16));
    jcmdOK.setRequestFocusEnabled(false);
    jcmdOK.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jcmdOKActionPerformed(evt);
        }
    });
    jPanel1.add(jcmdOK);

    jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/cancel.png"))); // NOI18N
    jcmdCancel.setText(AppLocal.getIntString("Button.Cancel")); // NOI18N
    jcmdCancel.setFocusPainted(false);
    jcmdCancel.setFocusable(false);
    jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16));
    jcmdCancel.setRequestFocusEnabled(false);
    jcmdCancel.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jcmdCancelActionPerformed(evt);
        }
    });
    jPanel1.add(jcmdCancel);

    jPanel8.add(jPanel1, java.awt.BorderLayout.LINE_END);

    jPanel3.add(jPanel8, java.awt.BorderLayout.SOUTH);

    getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER);

    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 613) / 2, (screenSize.height - 495) / 2, 613, 495);
}

From source file:DialogDemo.java

/**
 * Used by createSimpleDialogBox and createFeatureDialogBox to create a pane
 * containing a description, a single column of radio buttons, and the Show
 * it! button.//from www .  j  av a2  s  .  com
 */
private JPanel createPane(String description, JRadioButton[] radioButtons, JButton showButton) {

    int numChoices = radioButtons.length;
    JPanel box = new JPanel();
    JLabel label = new JLabel(description);

    box.setLayout(new BoxLayout(box, BoxLayout.PAGE_AXIS));
    box.add(label);

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

    JPanel pane = new JPanel(new BorderLayout());
    pane.add(box, BorderLayout.PAGE_START);
    pane.add(showButton, BorderLayout.PAGE_END);
    return pane;
}

From source file:e3fraud.gui.MainWindow.java

public MainWindow() {
    super(new BorderLayout(5, 5));

    extended = false;//  w  w  w  .  j  a v  a2 s .c  om

    //Create the log first, because the action listeners
    //need to refer to it.
    log = new JTextArea(10, 50);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setEditable(false);
    logScrollPane = new JScrollPane(log);
    DefaultCaret caret = (DefaultCaret) log.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    //        create the progress bar
    progressBar = new JProgressBar(0, 100);
    progressBar.setValue(progressBar.getMinimum());
    progressBar.setVisible(false);
    progressBar.setStringPainted(true);
    //Create the settings pane
    generationSettingLabel = new JLabel("Generate:");
    SpinnerModel collusionsSpinnerModel = new SpinnerNumberModel(1, 0, 3, 1);
    collusionSettingsPanel = new JPanel(new FlowLayout()) {
        @Override
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    // collusionSettingsPanel.setLayout(new BoxLayout(collusionSettingsPanel, BoxLayout.X_AXIS));
    collusionsButton = new JSpinner(collusionsSpinnerModel);
    collusionsLabel = new JLabel("collusion(s)");
    collusionSettingsPanel.add(collusionsButton);
    collusionSettingsPanel.add(collusionsLabel);

    rankingSettingLabel = new JLabel("Rank by:");
    lossButton = new JRadioButton("loss");
    lossButton.setToolTipText("Sort sub-ideal models based on loss for Target of Assessment (high -> low)");
    gainButton = new JRadioButton("gain");
    gainButton.setToolTipText(
            "Sort sub-ideal models based on gain of any actor except Target of Assessment (high -> low)");
    lossGainButton = new JRadioButton("loss + gain");
    lossGainButton.setToolTipText(
            "Sort sub-ideal models based on loss for Target of Assessment and, if equal, on gain of any actor except Target of Assessment");
    //gainLossButton = new JRadioButton("gain + loss");
    lossGainButton.setSelected(true);
    rankingGroup = new ButtonGroup();
    rankingGroup.add(lossButton);
    rankingGroup.add(gainButton);
    rankingGroup.add(lossGainButton);
    //rankingGroup.add(gainLossButton);
    groupingSettingLabel = new JLabel("Group by:");
    groupingButton = new JCheckBox("collusion");
    groupingButton.setToolTipText(
            "Groups sub-ideal models based on the pair of actors colluding before ranking them");
    groupingButton.setSelected(false);
    refreshButton = new JButton("Refresh");
    refreshButton.addActionListener(this);

    settingsPanel = new JPanel();
    settingsPanel.setLayout(new BoxLayout(settingsPanel, BoxLayout.PAGE_AXIS));
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(generationSettingLabel);
    collusionSettingsPanel.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(collusionSettingsPanel);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    rankingSettingLabel.setAlignmentY(TOP_ALIGNMENT);
    settingsPanel.add(rankingSettingLabel);
    settingsPanel.add(lossButton);
    settingsPanel.add(gainButton);
    settingsPanel.add(lossGainButton);
    //settingsPanel.add(gainLossButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(groupingSettingLabel);
    settingsPanel.add(groupingButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(refreshButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 20)));
    progressBar.setPreferredSize(
            new Dimension(settingsPanel.getSize().width, progressBar.getPreferredSize().height));
    settingsPanel.add(progressBar);

    //Create the result tree
    root = new DefaultMutableTreeNode("No models to display");
    treeModel = new DefaultTreeModel(root);
    tree = new JTree(treeModel);
    //tree.setUI(new CustomTreeUI());
    tree.setCellRenderer(new CustomTreeCellRenderer(tree));
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setLargeModel(true);
    resultScrollPane = new JScrollPane(tree);
    tree.addTreeSelectionListener(treeSelectionListener);

    //tree.setShowsRootHandles(true);
    //Create a file chooser for saving
    sfc = new JFileChooser();
    FileFilter jpegFilter = new FileNameExtensionFilter("JPEG image", new String[] { "jpg", "jpeg" });
    sfc.addChoosableFileFilter(jpegFilter);
    sfc.setFileFilter(jpegFilter);

    //Create a file chooser for loading
    fc = new JFileChooser();
    FileFilter rdfFilter = new FileNameExtensionFilter("RDF file", "RDF");
    fc.addChoosableFileFilter(rdfFilter);
    fc.setFileFilter(rdfFilter);

    //Create the open button.  
    openButton = new JButton("Load model", createImageIcon("images/Open24.png"));
    openButton.addActionListener(this);
    openButton.setToolTipText("Load a e3value model");

    //Create the ideal graph button. 
    idealGraphButton = new JButton("Show ideal graph", createImageIcon("images/Plot.png"));
    idealGraphButton.setToolTipText("Display ideal profitability graph");
    idealGraphButton.addActionListener(this);

    Dimension thinButtonDimension = new Dimension(15, 420);

    //Create the expand subideal graph button. 
    expandButton = new JButton(">");
    expandButton.setPreferredSize(thinButtonDimension);
    expandButton.setMargin(new Insets(0, 0, 0, 0));
    expandButton.setToolTipText("Expand to show non-ideal profitability graph for selected model");
    expandButton.addActionListener(this);

    //Create the collapse sub-ideal graph button. 
    collapseButton = new JButton("<");
    collapseButton.setPreferredSize(thinButtonDimension);
    collapseButton.setMargin(new Insets(0, 0, 0, 0));
    collapseButton.setToolTipText("Collapse non-ideal profitability graph for selected model");
    collapseButton.addActionListener(this);

    //Create the generation button. 
    generateButton = new JButton("Generate sub-ideal models", createImageIcon("images/generate.png"));
    generateButton.addActionListener(this);
    generateButton.setToolTipText("Generate sub-ideal models for the e3value model currently loaded");

    //Create the chart panel
    chartPane = new JPanel();
    chartPane.setLayout(new FlowLayout(FlowLayout.LEFT));
    chartPane.add(expandButton);

    //For layout purposes, put the buttons in a separate panel
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(openButton);
    buttonPanel.add(Box.createRigidArea(new Dimension(20, 0)));
    buttonPanel.add(generateButton);
    buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
    buttonPanel.add(idealGraphButton);

    //Add the buttons, the ranking options, the result list and the log to this panel.
    add(buttonPanel, BorderLayout.PAGE_START);
    add(settingsPanel, BorderLayout.LINE_START);
    add(resultScrollPane, BorderLayout.CENTER);

    add(logScrollPane, BorderLayout.PAGE_END);
    add(chartPane, BorderLayout.LINE_END);
    //and make a nice border around it
    setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10));
}