Example usage for java.awt GridBagConstraints HORIZONTAL

List of usage examples for java.awt GridBagConstraints HORIZONTAL

Introduction

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

Prototype

int HORIZONTAL

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

Click Source Link

Document

Resize the component horizontally but not vertically.

Usage

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

private void createGUI() {
    loadRecentFiles();/*  w w w  .  java2s .c o  m*/
    frame = new JFrame("LanguageTool " + JLanguageTool.VERSION);

    setLookAndFeel();
    openAction = new OpenAction();
    saveAction = new SaveAction();
    saveAsAction = new SaveAsAction();
    checkAction = new CheckAction();
    autoCheckAction = new AutoCheckAction(true);
    showResultAction = new ShowResultAction(true);

    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(new CloseListener());
    URL iconUrl = JLanguageTool.getDataBroker().getFromResourceDirAsUrl(TRAY_ICON);
    frame.setIconImage(new ImageIcon(iconUrl).getImage());

    textArea = new JTextArea();
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.addKeyListener(new ControlReturnTextCheckingListener());

    textLineNumber = new TextLineNumber(textArea, 2);
    numberedTextAreaPane = new JScrollPane(textArea);
    numberedTextAreaPane.setRowHeaderView(textLineNumber);

    resultArea = new JTextPane();
    undoRedo = new UndoRedoSupport(this.textArea, messages);
    frame.setJMenuBar(createMenuBar());

    GridBagConstraints buttonCons = new GridBagConstraints();

    JPanel insidePanel = new JPanel();
    insidePanel.setOpaque(false);
    insidePanel.setLayout(new GridBagLayout());

    buttonCons.gridx = 0;
    buttonCons.gridy = 0;
    buttonCons.anchor = GridBagConstraints.LINE_START;
    insidePanel.add(new JLabel(messages.getString("textLanguage") + " "), buttonCons);

    //create a ComboBox with flags, do not include hidden languages
    languageBox = LanguageComboBox.create(messages, EXTERNAL_LANGUAGE_SUFFIX, true, false);
    buttonCons.gridx = 1;
    buttonCons.gridy = 0;
    buttonCons.anchor = GridBagConstraints.LINE_START;
    insidePanel.add(languageBox, buttonCons);

    JCheckBox autoDetectBox = new JCheckBox(messages.getString("atd"));
    buttonCons.gridx = 2;
    buttonCons.gridy = 0;
    buttonCons.gridwidth = GridBagConstraints.REMAINDER;
    buttonCons.anchor = GridBagConstraints.LINE_START;
    insidePanel.add(autoDetectBox, buttonCons);

    buttonCons.gridx = 0;
    buttonCons.gridy = 1;
    buttonCons.gridwidth = GridBagConstraints.REMAINDER;
    buttonCons.fill = GridBagConstraints.HORIZONTAL;
    buttonCons.anchor = GridBagConstraints.LINE_END;
    buttonCons.weightx = 1.0;
    insidePanel.add(statusLabel, buttonCons);

    Container contentPane = frame.getContentPane();
    GridBagLayout gridLayout = new GridBagLayout();
    contentPane.setLayout(gridLayout);
    GridBagConstraints cons = new GridBagConstraints();

    cons.gridx = 0;
    cons.gridy = 1;
    cons.fill = GridBagConstraints.HORIZONTAL;
    cons.anchor = GridBagConstraints.FIRST_LINE_START;
    JToolBar toolbar = new JToolBar("Toolbar", JToolBar.HORIZONTAL);
    toolbar.setFloatable(false);
    contentPane.add(toolbar, cons);

    JButton openButton = new JButton(openAction);
    openButton.setHideActionText(true);
    openButton.setFocusable(false);
    toolbar.add(openButton);

    JButton saveButton = new JButton(saveAction);
    saveButton.setHideActionText(true);
    saveButton.setFocusable(false);
    toolbar.add(saveButton);

    JButton saveAsButton = new JButton(saveAsAction);
    saveAsButton.setHideActionText(true);
    saveAsButton.setFocusable(false);
    toolbar.add(saveAsButton);

    JButton spellButton = new JButton(this.checkAction);
    spellButton.setHideActionText(true);
    spellButton.setFocusable(false);
    toolbar.add(spellButton);

    JToggleButton autoSpellButton = new JToggleButton(autoCheckAction);
    autoSpellButton.setHideActionText(true);
    autoSpellButton.setFocusable(false);
    toolbar.add(autoSpellButton);

    JButton clearTextButton = new JButton(new ClearTextAction());
    clearTextButton.setHideActionText(true);
    clearTextButton.setFocusable(false);
    toolbar.add(clearTextButton);

    cons.insets = new Insets(5, 5, 5, 5);
    cons.fill = GridBagConstraints.BOTH;
    cons.weightx = 10.0f;
    cons.weighty = 10.0f;
    cons.gridx = 0;
    cons.gridy = 2;
    cons.weighty = 5.0f;
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, numberedTextAreaPane, new JScrollPane(resultArea));
    mainPanel.setLayout(new GridLayout(0, 1));
    contentPane.add(mainPanel, cons);
    mainPanel.add(splitPane);

    cons.fill = GridBagConstraints.HORIZONTAL;
    cons.gridx = 0;
    cons.gridy = 3;
    cons.weightx = 1.0f;
    cons.weighty = 0.0f;
    cons.insets = new Insets(4, 12, 4, 12);
    contentPane.add(insidePanel, cons);

    ltSupport = new LanguageToolSupport(this.frame, this.textArea, this.undoRedo);
    ResultAreaHelper.install(messages, ltSupport, resultArea);
    languageBox.selectLanguage(ltSupport.getLanguage());
    languageBox.setEnabled(!ltSupport.getConfig().getAutoDetect());
    autoDetectBox.setSelected(ltSupport.getConfig().getAutoDetect());
    taggerShowsDisambigLog = ltSupport.getConfig().getTaggerShowsDisambigLog();

    languageBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                // we cannot re-use the existing LT object anymore
                frame.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));
                Language lang = languageBox.getSelectedLanguage();
                ComponentOrientation componentOrientation = ComponentOrientation
                        .getOrientation(lang.getLocale());
                textArea.applyComponentOrientation(componentOrientation);
                resultArea.applyComponentOrientation(componentOrientation);
                ltSupport.setLanguage(lang);
            }
        }
    });
    autoDetectBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            boolean selected = e.getStateChange() == ItemEvent.SELECTED;
            languageBox.setEnabled(!selected);
            ltSupport.getConfig().setAutoDetect(selected);
            if (selected) {
                Language detected = ltSupport.autoDetectLanguage(textArea.getText());
                languageBox.selectLanguage(detected);
            }
        }
    });
    ltSupport.addLanguageToolListener(new LanguageToolListener() {
        @Override
        public void languageToolEventOccurred(LanguageToolEvent event) {
            if (event.getType() == LanguageToolEvent.Type.CHECKING_STARTED) {
                String msg = org.languagetool.tools.Tools.i18n(messages, "checkStart");
                statusLabel.setText(msg);
                if (event.getCaller() == getFrame()) {
                    setWaitCursor();
                    checkAction.setEnabled(false);
                }
            } else if (event.getType() == LanguageToolEvent.Type.CHECKING_FINISHED) {
                if (event.getCaller() == getFrame()) {
                    checkAction.setEnabled(true);
                    unsetWaitCursor();
                }
                String msg = org.languagetool.tools.Tools.i18n(messages, "checkDone",
                        event.getSource().getMatches().size(), event.getElapsedTime());
                statusLabel.setText(msg);
            } else if (event.getType() == LanguageToolEvent.Type.LANGUAGE_CHANGED) {
                languageBox.selectLanguage(ltSupport.getLanguage());
            } else if (event.getType() == LanguageToolEvent.Type.RULE_ENABLED) {
                //this will trigger a check and the result will be updated by
                //the CHECKING_FINISHED event
            } else if (event.getType() == LanguageToolEvent.Type.RULE_DISABLED) {
                String msg = org.languagetool.tools.Tools.i18n(messages, "checkDoneNoTime",
                        event.getSource().getMatches().size());
                statusLabel.setText(msg);
            }
        }
    });
    frame.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));
    Language lang = ltSupport.getLanguage();
    ComponentOrientation componentOrientation = ComponentOrientation.getOrientation(lang.getLocale());
    textArea.applyComponentOrientation(componentOrientation);
    resultArea.applyComponentOrientation(componentOrientation);

    ResourceBundle textLanguageMessageBundle = JLanguageTool.getMessageBundle(ltSupport.getLanguage());
    textArea.setText(textLanguageMessageBundle.getString("guiDemoText"));

    Configuration config = ltSupport.getConfig();
    if (config.getFontName() != null || config.getFontStyle() != Configuration.FONT_STYLE_INVALID
            || config.getFontSize() != Configuration.FONT_SIZE_INVALID) {
        String fontName = config.getFontName();
        if (fontName == null) {
            fontName = textArea.getFont().getFamily();
        }
        int fontSize = config.getFontSize();
        if (fontSize == Configuration.FONT_SIZE_INVALID) {
            fontSize = textArea.getFont().getSize();
        }
        Font font = new Font(fontName, config.getFontStyle(), fontSize);
        textArea.setFont(font);
    }

    frame.pack();
    frame.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
    frame.setLocationByPlatform(true);
    splitPane.setDividerLocation(200);
    MainWindowStateBean state = localStorage.loadProperty("gui.state", MainWindowStateBean.class);
    if (state != null) {
        if (state.getBounds() != null) {
            frame.setBounds(state.getBounds());
            ResizeComponentListener.setBoundsProperty(frame, state.getBounds());
        }
        if (state.getDividerLocation() != null) {
            splitPane.setDividerLocation(state.getDividerLocation());
        }
        if (state.getState() != null) {
            frame.setExtendedState(state.getState());
        }
    }
    ResizeComponentListener.attachToWindow(frame);
    maybeStartServer();
}

From source file:org.jtrfp.trcl.gui.ConfigWindow.java

public ConfigWindow() {
    setTitle("Settings");
    setSize(340, 540);//from  w  w  w .ja v  a 2  s  .  c  o  m
    if (config == null)
        config = new TRConfiguration();
    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    getContentPane().add(tabbedPane, BorderLayout.CENTER);

    JPanel generalTab = new JPanel();
    tabbedPane.addTab("General",
            new ImageIcon(ConfigWindow.class
                    .getResource("/org/freedesktop/tango/22x22/mimetypes/application-x-executable.png")),
            generalTab, null);
    GridBagLayout gbl_generalTab = new GridBagLayout();
    gbl_generalTab.columnWidths = new int[] { 0, 0 };
    gbl_generalTab.rowHeights = new int[] { 0, 188, 222, 0 };
    gbl_generalTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_generalTab.rowWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE };
    generalTab.setLayout(gbl_generalTab);

    JPanel settingsLoadSavePanel = new JPanel();
    GridBagConstraints gbc_settingsLoadSavePanel = new GridBagConstraints();
    gbc_settingsLoadSavePanel.insets = new Insets(0, 0, 5, 0);
    gbc_settingsLoadSavePanel.anchor = GridBagConstraints.WEST;
    gbc_settingsLoadSavePanel.gridx = 0;
    gbc_settingsLoadSavePanel.gridy = 0;
    generalTab.add(settingsLoadSavePanel, gbc_settingsLoadSavePanel);
    settingsLoadSavePanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null),
            "Overall Settings", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    FlowLayout flowLayout_1 = (FlowLayout) settingsLoadSavePanel.getLayout();
    flowLayout_1.setAlignment(FlowLayout.LEFT);

    JButton btnSave = new JButton("Export...");
    btnSave.setToolTipText("Export these settings to an external file");
    settingsLoadSavePanel.add(btnSave);
    btnSave.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            exportSettings();
        }
    });

    JButton btnLoad = new JButton("Import...");
    btnLoad.setToolTipText("Import an external settings file");
    settingsLoadSavePanel.add(btnLoad);
    btnLoad.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            importSettings();
        }
    });

    JButton btnConfigReset = new JButton("Reset");
    btnConfigReset.setToolTipText("Reset all settings to defaults");
    settingsLoadSavePanel.add(btnConfigReset);
    btnConfigReset.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            defaultSettings();
        }
    });

    JPanel registeredPODsPanel = new JPanel();
    registeredPODsPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null),
            "Registered PODs", TitledBorder.LEFT, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_registeredPODsPanel = new GridBagConstraints();
    gbc_registeredPODsPanel.insets = new Insets(0, 0, 5, 0);
    gbc_registeredPODsPanel.fill = GridBagConstraints.BOTH;
    gbc_registeredPODsPanel.gridx = 0;
    gbc_registeredPODsPanel.gridy = 1;
    generalTab.add(registeredPODsPanel, gbc_registeredPODsPanel);
    GridBagLayout gbl_registeredPODsPanel = new GridBagLayout();
    gbl_registeredPODsPanel.columnWidths = new int[] { 272, 0 };
    gbl_registeredPODsPanel.rowHeights = new int[] { 76, 0, 0 };
    gbl_registeredPODsPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_registeredPODsPanel.rowWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE };
    registeredPODsPanel.setLayout(gbl_registeredPODsPanel);

    JPanel podListPanel = new JPanel();
    GridBagConstraints gbc_podListPanel = new GridBagConstraints();
    gbc_podListPanel.insets = new Insets(0, 0, 5, 0);
    gbc_podListPanel.fill = GridBagConstraints.BOTH;
    gbc_podListPanel.gridx = 0;
    gbc_podListPanel.gridy = 0;
    registeredPODsPanel.add(podListPanel, gbc_podListPanel);
    podListPanel.setLayout(new BorderLayout(0, 0));

    JScrollPane podListScrollPane = new JScrollPane();
    podListPanel.add(podListScrollPane, BorderLayout.CENTER);

    podList = new JList(podLM);
    podList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    podListScrollPane.setViewportView(podList);

    JPanel podListOpButtonPanel = new JPanel();
    podListOpButtonPanel.setBorder(null);
    GridBagConstraints gbc_podListOpButtonPanel = new GridBagConstraints();
    gbc_podListOpButtonPanel.anchor = GridBagConstraints.NORTH;
    gbc_podListOpButtonPanel.gridx = 0;
    gbc_podListOpButtonPanel.gridy = 1;
    registeredPODsPanel.add(podListOpButtonPanel, gbc_podListOpButtonPanel);
    FlowLayout flowLayout = (FlowLayout) podListOpButtonPanel.getLayout();
    flowLayout.setAlignment(FlowLayout.LEFT);

    JButton addPodButton = new JButton("Add...");
    addPodButton.setIcon(
            new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png")));
    addPodButton.setToolTipText("Add a POD to the registry to be considered when running a game.");
    podListOpButtonPanel.add(addPodButton);
    addPodButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            addPOD();
        }
    });

    JButton removePodButton = new JButton("Remove");
    removePodButton.setIcon(new ImageIcon(
            ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png")));
    removePodButton.setToolTipText("Remove a POD file from being considered when playing a game");
    podListOpButtonPanel.add(removePodButton);
    removePodButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            podLM.removeElement(podList.getSelectedValue());
        }
    });

    JButton podEditButton = new JButton("Edit...");
    podEditButton.setIcon(null);
    podEditButton.setToolTipText("Edit the selected POD path");
    podListOpButtonPanel.add(podEditButton);
    podEditButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            editPODPath();
        }
    });

    JPanel missionPanel = new JPanel();
    GridBagConstraints gbc_missionPanel = new GridBagConstraints();
    gbc_missionPanel.fill = GridBagConstraints.BOTH;
    gbc_missionPanel.gridx = 0;
    gbc_missionPanel.gridy = 2;
    generalTab.add(missionPanel, gbc_missionPanel);
    missionPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Missions",
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagLayout gbl_missionPanel = new GridBagLayout();
    gbl_missionPanel.columnWidths = new int[] { 0, 0 };
    gbl_missionPanel.rowHeights = new int[] { 0, 0, 0 };
    gbl_missionPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_missionPanel.rowWeights = new double[] { 1.0, 0.0, Double.MIN_VALUE };
    missionPanel.setLayout(gbl_missionPanel);

    JScrollPane scrollPane = new JScrollPane();
    GridBagConstraints gbc_scrollPane = new GridBagConstraints();
    gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
    gbc_scrollPane.fill = GridBagConstraints.BOTH;
    gbc_scrollPane.gridx = 0;
    gbc_scrollPane.gridy = 0;
    missionPanel.add(scrollPane, gbc_scrollPane);

    missionList = new JList(missionLM);
    missionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    scrollPane.setViewportView(missionList);

    JPanel missionListOpButtonPanel = new JPanel();
    GridBagConstraints gbc_missionListOpButtonPanel = new GridBagConstraints();
    gbc_missionListOpButtonPanel.anchor = GridBagConstraints.NORTH;
    gbc_missionListOpButtonPanel.gridx = 0;
    gbc_missionListOpButtonPanel.gridy = 1;
    missionPanel.add(missionListOpButtonPanel, gbc_missionListOpButtonPanel);

    JButton addVOXButton = new JButton("Add...");
    addVOXButton.setIcon(
            new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png")));
    addVOXButton.setToolTipText("Add an external VOX file as a mission");
    missionListOpButtonPanel.add(addVOXButton);
    addVOXButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            addVOX();
        }
    });

    final JButton removeVOXButton = new JButton("Remove");
    removeVOXButton.setIcon(new ImageIcon(
            ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png")));
    removeVOXButton.setToolTipText("Remove the selected mission");
    missionListOpButtonPanel.add(removeVOXButton);
    removeVOXButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            missionLM.remove(missionList.getSelectedIndex());
        }
    });

    final JButton editVOXButton = new JButton("Edit...");
    editVOXButton.setToolTipText("Edit the selected Mission's VOX path");
    missionListOpButtonPanel.add(editVOXButton);
    editVOXButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            editVOXPath();
        }
    });

    missionList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent evt) {
            final String val = (String) missionList.getSelectedValue();
            if (val == null)
                missionList.setSelectedIndex(0);
            else if (isBuiltinVOX(val)) {
                removeVOXButton.setEnabled(false);
                editVOXButton.setEnabled(false);
            } else {
                removeVOXButton.setEnabled(true);
                editVOXButton.setEnabled(true);
            }
        }
    });

    JPanel soundTab = new JPanel();
    tabbedPane.addTab("Sound",
            new ImageIcon(
                    ConfigWindow.class.getResource("/org/freedesktop/tango/22x22/devices/audio-card.png")),
            soundTab, null);
    GridBagLayout gbl_soundTab = new GridBagLayout();
    gbl_soundTab.columnWidths = new int[] { 0, 0 };
    gbl_soundTab.rowHeights = new int[] { 65, 51, 70, 132, 0, 0, 0 };
    gbl_soundTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_soundTab.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
    soundTab.setLayout(gbl_soundTab);

    JPanel checkboxPanel = new JPanel();
    GridBagConstraints gbc_checkboxPanel = new GridBagConstraints();
    gbc_checkboxPanel.insets = new Insets(0, 0, 5, 0);
    gbc_checkboxPanel.fill = GridBagConstraints.BOTH;
    gbc_checkboxPanel.gridx = 0;
    gbc_checkboxPanel.gridy = 0;
    soundTab.add(checkboxPanel, gbc_checkboxPanel);

    chckbxLinearInterpolation = new JCheckBox("Linear Filtering");
    chckbxLinearInterpolation.setToolTipText("Use the GPU's TMU to smooth playback of low-rate samples.");
    chckbxLinearInterpolation.setHorizontalAlignment(SwingConstants.LEFT);
    checkboxPanel.add(chckbxLinearInterpolation);

    chckbxLinearInterpolation.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            needRestart = true;
        }
    });

    chckbxBufferLag = new JCheckBox("Buffer Lag");
    chckbxBufferLag.setToolTipText("Improves efficiency, doubles latency.");
    checkboxPanel.add(chckbxBufferLag);

    JPanel modStereoWidthPanel = new JPanel();
    FlowLayout flowLayout_2 = (FlowLayout) modStereoWidthPanel.getLayout();
    flowLayout_2.setAlignment(FlowLayout.LEFT);
    modStereoWidthPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null),
            "MOD Stereo Width", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_modStereoWidthPanel = new GridBagConstraints();
    gbc_modStereoWidthPanel.anchor = GridBagConstraints.NORTH;
    gbc_modStereoWidthPanel.insets = new Insets(0, 0, 5, 0);
    gbc_modStereoWidthPanel.fill = GridBagConstraints.HORIZONTAL;
    gbc_modStereoWidthPanel.gridx = 0;
    gbc_modStereoWidthPanel.gridy = 1;
    soundTab.add(modStereoWidthPanel, gbc_modStereoWidthPanel);

    modStereoWidthSlider = new JSlider();
    modStereoWidthSlider.setPaintTicks(true);
    modStereoWidthSlider.setMinorTickSpacing(25);
    modStereoWidthPanel.add(modStereoWidthSlider);

    final JLabel modStereoWidthLbl = new JLabel("NN%");
    modStereoWidthPanel.add(modStereoWidthLbl);

    JPanel bufferSizePanel = new JPanel();
    FlowLayout flowLayout_3 = (FlowLayout) bufferSizePanel.getLayout();
    flowLayout_3.setAlignment(FlowLayout.LEFT);
    bufferSizePanel.setBorder(
            new TitledBorder(null, "Buffer Size", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_bufferSizePanel = new GridBagConstraints();
    gbc_bufferSizePanel.anchor = GridBagConstraints.NORTH;
    gbc_bufferSizePanel.insets = new Insets(0, 0, 5, 0);
    gbc_bufferSizePanel.fill = GridBagConstraints.HORIZONTAL;
    gbc_bufferSizePanel.gridx = 0;
    gbc_bufferSizePanel.gridy = 2;
    soundTab.add(bufferSizePanel, gbc_bufferSizePanel);

    audioBufferSizeCB = new JComboBox();
    audioBufferSizeCB.setModel(new DefaultComboBoxModel(AudioBufferSize.values()));
    bufferSizePanel.add(audioBufferSizeCB);

    soundOutputSelectorGUI = new SoundOutputSelectorGUI();
    soundOutputSelectorGUI.setBorder(
            new TitledBorder(null, "Output Driver", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_soundOutputSelectorGUI = new GridBagConstraints();
    gbc_soundOutputSelectorGUI.anchor = GridBagConstraints.NORTH;
    gbc_soundOutputSelectorGUI.insets = new Insets(0, 0, 5, 0);
    gbc_soundOutputSelectorGUI.fill = GridBagConstraints.HORIZONTAL;
    gbc_soundOutputSelectorGUI.gridx = 0;
    gbc_soundOutputSelectorGUI.gridy = 3;
    soundTab.add(soundOutputSelectorGUI, gbc_soundOutputSelectorGUI);

    modStereoWidthSlider.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent arg0) {
            modStereoWidthLbl.setText(modStereoWidthSlider.getValue() + "%");
            needRestart = true;
        }
    });

    JPanel okCancelPanel = new JPanel();
    getContentPane().add(okCancelPanel, BorderLayout.SOUTH);
    okCancelPanel.setLayout(new BorderLayout(0, 0));

    JButton btnOk = new JButton("OK");
    btnOk.setToolTipText("Apply these settings and close the window");
    okCancelPanel.add(btnOk, BorderLayout.WEST);
    btnOk.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            applySettings();
            ConfigWindow.this.setVisible(false);
        }
    });

    JButton btnCancel = new JButton("Cancel");
    btnCancel.setToolTipText("Close the window without applying settings");
    okCancelPanel.add(btnCancel, BorderLayout.EAST);

    JLabel lblConfigpath = new JLabel(TRConfiguration.getConfigFilePath().getAbsolutePath());
    lblConfigpath.setIcon(null);
    lblConfigpath.setToolTipText("Default config file path");
    lblConfigpath.setHorizontalAlignment(SwingConstants.CENTER);
    lblConfigpath.setFont(new Font("Dialog", Font.BOLD, 6));
    okCancelPanel.add(lblConfigpath, BorderLayout.CENTER);
    btnCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            ConfigWindow.this.setVisible(false);
        }
    });
}

From source file:com.sec.ose.osi.ui.frm.main.identification.stringmatch.JPanStringMatchMain.java

public JPanel getJPanelLicenseFolder() {
    if (jPanelLicenseFolder == null) {
        GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
        gridBagConstraints13.anchor = GridBagConstraints.WEST;
        gridBagConstraints13.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints13.insets = new Insets(0, 0, 5, 0);
        gridBagConstraints13.gridx = 1;/*from  w  w w.  j  a  va  2 s. c  o  m*/
        gridBagConstraints13.gridy = 0;
        gridBagConstraints13.gridwidth = 1;
        gridBagConstraints13.weightx = 1.0;

        GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
        gridBagConstraints11.gridx = 0;
        gridBagConstraints11.insets = new Insets(0, 0, 5, 3);
        gridBagConstraints11.gridy = 0;

        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
        gridBagConstraints4.anchor = GridBagConstraints.WEST;
        gridBagConstraints4.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints4.insets = new Insets(0, 0, 0, 0);
        gridBagConstraints4.gridx = -1;
        gridBagConstraints4.gridy = 1;
        gridBagConstraints4.gridwidth = 1;
        gridBagConstraints4.weightx = 0.0;

        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.anchor = GridBagConstraints.EAST;
        gridBagConstraints2.insets = new Insets(0, 0, 0, 3);
        gridBagConstraints2.gridx = -1;
        gridBagConstraints2.gridy = 1;
        gridBagConstraints2.ipadx = 0;
        gridBagConstraints2.weightx = 0.0;
        gridBagConstraints2.fill = GridBagConstraints.NONE;
        jPanelLicenseFolder = new JPanel();
        jPanelLicenseFolder.setLayout(new GridBagLayout());
        jPanelLicenseFolder.setPreferredSize(new Dimension(403, 66));
        jPanelLicenseFolder.add(jLabelLicenseForOpt1, gridBagConstraints2);
        jPanelLicenseFolder.add(getJComboLicenseNameForOpt1(), gridBagConstraints4);
        jPanelLicenseFolder.add(jLabelComponentForOpt1, gridBagConstraints11);
        jPanelLicenseFolder.add(getJComboBoxComponent(), gridBagConstraints13);
    }
    return jPanelLicenseFolder;
}

From source file:com.sec.ose.osi.ui.dialog.setting.JPanProjectAnalysisSetting.java

/**
 * This method initializes jIntMainPanel   
 *    //ww  w.j ava 2 s . co  m
 * @return javax.swing.JPanel   
 */
private JPanel getJIntMainPanel() {
    if (jIntMainPanel == null) {

        GridBagConstraints gridBagConstraintsSplit = new GridBagConstraints();
        gridBagConstraintsSplit.anchor = GridBagConstraints.NORTHWEST;
        gridBagConstraintsSplit.weighty = 1.0;
        gridBagConstraintsSplit.insets = new Insets(5, 5, 0, 5);
        gridBagConstraintsSplit.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsSplit.weightx = 1.0;

        GridBagConstraints gridBagConstraintsMonitor = new GridBagConstraints();
        gridBagConstraintsMonitor.anchor = GridBagConstraints.WEST;
        gridBagConstraintsMonitor.weighty = 1.0;
        gridBagConstraintsMonitor.insets = new Insets(5, 5, 0, 5);
        gridBagConstraintsMonitor.gridx = 0;
        gridBagConstraintsMonitor.gridy = 1;
        gridBagConstraintsMonitor.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsMonitor.weightx = 1.0;

        jIntMainPanel = new JPanel();
        jIntMainPanel.setLayout(new GridBagLayout());
        jIntMainPanel.setBorder(BorderFactory.createTitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION,
                TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
        jIntMainPanel.add(getJPanelProjectSplit(), gridBagConstraintsSplit);
        jIntMainPanel.add(getJPanelMonitorInterval(), gridBagConstraintsMonitor);
    }
    return jIntMainPanel;
}

From source file:org.executequery.gui.browser.TableDataTab.java

private void initRowCountPanel() {

    rowCountField = new DisabledField();
    rowCountPanel = new JPanel(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridy = 0;/*from   ww w  . j  a  v  a2  s . co  m*/
    gbc.gridx = 0;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    rowCountPanel.add(new JLabel("Data Row Count:"), gbc);
    gbc.gridx = 2;
    gbc.insets.bottom = 2;
    gbc.insets.left = 5;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets.right = 0;
    rowCountPanel.add(rowCountField, gbc);
}

From source file:org.jivesoftware.sparkimpl.plugin.viewer.PluginViewer.java

private void downloadPlugin(final PublicPlugin plugin) {
    // Prepare HTTP post
    final GetMethod post = new GetMethod(plugin.getDownloadURL());

    // Get HTTP client
    Protocol.registerProtocol("https", new Protocol("https", new EasySSLProtocolSocketFactory(), 443));
    final HttpClient httpclient = new HttpClient();
    String proxyHost = System.getProperty("http.proxyHost");
    String proxyPort = System.getProperty("http.proxyPort");

    if (Default.getBoolean("PLUGIN_REPOSITORY_USE_PROXY")) {
        if (ModelUtil.hasLength(proxyHost) && ModelUtil.hasLength(proxyPort)) {
            try {
                httpclient.getHostConfiguration().setProxy(proxyHost, Integer.parseInt(proxyPort));
            } catch (NumberFormatException e) {
                Log.error(e);/*from ww w  .  j a va  2  s  . co m*/
            }
        }
    }
    // Execute request

    try {
        int result = httpclient.executeMethod(post);
        if (result != 200) {
            return;
        }

        long length = post.getResponseContentLength();
        int contentLength = (int) length;

        progressBar = new JProgressBar(0, contentLength);

        final JFrame frame = new JFrame(Res.getString("message.downloading", plugin.getName()));

        frame.setIconImage(SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_IMAGE).getImage());

        final Thread thread = new Thread(new Runnable() {
            public void run() {
                try {
                    Thread.sleep(2000);
                    InputStream stream = post.getResponseBodyAsStream();

                    URL url = new URL(plugin.getDownloadURL());
                    String name = URLFileSystem.getFileName(url);
                    String directoryName = URLFileSystem.getName(url);

                    File pluginDownload = new File(PluginManager.PLUGINS_DIRECTORY, name);

                    FileOutputStream out = new FileOutputStream(pluginDownload);
                    copy(stream, out);
                    out.close();

                    frame.dispose();

                    // Remove SparkPlugUI
                    // Clear all selections
                    Component[] comps = availablePanel.getComponents();
                    for (Component comp : comps) {
                        if (comp instanceof SparkPlugUI) {
                            SparkPlugUI sparkPlug = (SparkPlugUI) comp;
                            if (sparkPlug.getPlugin().getDownloadURL().equals(plugin.getDownloadURL())) {
                                availablePanel.remove(sparkPlug);

                                _deactivatedPlugins.remove(sparkPlug.getPlugin().getName());
                                _prefs.setDeactivatedPlugins(_deactivatedPlugins);

                                PluginManager.getInstance().addPlugin(sparkPlug.getPlugin());

                                sparkPlug.showOperationButton();
                                installedPanel.add(sparkPlug);
                                sparkPlug.getPlugin()
                                        .setPluginDir(new File(PluginManager.PLUGINS_DIRECTORY, directoryName));
                                installedPanel.invalidate();
                                installedPanel.repaint();
                                availablePanel.invalidate();
                                availablePanel.invalidate();
                                availablePanel.validate();
                                availablePanel.repaint();
                            }
                        }
                    }
                } catch (Exception ex) {
                    // Nothing to do
                } finally {
                    // Release current connection to the connection pool once you are done
                    post.releaseConnection();
                }
            }
        });

        frame.getContentPane().setLayout(new GridBagLayout());
        frame.getContentPane().add(new JLabel(Res.getString("message.downloading.spark.plug")),
                new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
                        GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
        frame.getContentPane().add(progressBar, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0,
                GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
        frame.pack();
        frame.setSize(400, 100);
        GraphicUtils.centerWindowOnComponent(frame, this);

        frame.setVisible(true);
        thread.start();

    } catch (IOException e) {
        Log.error(e);
    }
}

From source file:net.java.sip.communicator.gui.AuthenticationSplash.java

/**
 * The user has selected an option. Here we close and dispose the dialog.
 * If actionCommand is an ActionEvent, getCommandString() is called,
 * otherwise toString() is used to get the action command.
 *
 * @param actionCommand may be null/*w w w .j  av a 2s .  c  om*/
 */
private void registrationComponents() {
    Container contents = getContentPane();
    contents.setLayout(new BorderLayout());

    String title = Utils.getProperty("net.java.sip.communicator.gui.REG_WIN_TITLE");

    if (title == null)
        title = "Registration Manager";

    setTitle(title);
    setResizable(false);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent event) {
            registrationDialogDone(CMD_CANCEL);
        }
    });

    // Accessibility -- all frames, dialogs, and applets should
    // have a description
    getAccessibleContext().setAccessibleDescription("Registration Splash");

    String authPromptLabelValue = Utils.getProperty("net.java.sip.communicator.gui.REGISTRATION_PROMPT");

    if (authPromptLabelValue == null)
        authPromptLabelValue = "Please fill in the following fields to register:";

    JLabel splashLabel = new JLabel(authPromptLabelValue);
    splashLabel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    splashLabel.setHorizontalAlignment(SwingConstants.CENTER);
    splashLabel.setHorizontalTextPosition(SwingConstants.CENTER);
    contents.add(splashLabel, BorderLayout.NORTH);

    JPanel centerPane = new JPanel();
    centerPane.setLayout(new GridBagLayout());

    /* My additions */
    nameTextField = new JTextField(); //needed below

    // name label
    nameLabel = new JLabel();
    nameLabel.setLabelFor(nameTextField);
    String nLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.NAME_LABEL");

    if (nLabelStr == null)
        nLabelStr = "Name";

    nameLabel.setText(nLabelStr);

    int gridy = 0;
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = gridy;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(11, 12, 0, 0);

    centerPane.add(nameLabel, c);

    // name text
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(11, 7, 0, 11);
    centerPane.add(nameTextField, c);

    lastNameTextField = new JTextField(); //needed below

    // last name label
    lastNameLabel = new JLabel();
    lastNameLabel.setLabelFor(nameTextField);
    String lnLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.LAST_NAME_LABEL");

    if (lnLabelStr == null)
        lnLabelStr = "Last Name";

    lastNameLabel.setText(lnLabelStr);

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = gridy;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(11, 12, 0, 0);

    centerPane.add(lastNameLabel, c);

    // last name text
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(11, 7, 0, 11);
    centerPane.add(lastNameTextField, c);

    mailTextField = new JTextField(); //needed below

    // mail label
    mailLabel = new JLabel();
    mailLabel.setLabelFor(mailTextField);
    String mLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.MAIL_LABEL");

    if (mLabelStr == null)
        mLabelStr = "Email";

    mailLabel.setText(mLabelStr);

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = gridy;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(11, 12, 0, 0);

    centerPane.add(mailLabel, c);

    // mail text
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(11, 7, 0, 11);
    centerPane.add(mailTextField, c);
    /* END: MY additions */

    userNameTextField = new JTextField(); // needed below

    // user name label
    userNameLabel = new JLabel();
    userNameLabel.setLabelFor(userNameTextField);
    String userNameLabelValue = Utils.getProperty("net.java.sip.communicator.gui.USER_NAME_LABEL");

    if (userNameLabelValue == null)
        userNameLabelValue = "Username";

    userNameLabel.setText(userNameLabelValue);
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = gridy;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(12, 12, 0, 0);
    centerPane.add(userNameLabel, c);

    // user name text
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(12, 7, 0, 11);
    centerPane.add(userNameTextField, c);

    passwordTextField = new JPasswordField(); //needed below

    // password label
    passwordLabel = new JLabel();
    passwordLabel.setLabelFor(passwordTextField);
    String pLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.PASSWORD_LABEL");

    if (pLabelStr == null)
        pLabelStr = "Password";

    passwordLabel.setText(pLabelStr);
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = gridy;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(11, 12, 0, 0);

    centerPane.add(passwordLabel, c);

    // password text
    passwordTextField.setEchoChar('\u2022');
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(11, 7, 0, 11);
    centerPane.add(passwordTextField, c);

    policyDropDown = new JComboBox();
    policyDropDown.addItem("Basic");
    policyDropDown.addItem("Pro");
    policyDropDown.addItem("Enterprise");

    // policy label
    policyLabel = new JLabel();
    policyLabel.setLabelFor(policyDropDown);
    String plcLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.POLICY_LABEL");

    if (plcLabelStr == null)
        plcLabelStr = "Policy";

    policyLabel.setText(plcLabelStr);
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = gridy;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(11, 12, 0, 0);
    centerPane.add(policyLabel, c);

    // policy menu
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(11, 7, 0, 11);
    centerPane.add(policyDropDown, c);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, 0));

    registerButton = new JButton();
    registerButton.setMnemonic('G');
    registerButton.setText("Register");
    registerButton.setActionCommand(CMD_REGISTER);
    registerButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            registrationDialogDone(event);
        }
    });
    buttonPanel.add(registerButton);

    buttonPanel.add(Box.createRigidArea(new Dimension(5, 0)));

    cancelButton = new JButton();
    cancelButton.setText("Cancel");
    cancelButton.setActionCommand(CMD_CANCEL);
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            registrationDialogDone(event);
        }
    });
    buttonPanel.add(cancelButton);

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 2;
    c.insets = new Insets(11, 12, 11, 11);

    centerPane.add(buttonPanel, c);

    contents.add(centerPane, BorderLayout.CENTER);
    getRootPane().setDefaultButton(registerButton);
    registrationEqualizeButtonSizes();

    setFocusTraversalPolicy(new FocusTraversalPol());

}

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

/**
 * Sets the specified GridBagConstraints with the specified grid y coordinate and:<br>
 * <br>/*from   w w w .  java  2s  .  c  o  m*/
 * grid x = 1 <br>
 * grid width = 1 <br>
 * weight x = 1 <br>
 * insets = FIELD_INSETS <br>
 * fill = GridBagConstraints.HORIZONTAL <br>
 * anchor = GridBagConstraints.WEST
 * 
 * @param gbc
 *           the constraints to set
 * @param gridy
 *           the grid y coordinate
 */
private void setFieldConstraints(GridBagConstraints gbc, int gridy) {
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.gridwidth = 1;
    gbc.weightx = 1;
    gbc.insets = FIELD_INSETS;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;

}

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

private JPanel getIntervalo() {
    JPanel intervalo = new JPanel(new GridBagLayout());
    intervalo.setOpaque(false);//  ww  w.ja v  a  2  s  . c o m
    intervalo.setBorder(new TitledBorder("Intervalo Temporal de Consulta"));

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;

    intervalo.add(new JLabel("Fecha/Hora Inicial"), gbc);
    gbc.gridx++;
    calendarini = new JCalendarCombo();
    calendarini.addActionListener(actionListener);
    calendarini.addDateListener(dateListener);
    intervalo.add(calendarini, gbc);
    gbc.gridx++;
    final Calendar instance = Calendar.getInstance();
    instance.set(Calendar.HOUR, 0);
    instance.set(Calendar.MINUTE, 0);
    instance.set(Calendar.SECOND, 0);
    horaini = initializeSpinner(instance);
    intervalo.add(horaini, gbc);

    gbc.gridx = 0;
    gbc.gridy++;

    intervalo.add(new JLabel("Fecha/Hora Final"), gbc);
    gbc.gridx++;
    calendarfin = new JCalendarCombo();
    calendarfin.addActionListener(actionListener);
    calendarfin.addDateListener(dateListener);
    intervalo.add(calendarfin, gbc);
    gbc.gridx++;
    horafin = initializeSpinner(instance);
    intervalo.add(horafin, gbc);

    gbc.gridx = 0;
    gbc.gridy++;
    gbc.anchor = GridBagConstraints.EAST;
    soloUltimas = new JCheckBox();
    soloUltimas.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateRecursos();
        }
    });
    soloUltimas.setOpaque(false);
    soloUltimas.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            boolean enabled = !soloUltimas.isSelected();
            calendarini.setEnabled(enabled);
            calendarfin.setEnabled(enabled);
            horaini.setEnabled(enabled);
            horafin.setEnabled(enabled);
        }
    });
    intervalo.add(soloUltimas, gbc);
    gbc.gridx++;
    gbc.anchor = GridBagConstraints.WEST;
    intervalo.add(new JLabel("Consultar Slo Las ltimas Posiciones"), gbc);

    return intervalo;
}

From source file:com.rapidminer.gui.viewer.metadata.AttributeStatisticsPanel.java

/**
 * Initializes the GUI.//from   w  ww . ja  v a  2 s .c o m
 *
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void initGUI() {
    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    // add attribute name
    panelAttName = new JPanel();
    panelAttName.setLayout(new BoxLayout(panelAttName, BoxLayout.PAGE_AXIS));
    panelAttName.setOpaque(false);
    // this border is to visualize that the name column can be enlarged/shrinked
    panelAttName.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.LIGHT_GRAY));

    labelAttHeader = new JLabel(LABEL_DOTS);
    labelAttHeader.setFont(labelAttHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelAttHeader.setForeground(Color.GRAY);
    panelAttName.add(labelAttHeader);

    labelAttName = new JLabel(LABEL_DOTS);
    labelAttName.setFont(labelAttName.getFont().deriveFont(Font.BOLD, FONT_SIZE_LABEL_VALUE));
    labelAttName.setMinimumSize(DIMENSION_LABEL_ATTRIBUTE);
    labelAttName.setPreferredSize(DIMENSION_LABEL_ATTRIBUTE);
    panelAttName.add(labelAttName);

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.insets = new Insets(3, 20, 3, 10);
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 0.0;
    gbc.weighty = 1.0;
    gbc.gridheight = 2;
    add(panelAttName, gbc);

    // create value type name and bring it to a nice to read format (aka uppercase first letter
    // and replace '_' with ' '
    gbc.gridx += 1;
    gbc.insets = new Insets(5, 15, 5, 10);
    labelAttType = new JLabel(LABEL_DOTS);
    labelAttType.setMinimumSize(DIMENSION_LABEL_TYPE);
    labelAttType.setPreferredSize(DIMENSION_LABEL_TYPE);
    add(labelAttType, gbc);

    // missings panel
    JPanel panelStatsMissing = new JPanel();
    panelStatsMissing.setLayout(new BoxLayout(panelStatsMissing, BoxLayout.PAGE_AXIS));
    panelStatsMissing.setOpaque(false);

    labelStatsMissing = new JLabel(LABEL_DOTS);
    labelStatsMissing.setMinimumSize(DIMENSION_LABEL_MISSINGS);
    labelStatsMissing.setPreferredSize(DIMENSION_LABEL_MISSINGS);
    panelStatsMissing.add(labelStatsMissing);

    gbc.gridx += 1;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0.0;
    add(panelStatsMissing, gbc);

    // chart panel(s) (only visible when enlarged)
    JPanel chartPanel = new JPanel(new BorderLayout());
    chartPanel.setBackground(COLOR_TRANSPARENT);
    chartPanel.setOpaque(false);
    listOfChartPanels.add(chartPanel);
    updateVisibilityOfChartPanels();

    gbc.fill = GridBagConstraints.NONE;
    gbc.weighty = 0.0;
    gbc.insets = new Insets(0, 10, 0, 10);
    for (JPanel panel : listOfChartPanels) {
        gbc.gridx += 1;
        add(panel, gbc);
    }

    // (hidden) construction panel
    String constructionLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.construction.label");
    panelStatsConstruction = new JPanel();
    panelStatsConstruction.setLayout(new BoxLayout(panelStatsConstruction, BoxLayout.PAGE_AXIS));
    panelStatsConstruction.setOpaque(false);
    panelStatsConstruction.setVisible(false);

    JLabel labelConstructionHeader = new JLabel(constructionLabel);
    labelConstructionHeader.setFont(labelConstructionHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelConstructionHeader.setForeground(Color.GRAY);
    panelStatsConstruction.add(labelConstructionHeader);

    labelStatsConstruction = new JLabel(LABEL_DOTS);
    labelStatsConstruction.setFont(labelStatsConstruction.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    labelStatsConstruction.setMinimumSize(DIMENSION_LABEL_CONSTRUCTION);
    labelStatsConstruction.setPreferredSize(DIMENSION_LABEL_CONSTRUCTION);
    panelStatsConstruction.add(labelStatsConstruction);

    gbc.gridx += 1;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0.0;
    add(panelStatsConstruction, gbc);

    // statistics panel, contains different statistics panels for numerical/nominal/date_time on
    // a card layout
    // needed to switch between for model swapping
    cardStatsPanel = new JPanel();
    cardStatsPanel.setOpaque(false);
    cardLayout = new CardLayout();
    cardStatsPanel.setLayout(cardLayout);

    // numerical version
    JPanel statsNumPanel = new JPanel();
    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints gbcStatPanel = new GridBagConstraints();
    statsNumPanel.setLayout(layout);
    statsNumPanel.setOpaque(false);

    String avgLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.avg.label");
    String devianceLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.variance.label");
    String minLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.min.label");
    String maxLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.max.label");

    // min value panel
    JPanel panelStatsMin = new JPanel();
    panelStatsMin.setLayout(new BoxLayout(panelStatsMin, BoxLayout.PAGE_AXIS));
    panelStatsMin.setOpaque(false);

    JLabel labelMinHeader = new JLabel(minLabel);
    labelMinHeader.setFont(labelMinHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelMinHeader.setForeground(Color.GRAY);
    panelStatsMin.add(labelMinHeader);

    labelStatsMin = new JLabel(LABEL_DOTS);
    labelStatsMin.setFont(labelStatsMin.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsMin.add(labelStatsMin);

    // max value panel
    JPanel panelStatsMax = new JPanel();
    panelStatsMax.setLayout(new BoxLayout(panelStatsMax, BoxLayout.PAGE_AXIS));
    panelStatsMax.setOpaque(false);

    JLabel labelMaxHeader = new JLabel(maxLabel);
    labelMaxHeader.setFont(labelMaxHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelMaxHeader.setForeground(Color.GRAY);
    panelStatsMax.add(labelMaxHeader);

    labelStatsMax = new JLabel(LABEL_DOTS);
    labelStatsMax.setFont(labelStatsMax.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsMax.add(labelStatsMax);

    // average value panel
    JPanel panelStatsAvg = new JPanel();
    panelStatsAvg.setLayout(new BoxLayout(panelStatsAvg, BoxLayout.PAGE_AXIS));
    panelStatsAvg.setOpaque(false);

    JLabel labelAvgHeader = new JLabel(avgLabel);
    labelAvgHeader.setFont(labelAvgHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelAvgHeader.setForeground(Color.GRAY);
    panelStatsAvg.add(labelAvgHeader);

    labelStatsAvg = new JLabel(LABEL_DOTS);
    labelStatsAvg.setFont(labelStatsAvg.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsAvg.add(labelStatsAvg);

    // deviance value panel
    JPanel panelStatsDeviance = new JPanel();
    panelStatsDeviance.setLayout(new BoxLayout(panelStatsDeviance, BoxLayout.PAGE_AXIS));
    panelStatsDeviance.setOpaque(false);

    JLabel labelDevianceHeader = new JLabel(devianceLabel);
    labelDevianceHeader.setFont(labelDevianceHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelDevianceHeader.setForeground(Color.GRAY);
    panelStatsDeviance.add(labelDevianceHeader);

    labelStatsDeviation = new JLabel(LABEL_DOTS);
    labelStatsDeviation.setFont(labelStatsDeviation.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsDeviance.add(labelStatsDeviation);

    // add sub panels to stats panel
    gbcStatPanel.gridx = 0;
    gbcStatPanel.weightx = 0.0;
    gbcStatPanel.fill = GridBagConstraints.NONE;
    gbcStatPanel.insets = new Insets(0, 0, 0, 4);
    panelStatsMin.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE);
    statsNumPanel.add(panelStatsMin, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsMax.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE);
    statsNumPanel.add(panelStatsMax, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsAvg.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE);
    statsNumPanel.add(panelStatsAvg, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsDeviance.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE);
    statsNumPanel.add(panelStatsDeviance, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    gbcStatPanel.weightx = 1.0;
    gbcStatPanel.fill = GridBagConstraints.HORIZONTAL;
    statsNumPanel.add(new JLabel(), gbcStatPanel);
    cardStatsPanel.add(statsNumPanel, CARD_NUMERICAL);

    // nominal version
    JPanel statsNomPanel = new JPanel();
    statsNomPanel.setLayout(layout);
    statsNomPanel.setOpaque(false);
    String leastLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.least.label");
    String mostLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.most.label");
    String valuesLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.values.label");

    // least panel
    JPanel panelStatsLeast = new JPanel();
    panelStatsLeast.setLayout(new BoxLayout(panelStatsLeast, BoxLayout.PAGE_AXIS));
    panelStatsLeast.setOpaque(false);

    JLabel labelLeastHeader = new JLabel(leastLabel);
    labelLeastHeader.setFont(labelLeastHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelLeastHeader.setForeground(Color.GRAY);
    labelLeastHeader.setAlignmentX(Component.LEFT_ALIGNMENT);
    panelStatsLeast.add(labelLeastHeader);

    labelStatsLeast = new JLabel(LABEL_DOTS);
    labelStatsLeast.setFont(labelStatsLeast.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsLeast.add(labelStatsLeast);

    // most panel
    JPanel panelStatsMost = new JPanel();
    panelStatsMost.setLayout(new BoxLayout(panelStatsMost, BoxLayout.PAGE_AXIS));
    panelStatsMost.setOpaque(false);

    JLabel labelMostHeader = new JLabel(mostLabel);
    labelMostHeader.setFont(labelMostHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelMostHeader.setForeground(Color.GRAY);
    labelMostHeader.setAlignmentX(Component.LEFT_ALIGNMENT);
    panelStatsMost.add(labelMostHeader);

    labelStatsMost = new JLabel(LABEL_DOTS);
    labelStatsMost.setFont(labelStatsMost.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsMost.add(labelStatsMost);

    // values panel
    JPanel panelStatsValues = new JPanel();
    panelStatsValues.setLayout(new BoxLayout(panelStatsValues, BoxLayout.PAGE_AXIS));
    panelStatsValues.setOpaque(false);

    JLabel labelValuesHeader = new JLabel(valuesLabel);
    labelValuesHeader.setFont(labelValuesHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelValuesHeader.setForeground(Color.GRAY);
    labelValuesHeader.setAlignmentX(Component.LEFT_ALIGNMENT);
    panelStatsValues.add(labelValuesHeader);

    labelStatsValues = new JLabel(LABEL_DOTS);
    labelStatsValues.setFont(labelStatsValues.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsValues.add(labelStatsValues);

    detailsButton = new JButton(new ShowNomValueAction(this));
    detailsButton.setVisible(false);
    detailsButton.setOpaque(false);
    detailsButton.setContentAreaFilled(false);
    detailsButton.setBorderPainted(false);
    detailsButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
    detailsButton.setHorizontalAlignment(SwingConstants.LEFT);
    detailsButton.setHorizontalTextPosition(SwingConstants.LEFT);
    detailsButton.setIcon(null);
    Font font = detailsButton.getFont();
    Map attributes = font.getAttributes();
    attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
    detailsButton.setFont(font.deriveFont(attributes));
    panelStatsValues.add(detailsButton);

    // add sub panel to stats panel
    gbcStatPanel.gridx = 0;
    gbcStatPanel.weightx = 0.0;
    gbcStatPanel.fill = GridBagConstraints.NONE;
    gbcStatPanel.insets = new Insets(0, 0, 0, 6);
    panelStatsLeast.setPreferredSize(DIMENSION_PANEL_NOMINAL_PREF_SIZE);
    statsNomPanel.add(panelStatsLeast, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsMost.setPreferredSize(DIMENSION_PANEL_NOMINAL_PREF_SIZE);
    statsNomPanel.add(panelStatsMost, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    statsNomPanel.add(panelStatsValues, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    gbcStatPanel.weightx = 1.0;
    gbcStatPanel.fill = GridBagConstraints.HORIZONTAL;
    statsNomPanel.add(new JLabel(), gbcStatPanel);
    cardStatsPanel.add(statsNomPanel, CARD_NOMINAL);

    // date_time version
    JPanel statsDateTimePanel = new JPanel();
    statsDateTimePanel.setLayout(layout);
    statsDateTimePanel.setOpaque(false);

    String durationLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.duration.label");
    String fromLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.from.label");
    String untilLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.until.label");

    // min value panel
    JPanel panelStatsFrom = new JPanel();
    panelStatsFrom.setLayout(new BoxLayout(panelStatsFrom, BoxLayout.PAGE_AXIS));
    panelStatsFrom.setOpaque(false);

    JLabel labelFromHeader = new JLabel(fromLabel);
    labelFromHeader.setFont(labelFromHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelFromHeader.setForeground(Color.GRAY);
    panelStatsFrom.add(labelFromHeader);

    labelStatsFrom = new JLabel(LABEL_DOTS);
    labelStatsFrom.setFont(labelStatsFrom.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsFrom.add(labelStatsFrom);

    // until value panel
    JPanel panelStatsUntil = new JPanel();
    panelStatsUntil.setLayout(new BoxLayout(panelStatsUntil, BoxLayout.PAGE_AXIS));
    panelStatsUntil.setOpaque(false);

    JLabel labelUntilHeader = new JLabel(untilLabel);
    labelUntilHeader.setFont(labelUntilHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelUntilHeader.setForeground(Color.GRAY);
    panelStatsUntil.add(labelUntilHeader);

    labelStatsUntil = new JLabel(LABEL_DOTS);
    labelStatsUntil.setFont(labelStatsUntil.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsUntil.add(labelStatsUntil);

    // duration value panel
    JPanel panelStatsDuration = new JPanel();
    panelStatsDuration.setLayout(new BoxLayout(panelStatsDuration, BoxLayout.PAGE_AXIS));
    panelStatsDuration.setOpaque(false);

    JLabel labelDurationHeader = new JLabel(durationLabel);
    labelDurationHeader.setFont(labelDurationHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelDurationHeader.setForeground(Color.GRAY);
    panelStatsDuration.add(labelDurationHeader);

    labelStatsDuration = new JLabel(LABEL_DOTS);
    labelStatsDuration.setFont(labelStatsDuration.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsDuration.add(labelStatsDuration);

    // add sub panels to stats panel
    gbcStatPanel.gridx = 0;
    gbcStatPanel.weightx = 0.0;
    gbcStatPanel.fill = GridBagConstraints.NONE;
    gbcStatPanel.insets = new Insets(0, 0, 0, 6);
    panelStatsFrom.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE);
    statsDateTimePanel.add(panelStatsFrom, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsUntil.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE);
    statsDateTimePanel.add(panelStatsUntil, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsDuration.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE);
    statsDateTimePanel.add(panelStatsDuration, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    gbcStatPanel.weightx = 1.0;
    gbcStatPanel.fill = GridBagConstraints.HORIZONTAL;
    statsDateTimePanel.add(new JLabel(), gbcStatPanel);
    cardStatsPanel.add(statsDateTimePanel, CARD_DATE_TIME);

    // add stats panel to main gui
    gbc.gridx += 1;
    gbc.insets = new Insets(5, 10, 5, 10);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.anchor = GridBagConstraints.WEST;
    add(cardStatsPanel, gbc);

    // needed so we can draw our own background
    setOpaque(false);

    // handle mouse events for hover effect and enlarging/shrinking
    addMouseListener(enlargeAndHoverAndPopupMouseAdapter);

    // change cursor to indicate this component can be clicked
    setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}