Example usage for java.awt GridBagConstraints BOTH

List of usage examples for java.awt GridBagConstraints BOTH

Introduction

In this page you can find the example usage for java.awt GridBagConstraints BOTH.

Prototype

int BOTH

To view the source code for java.awt GridBagConstraints BOTH.

Click Source Link

Document

Resize the component both horizontally and vertically.

Usage

From source file:org.openconcerto.erp.core.finance.accounting.ui.PlanComptableGPanel.java

private void uiInit() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();

    this.setOpaque(false);
    this.panelCompte.setOpaque(false);
    this.panelInfosCompte.setOpaque(false);
    this.panelDetails.setOpaque(false);

    this.panelCompte.setLayout(new GridBagLayout());
    this.panelInfosCompte.setLayout(new GridBagLayout());
    this.panelDetails.setLayout(new GridBagLayout());

    /*******************************************************************************************
     * * RadioButton Selection du mode d'affichage du PCG abrege, base ou developp Panel
     * Details//from w  ww  .j  a v a  2  s  . com
     ******************************************************************************************/
    this.panelDetails.add(this.radioCompteBase, c);
    this.radioCompteBase.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateCompteTable();
        }
    });

    c.gridy++;
    this.panelDetails.add(this.radioCompteAbrege, c);
    this.radioCompteAbrege.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateCompteTable();
        }
    });

    c.gridy++;
    this.panelDetails.add(this.radioCompteDeveloppe, c);
    this.radioCompteDeveloppe.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateCompteTable();
        }

    });

    ButtonGroup grp1 = new ButtonGroup();
    grp1.add(this.radioCompteBase);
    grp1.add(this.radioCompteAbrege);
    grp1.add(this.radioCompteDeveloppe);

    this.radioCompteBase.setSelected(true);

    /*******************************************************************************************
     * ** Panel Compte
     ******************************************************************************************/
    c.insets = new Insets(2, 2, 1, 2);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0;
    c.weighty = 0;
    this.panelDetails.setBorder(BorderFactory.createTitledBorder("Dtails"));
    this.panelCompte.add(this.panelDetails, c);

    /*******************************************************************************************
     * * Affichage du plan comptable
     ******************************************************************************************/
    SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
    SQLTable classeCompteTable = base.getTable("CLASSE_COMPTE");

    SQLSelect selClasse = new SQLSelect(base);

    selClasse.addSelect(classeCompteTable.getField("ID"));
    selClasse.addSelect(classeCompteTable.getField("NOM"));
    selClasse.addSelect(classeCompteTable.getField("TYPE_NUMERO_COMPTE"));

    selClasse.addRawOrder("\"CLASSE_COMPTE\".\"TYPE_NUMERO_COMPTE\"");

    String reqClasse = selClasse.asString();
    Object obClasse = base.getDataSource().execute(reqClasse, new ArrayListHandler());

    List myListClasse = (List) obClasse;

    if (myListClasse.size() != 0) {
        for (int k = 0; k < myListClasse.size(); k++) {
            Object[] objTmp = (Object[]) myListClasse.get(k);
            ClasseCompte ccTmp = new ClasseCompte(Integer.parseInt(objTmp[0].toString()), objTmp[1].toString(),
                    objTmp[2].toString());
            this.classeComptes.add(ccTmp);

            JTable tab = creerJTable(ccTmp);
            this.tables.add(tab);
            this.tabbedClasse.add(ccTmp.getNom(), new JScrollPane(tab));
        }
    }
    c.gridwidth = 4;
    c.gridheight = 6;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 1;
    c.gridx++;
    c.gridy = 0;
    this.panelCompte.add(this.tabbedClasse, c);

    /*******************************************************************************************
     * * Informations sur le compte selectionn Panel Infos Compte
     ******************************************************************************************/
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridheight = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1;
    c.weighty = 0;
    c.gridy = 0;
    c.gridx = 0;
    TitledSeparator sep = new TitledSeparator("Informations sur le compte");
    this.panelInfosCompte.add(sep, c);

    GridBagConstraints cInfos = new GridBagConstraints();
    cInfos.insets = new Insets(0, 0, 0, 0);
    cInfos.fill = GridBagConstraints.BOTH;
    cInfos.anchor = GridBagConstraints.NORTHWEST;
    cInfos.gridx = 0;
    cInfos.gridy = 0;
    cInfos.gridwidth = 1;
    cInfos.gridheight = 1;
    cInfos.weightx = 1;
    cInfos.weighty = 1;
    this.textInfos.setFont(this.getFont());
    this.textInfos.setEditable(false);
    JPanel infos = new JPanel(new GridBagLayout());
    infos.add(this.textInfos, cInfos);

    JScrollPane scrollInfos = new JScrollPane(infos);
    c.insets = new Insets(0, 0, 0, 0);
    c.gridx = 0;
    c.gridy++;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = GridBagConstraints.REMAINDER;

    this.panelInfosCompte.add(scrollInfos, c);
    this.panelInfosCompte.setMinimumSize(new Dimension(100, 80));

    JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, this.panelCompte, this.panelInfosCompte);
    split.setBorder(null);
    this.add(split, c);
}

From source file:org.keyboardplaying.xtt.ui.UIController.java

/** Builds and shows the settings window. */
public void showSettingsWindow() {
    /* Create UI. */
    JPanel pane = new JPanel(new GridBagLayout());

    /* Arrange the components */
    GridBagConstraints c;/*from  ww w. ja v a 2  s  . c  o m*/

    // project directory (text)
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.BOTH;
    pane.add(new ProjectTextFieldChooser(location), c);

    // project directory (button)
    c = new GridBagConstraints();
    c.gridx = 2;
    c.gridy = 0;
    c.fill = GridBagConstraints.BOTH;
    pane.add(new ProjectButtonChooser(images, i18n, location), c);

    // Locale (icon)
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 1;
    c.fill = GridBagConstraints.BOTH;
    pane.add(new JLabel(new ImageIcon(images.getImage("image-prefs-locale", ImageSize.W_16))), c);

    // Locale (combo)
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.BOTH;
    pane.add(new LocaleComboBox(i18n), c);

    // Clear preferences
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.BOTH;
    pane.add(makeActionButton("action.prefs.clear", "action-clear-prefs", ImageSize.W_16, clearPrefsAction), c);

    makeWindow("app.settings", "icon-settings", pane).setVisible(true);
}

From source file:FontChooser.java

private void createUserInterface() {
    final JPanel content = new JPanel(new GridBagLayout());
    final GridBagConstraints gbc = new GridBagConstraints();

    setContentPane(content);//from w w w  .  j a  v  a2  s  .  com
    content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.fill = GridBagConstraints.HORIZONTAL;

    gbc.gridx = gbc.gridy = 0;
    content.add(new JLabel("Font"), gbc);

    ++gbc.gridx;
    content.add(new JLabel("Size"), gbc);

    if (_selectStyles) {
        ++gbc.gridx;
        content.add(new JLabel("Style"), gbc);
    }

    ++gbc.gridy;
    gbc.gridx = 0;
    _fontNamesCmb = new JComboBox(
            GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
    content.add(_fontNamesCmb, gbc);

    ++gbc.gridx;
    _fontSizesCmb.setEditable(true);
    content.add(_fontSizesCmb, gbc);

    if (_selectStyles) {
        ++gbc.gridx;
        content.add(_boldChk, gbc);
        ++gbc.gridy;
        content.add(_italicChk, gbc);
    }

    gbc.gridx = 0;
    ++gbc.gridy;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.CENTER;
    content.add(createPreviewPanel(), gbc);

    ++gbc.gridy;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    content.add(createButtonsPanel(), gbc);

    pack();
    setResizable(true);
}

From source file:com.sec.ose.osi.ui.frm.main.report.JPanExportReport.java

private JPanel getJPanelDocumentExportInfo() {
    if (jPanelDocumentExportInfo == null) {
        jPanelDocumentExportInfo = new JPanel();
        jPanelDocumentExportInfo.setLayout(new GridBagLayout());

        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.fill = GridBagConstraints.BOTH;
        gridBagConstraints1.gridx = 0;/*  w ww  .j  a v a  2  s. co m*/
        gridBagConstraints1.gridy = 0;
        gridBagConstraints1.weightx = 1.0;
        gridBagConstraints1.insets = new Insets(0, 5, 0, 5);
        jPanelDocumentExportInfo.add(getJTextFieldReportLocation(), gridBagConstraints1);

        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.gridx = 1;
        gridBagConstraints2.gridy = 0;
        jPanelDocumentExportInfo.add(getJButtonCreateExplorer(), gridBagConstraints2);
    }
    return jPanelDocumentExportInfo;
}

From source file:me.childintime.childintime.ui.window.tool.BmiToolDialog.java

private JPanel buildUiBodyStatePanel() {
    // Create a grid bag constraints configuration
    GridBagConstraints c = new GridBagConstraints();

    // Body state panel
    final JPanel bodyStatePanel = new JPanel(new GridBagLayout());
    bodyStatePanel.setBorder(new CompoundBorder(BorderFactory.createTitledBorder("BMI tool"),
            BorderFactory.createEmptyBorder(8, 8, 8, 8)));

    // Add the student panel to the body state panel
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;// w w  w . j ava  2s . co m
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridheight = 2;
    c.insets = new Insets(0, 0, 0, 0);
    c.anchor = GridBagConstraints.CENTER;
    bodyStatePanel.add(buildUiStudentPanel(), c);

    // Add the input panel to the body state panel
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridheight = 1;
    c.insets = new Insets(0, 16, 0, 0);
    c.anchor = GridBagConstraints.NORTH;
    bodyStatePanel.add(buildUiChartPanel(), c);

    // Add the input panel to the body state panel
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 1;
    c.gridy = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.gridheight = 1;
    c.insets = new Insets(32, 16, 0, 0);
    c.anchor = GridBagConstraints.CENTER;
    bodyStatePanel.add(buildUiStudentBodyStatesPanel(), c);

    // Return the body state panel
    return bodyStatePanel;
}

From source file:com.intel.stl.ui.main.view.StaDetailsPanel.java

/**
 * Description:/*ww  w  .j a  va  2s .c  o  m*/
 * 
 * @param sourceName
 */
protected void initComponent() {
    setLayout(new BorderLayout(0, 10));
    setOpaque(false);
    setBorder(BorderFactory.createTitledBorder((Border) null));

    JPanel titlePanel = new JPanel(new BorderLayout(5, 1));
    titlePanel.setOpaque(false);
    numberLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN);
    numberLabel.setHorizontalAlignment(JLabel.RIGHT);
    titlePanel.add(numberLabel, BorderLayout.CENTER);
    nameLabel = ComponentFactory.getH3Label("", Font.PLAIN);
    nameLabel.setHorizontalAlignment(JLabel.LEFT);
    nameLabel.setVerticalAlignment(JLabel.BOTTOM);
    titlePanel.add(nameLabel, BorderLayout.EAST);
    add(titlePanel, BorderLayout.NORTH);

    JPanel mainPanel = new JPanel();
    mainPanel.setOpaque(false);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
    GridBagLayout gridBag = new GridBagLayout();
    mainPanel.setLayout(gridBag);
    GridBagConstraints gc = new GridBagConstraints();

    gc.insets = new Insets(2, 2, 2, 2);
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.weightx = 1;
    gc.gridwidth = 1;
    gc.weighty = 0;
    failedChartPanel = new ChartPanel(null);
    failedChartPanel.setPreferredSize(new Dimension(60, 20));
    mainPanel.add(failedChartPanel, gc);

    gc.fill = GridBagConstraints.BOTH;
    gc.weightx = 0;
    failedNumberLabel = ComponentFactory.getH2Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.BOLD);
    failedNumberLabel.setForeground(UIConstants.INTEL_DARK_RED);
    failedNumberLabel.setHorizontalAlignment(JLabel.CENTER);
    mainPanel.add(failedNumberLabel, gc);

    gc.gridwidth = GridBagConstraints.REMAINDER;
    failedNameLabel = ComponentFactory.getH5Label(STLConstants.K0020_FAILED.getValue(), Font.PLAIN);
    failedNameLabel.setVerticalAlignment(JLabel.BOTTOM);
    mainPanel.add(failedNameLabel, gc);

    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.weightx = 1;
    gc.gridwidth = 1;
    skippedChartPanel = new ChartPanel(null);
    skippedChartPanel.setPreferredSize(new Dimension(60, 20));
    mainPanel.add(skippedChartPanel, gc);

    gc.fill = GridBagConstraints.BOTH;
    gc.weightx = 0;
    skippedNumberLabel = ComponentFactory.getH2Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.BOLD);
    skippedNumberLabel.setForeground(UIConstants.INTEL_DARK_ORANGE);
    skippedNumberLabel.setHorizontalAlignment(JLabel.CENTER);
    mainPanel.add(skippedNumberLabel, gc);

    gc.gridwidth = GridBagConstraints.REMAINDER;
    skippedNameLabel = ComponentFactory.getH5Label(STLConstants.K0021_SKIPPED.getValue(), Font.PLAIN);
    skippedNameLabel.setVerticalAlignment(JLabel.BOTTOM);
    mainPanel.add(skippedNameLabel, gc);

    gc.weighty = 0;
    gc.fill = GridBagConstraints.NONE;
    gc.insets = new Insets(8, 2, 2, 2);
    gc.weightx = 1;
    gc.gridwidth = 1;
    gc.gridheight = types.length;
    typeChartPanel = new ChartPanel(null);
    typeChartPanel.setPreferredSize(new Dimension(80, 60));
    mainPanel.add(typeChartPanel, gc);

    typeNumberLabels = new JLabel[types.length];
    typeNameLabels = new JLabel[types.length];
    gc.fill = GridBagConstraints.BOTH;
    gc.gridheight = 1;
    gc.insets = new Insets(12, 2, 2, 2);
    for (int i = 0; i < types.length; i++) {
        if (i == 1) {
            gc.insets = new Insets(2, 2, 2, 2);
        }

        gc.weightx = 0;
        gc.gridwidth = 1;
        typeNumberLabels[i] = createNumberLabel();
        mainPanel.add(typeNumberLabels[i], gc);

        gc.gridwidth = GridBagConstraints.REMAINDER;
        typeNameLabels[i] = createNameLabel(types[i].getName());
        mainPanel.add(typeNameLabels[i], gc);
    }

    gc.fill = GridBagConstraints.BOTH;
    mainPanel.add(Box.createGlue(), gc);

    add(mainPanel, BorderLayout.CENTER);
}

From source file:com.xtructure.xevolution.gui.XEvolutionGui.java

/**
 * Creates a new {@link XEvolutionGui}./*from w  ww.  j av  a  2  s .  c o  m*/
 * 
 * @param title
 *            the base string for the title of the gui
 * @param visualizeData
 *            the visualize data
 * @param dataTracker
 *            the data tracker
 */
public XEvolutionGui(String title, VisualizeData visualizeData, DataTracker<?, ?> dataTracker) {
    this.title = title;
    frame = new JFrame(title);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    populationFiles = new ArrayList<File>();
    menuBar = new MenuBar(this, frame, title);
    frame.setJMenuBar(menuBar);
    tabbedPane = new JTabbedPane();
    tabbedPane.setPreferredSize(new Dimension(600, 400));
    frame.getContentPane().add(tabbedPane);
    statusBar = new StatusBar();
    frame.add(statusBar, BorderLayout.PAGE_END);
    graphPanel = new JPanel();
    graphPanel.setLayout(new GridLayout(0, 1));
    bufferSize = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();
    bufferCount = 3; // max,avg,min
    graphsMap = new HashMap<XValId<?>, Graph>();
    tabbedPane.addTab("Graphs", graphPanel);
    generationsPanel = new JPanel();
    generationsPanel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 0.5;
    c.weighty = 0.5;
    populationPanel = new PopulationPanel(popLock);
    genomePanel = new GenomePanel();
    genomePanel.addSortByAttributeId(Genome.FITNESS_ATTRIBUTE_ID);
    genomePanel.addSortByAttributeId(Genome.COMPLEXITY_ATTRIBUTE_ID);
    genomePanel.getSortComboBox().setSelectedItem(Genome.FITNESS_ATTRIBUTE_ID);
    c.gridx = 0;
    c.gridy = 0;
    generationsPanel.add(populationPanel, c);
    c.gridx = 1;
    c.gridy = 0;
    generationsPanel.add(genomePanel, c);
    tabbedPane.addTab("Generations", generationsPanel);
    genealogyPanel = new GenealogyPanel(dataTracker);
    tabbedPane.addTab("Genealogy", genealogyPanel);
    addGraph(Genome.FITNESS_ATTRIBUTE_ID);
    addGraph(Genome.COMPLEXITY_ATTRIBUTE_ID);
    this.dataTracker = dataTracker;
    new GuiListener(populationPanel, genomePanel, genealogyPanel, visualizeData, dataTracker);
    frame.setResizable(true);
    frame.pack();
    frame.setVisible(true);
    catchUp();
}

From source file:com.digitalgeneralists.assurance.ui.MainWindow.java

private void initializeComponent() {
    if (!this.initialized) {
        logger.info("Initializing the main window.");

        if (AssuranceUtils.getPlatform() == Platform.MAC) {

            System.setProperty("apple.laf.useScreenMenuBar", "true");
            com.apple.eawt.Application macApplication = com.apple.eawt.Application.getApplication();
            MacApplicationAdapter macAdapter = new MacApplicationAdapter(this);
            macApplication.addApplicationListener(macAdapter);
            macApplication.setEnabledPreferencesMenu(true);
        }//from  ww  w.ja v  a 2s.co  m

        this.setTitle(Application.applicationShortName);

        this.setDefaultCloseOperation(EXIT_ON_CLOSE);

        GridBagLayout gridbag = new GridBagLayout();
        this.setLayout(gridbag);

        this.topArea = new JTabbedPane();

        this.scanLaunchPanel.setPreferredSize(new Dimension(600, 150));

        this.scanHistoryPanel.setPreferredSize(new Dimension(600, 150));

        this.topArea.addTab("Scan", this.scanLaunchPanel);

        this.topArea.addTab("History", this.scanHistoryPanel);

        this.resultsPanel.setPreferredSize(new Dimension(600, 400));

        this.topArea.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                resultsPanel.resetPanel();
                // NOTE:  This isn't ideal.  It feels brittle.
                if (topArea.getSelectedIndex() == viewHistoryMenuItemIndex) {
                    viewHistoryMenuItem.setSelected(true);
                } else {
                    viewScanMenuItem.setSelected(true);
                }
            }
        });

        GridBagConstraints topPanelConstraints = new GridBagConstraints();
        topPanelConstraints.anchor = GridBagConstraints.NORTH;
        topPanelConstraints.fill = GridBagConstraints.BOTH;
        topPanelConstraints.gridx = 0;
        topPanelConstraints.gridy = 0;
        topPanelConstraints.weightx = 1.0;
        topPanelConstraints.weighty = 0.33;
        topPanelConstraints.gridheight = 1;
        topPanelConstraints.gridwidth = 1;
        topPanelConstraints.insets = new Insets(0, 0, 0, 0);

        this.getContentPane().add(this.topArea, topPanelConstraints);

        GridBagConstraints resultsPanelConstraints = new GridBagConstraints();
        resultsPanelConstraints.anchor = GridBagConstraints.SOUTH;
        resultsPanelConstraints.fill = GridBagConstraints.BOTH;
        resultsPanelConstraints.gridx = 0;
        resultsPanelConstraints.gridy = 1;
        resultsPanelConstraints.weightx = 1.0;
        resultsPanelConstraints.weighty = 0.67;
        resultsPanelConstraints.gridheight = 1;
        resultsPanelConstraints.gridwidth = 1;
        resultsPanelConstraints.insets = new Insets(0, 0, 0, 0);

        this.getContentPane().add(this.resultsPanel, resultsPanelConstraints);

        this.applicationDelegate.addEventObserver(ScanStartedEvent.class, this);
        this.applicationDelegate.addEventObserver(ScanCompletedEvent.class, this);
        this.applicationDelegate.addEventObserver(SetScanDefinitionMenuStateEvent.class, this);
        this.applicationDelegate.addEventObserver(SetScanResultsMenuStateEvent.class, this);
        this.applicationDelegate.addEventObserver(ApplicationConfigurationLoadedEvent.class, this);

        JMenu menu;
        JMenuItem menuItem;

        menuBar = new JMenuBar();

        StringBuilder accessiblityLabel = new StringBuilder(128);
        if (AssuranceUtils.getPlatform() != Platform.MAC) {
            menu = new JMenu(Application.applicationShortName);
            menu.getAccessibleContext().setAccessibleDescription(accessiblityLabel.append("Actions for ")
                    .append(Application.applicationShortName).append(" application").toString());
            accessiblityLabel.setLength(0);
            menuBar.add(menu);

            menuItem = new JMenuItem(MainWindow.quitApplicationMenuLabel, KeyEvent.VK_Q);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
            menuItem.getAccessibleContext().setAccessibleDescription(accessiblityLabel.append("Close the ")
                    .append(Application.applicationShortName).append(" application").toString());
            accessiblityLabel.setLength(0);
            menuItem.addActionListener(this);
            menuItem.setActionCommand(AssuranceActions.quitApplicationAction);
            menu.add(menuItem);

            menu.addSeparator();

            menuItem = new JMenuItem(MainWindow.aboutApplicationMenuLabel);
            menuItem.getAccessibleContext().setAccessibleDescription(
                    accessiblityLabel.append("Display information about this version of ")
                            .append(Application.applicationShortName).append(".").toString());
            accessiblityLabel.setLength(0);
            menuItem.addActionListener(this);
            menuItem.setActionCommand(AssuranceActions.aboutApplicationAction);
            menu.add(menuItem);
        }

        menu = new JMenu("Scan");
        menu.setMnemonic(KeyEvent.VK_S);
        menu.getAccessibleContext().setAccessibleDescription("Actions for file scans");
        menuBar.add(menu);

        menuItem = new JMenuItem(MainWindow.newScanDefinitonMenuLabel, KeyEvent.VK_N);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext().setAccessibleDescription("Create a new scan definition");
        menuItem.addActionListener(this.scanLaunchPanel);
        menuItem.setActionCommand(AssuranceActions.newScanDefinitonAction);
        menu.add(menuItem);

        menuItem = new JMenuItem(MainWindow.deleteScanDefinitonMenuLabel, KeyEvent.VK_D);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext().setAccessibleDescription("Delete the selected scan definition");
        menuItem.addActionListener(this.scanLaunchPanel);
        menuItem.setActionCommand(AssuranceActions.deleteScanDefinitonAction);
        menu.add(menuItem);

        menu.addSeparator();

        menuItem = new JMenuItem(MainWindow.scanMenuLabel, KeyEvent.VK_S);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext()
                .setAccessibleDescription("Launch a scan using the selected scan definition");
        menuItem.addActionListener(this.scanLaunchPanel);
        menuItem.setActionCommand(AssuranceActions.scanAction);
        menu.add(menuItem);

        menuItem = new JMenuItem(MainWindow.scanAndMergeMenuLabel, KeyEvent.VK_M);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext().setAccessibleDescription(
                "Launch a scan using the selected scan definition and merge the results");
        menuItem.addActionListener(this.scanLaunchPanel);
        menuItem.setActionCommand(AssuranceActions.scanAndMergeAction);
        menu.add(menuItem);

        menu = new JMenu("Results");
        menu.setMnemonic(KeyEvent.VK_R);
        menu.getAccessibleContext().setAccessibleDescription("Actions for scan results");
        menuBar.add(menu);

        menuItem = new JMenuItem(MainWindow.replaceSourceMenuLabel, KeyEvent.VK_O);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext()
                .setAccessibleDescription("Replace the source file with the target file");
        menuItem.addActionListener(this.resultsPanel.getResultMenuListener());
        menuItem.setActionCommand(AssuranceActions.replaceSourceAction);
        menu.add(menuItem);

        menuItem = new JMenuItem(MainWindow.replaceTargetMenuLabel, KeyEvent.VK_T);
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK));
        menuItem.getAccessibleContext()
                .setAccessibleDescription("Replace the target file with the source file");
        menuItem.addActionListener(this.resultsPanel.getResultMenuListener());
        menuItem.setActionCommand(AssuranceActions.replaceTargetAction);
        menu.add(menuItem);

        menu.addSeparator();

        menuItem = new JMenuItem(MainWindow.sourceAttributesMenuLabel);
        menuItem.getAccessibleContext().setAccessibleDescription("View the source file attributes");
        menuItem.addActionListener(this.resultsPanel.getResultMenuListener());
        menuItem.setActionCommand(AssuranceActions.sourceAttributesAction);
        menu.add(menuItem);

        menuItem = new JMenuItem(MainWindow.targetAttributesMenuLabel);
        menuItem.getAccessibleContext().setAccessibleDescription("View the target file attributes");
        menuItem.addActionListener(this.resultsPanel.getResultMenuListener());
        menuItem.setActionCommand(AssuranceActions.targetAttributesAction);
        menu.add(menuItem);

        menu = new JMenu("View");
        menu.setMnemonic(KeyEvent.VK_V);
        menu.getAccessibleContext().setAccessibleDescription(
                accessiblityLabel.append("Views within ").append(Application.applicationShortName).toString());
        accessiblityLabel.setLength(0);
        menuBar.add(menu);

        ButtonGroup group = new ButtonGroup();

        this.viewScanMenuItem = new JRadioButtonMenuItem(MainWindow.viewScanMenuLabel);
        this.viewScanMenuItem.addActionListener(this);
        this.viewScanMenuItem.setActionCommand(AssuranceActions.viewScanAction);
        this.viewScanMenuItem.setSelected(true);
        group.add(this.viewScanMenuItem);
        menu.add(this.viewScanMenuItem);

        this.viewHistoryMenuItem = new JRadioButtonMenuItem(MainWindow.viewHistoryMenuLabel);
        this.viewHistoryMenuItem.addActionListener(this);
        this.viewHistoryMenuItem.setActionCommand(AssuranceActions.viewHistoryAction);
        this.viewHistoryMenuItem.setSelected(true);
        group.add(this.viewHistoryMenuItem);
        menu.add(this.viewHistoryMenuItem);

        if (AssuranceUtils.getPlatform() != Platform.MAC) {
            menu = new JMenu("Tools");
            menu.getAccessibleContext()
                    .setAccessibleDescription(accessiblityLabel.append("Additional actions for ")
                            .append(Application.applicationShortName).append(" application").toString());
            accessiblityLabel.setLength(0);
            menuBar.add(menu);

            menuItem = new JMenuItem(MainWindow.settingsMenuLabel, KeyEvent.VK_COMMA);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, ActionEvent.CTRL_MASK));
            menuItem.getAccessibleContext()
                    .setAccessibleDescription(accessiblityLabel.append("Change settings for the ")
                            .append(Application.applicationShortName).append(" application").toString());
            accessiblityLabel.setLength(0);
            menuItem.addActionListener(this);
            menuItem.setActionCommand(AssuranceActions.displaySettingsAction);
            menu.add(menuItem);
        }

        this.setJMenuBar(menuBar);

        this.initialized = true;
    }
}

From source file:net.sourceforge.squirrel_sql.client.preferences.WikiTablePreferencesPanel.java

/**
 * Create the component, which shows a example.
 * The example contains a {@link JTable} and a {@link JTextField}. If the user change a element of the configuration, then the example will be updated.
 * So we can provide a feedback of the result immediately.
 *//*from  ww w.  j  a  va  2s . c  o m*/
private Component createExamplePanel() {
    JPanel jp = new JPanel(new GridBagLayout());
    jp.setBorder(
            BorderFactory.createTitledBorder(s_stringMgr.getString("WikiTablePreferencesPanel.titleExample"))); //$NON-NLS-1$

    GridBagConstraints gbc = new GridBagConstraints();

    String[][] rowData = new String[][] {
            { s_stringMgr.getString("WikiTablePreferencesPanel.austria"), //$NON-NLS-1$
                    s_stringMgr.getString("WikiTablePreferencesPanel.vienna") }, //$NON-NLS-1$
            { s_stringMgr.getString("WikiTablePreferencesPanel.italy"), //$NON-NLS-1$
                    s_stringMgr.getString("WikiTablePreferencesPanel.rome") } //$NON-NLS-1$
    };

    String[] columnNames = new String[] { s_stringMgr.getString("WikiTablePreferencesPanel.country"), //$NON-NLS-1$
            s_stringMgr.getString("WikiTablePreferencesPanel.captial") }; //$NON-NLS-1$

    exampleTable = new JTable(rowData, columnNames);
    exampleTable.setMinimumSize(new Dimension(10, 10));

    JScrollPane sp = new JScrollPane(exampleTable);
    sp.setPreferredSize(new Dimension(100, 50));

    gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 1;
    gbc.weighty = 0.1;
    jp.add(sp, gbc);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weighty = 0;
    gbc.weightx = 0;
    jp.add(new JLabel(s_stringMgr.getString("WikiTablePreferencesPanel.titleResultExample")), gbc); //$NON-NLS-1$

    exampleText = new JTextArea(15, 20);
    exampleText.setWrapStyleWord(true);
    exampleText.setEditable(false);
    exampleText.setLineWrap(false);

    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weighty = 1;
    gbc.weightx = 1;

    sp = new JScrollPane(exampleText);
    jp.add(sp, gbc);

    return jp;
}

From source file:com.excilys.ebi.gatling.recorder.ui.component.RunningFrame.java

public RunningFrame() {

    /* Initialization of the frame */
    setTitle("Gatling Recorder - Running...");
    setMinimumSize(new Dimension(800, 640));
    setLocationRelativeTo(null);/*from   w ww.  jav  a2  s.com*/
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GridBagLayout gbl = new GridBagLayout();
    setLayout(gbl);

    setIconImages(Commons.getIconList());

    /* Declaration & initialization of components */
    JButton btnClear = new JButton("Clear");
    final JButton btnStop = new JButton("Stop !");
    btnStop.setSize(120, 30);

    JScrollPane panelFilters = new JScrollPane(executedEvents);
    panelFilters.setPreferredSize(new Dimension(300, 100));

    stringRequest.setPreferredSize(new Dimension(330, 100));
    JSplitPane requestResponsePane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(stringRequest),
            new JScrollPane(stringResponse));
    final JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, requestResponsePane, stringRequestBody);

    JScrollPane panelHostsCertificate = new JScrollPane(requiredHostsCertificate);
    panelHostsCertificate.setPreferredSize(new Dimension(300, 100));

    /* Layout */
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(10, 5, 0, 0);

    gbc.gridx = 0;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.gridy = 0;
    add(new JLabel("Tag :"), gbc);

    gbc.gridx = 1;
    add(txtTag, gbc);

    gbc.gridx = 2;
    gbc.weightx = 0.5;
    add(btnTag, gbc);

    gbc.gridx = 3;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.weightx = 0.25;
    add(btnClear, gbc);

    gbc.gridx = 4;
    gbc.anchor = GridBagConstraints.LINE_END;
    add(btnStop, gbc);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 0;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(new JLabel("Executed Events:"), gbc);

    gbc.gridy = 2;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1;
    gbc.weighty = 0.20;
    gbc.fill = GridBagConstraints.BOTH;
    add(panelFilters, gbc);

    gbc.gridy = 4;
    gbc.weightx = 1;
    gbc.weighty = 0.75;
    gbc.fill = GridBagConstraints.BOTH;
    add(sp, gbc);

    gbc.gridy = 5;
    gbc.weighty = 0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.anchor = GridBagConstraints.CENTER;
    add(new JLabel("Secured hosts requiring accepting a certificate:"), gbc);

    gbc.gridy = 6;
    gbc.weighty = 0.05;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(panelHostsCertificate, gbc);

    /* Listeners */
    btnTag.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (!txtTag.getText().equals(EMPTY)) {
                TagEvent tag = new TagEvent(txtTag.getText());
                events.addElement(tag.toString());
                executedEvents.ensureIndexIsVisible(events.getSize() - 1);
                listEvents.add(tag);
                txtTag.setText(EMPTY);
            }
        }
    });

    executedEvents.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (executedEvents.getSelectedIndex() >= 0) {
                Object obj = listEvents.get(executedEvents.getSelectedIndex());
                if (obj instanceof ResponseReceivedEvent) {
                    ResponseReceivedEvent event = (ResponseReceivedEvent) obj;
                    stringRequest.txt.setText(event.getRequest().toString());
                    stringResponse.txt.setText(event.getResponse().toString());
                    stringRequestBody.txt.setText(new String(event.getRequest().getContent().array()));
                } else {
                    stringRequest.txt.setText(EMPTY);
                    stringResponse.txt.setText(EMPTY);
                    stringRequestBody.txt.setText(EMPTY);
                }
            }
        }
    });

    btnClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            clearOldRunning();
        }
    });

    btnStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            saveScenario();
            proxy.shutdown();
            proxy = null;
            if (!Configuration.getInstance().isConfigurationSkipped())
                getEventBus().post(new ShowConfigurationFrameEvent());
            else
                System.exit(0);
        }
    });
}