Example usage for javax.swing JPanel getPreferredSize

List of usage examples for javax.swing JPanel getPreferredSize

Introduction

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

Prototype

@Transient
public Dimension getPreferredSize() 

Source Link

Document

If the preferredSize has been set to a non-null value just returns it.

Usage

From source file:com.t3.client.ui.T3Frame.java

public void showControlPanel(JPanel... panels) {
    JPanel layoutPanel = new JPanel(new GridBagLayout());
    layoutPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));

    int i = 0;//from ww  w  .  j  a v a2 s.c o m
    for (JPanel panel : panels) {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = i;
        gbc.weightx = 1;
        gbc.fill = GridBagConstraints.BOTH;
        layoutPanel.add(panel, gbc);
        i++;
    }
    layoutPanel.setSize(layoutPanel.getPreferredSize());
    zoneRendererPanel.add(layoutPanel, PositionalLayout.Position.NE);
    zoneRendererPanel.setComponentZOrder(layoutPanel, 0);
    zoneRendererPanel.revalidate();
    zoneRendererPanel.repaint();
    visibleControlPanel = layoutPanel;
}

From source file:org.cds06.speleograph.graph.DateAxisEditor.java

public DateAxisEditor(DateAxis dateAxis) {
    super(SpeleoGraphApp.getInstance(), true);
    this.axis = dateAxis;
    this.setTitle(I18nSupport.translate("graph.dateAxisEditor"));
    JPanel panel = new JPanel();
    panel.setLayout(/*w w  w .ja  v  a  2 s  .  c  o m*/
            new FormLayout("r:p,4dlu,p:grow,4dlu", "p:grow,p,4dlu:grow,p,4dlu:grow,p,4dlu:grow,p,p:grow"));
    CellConstraints cc = new CellConstraints();
    panel.add(new JLabel("Format :"), cc.xy(1, 2));
    panel.add(dateSelector, cc.xy(3, 2));
    panel.add(new JLabel("Date dbut :"), cc.xy(1, 4));
    panel.add(minDate, cc.xy(3, 4));
    panel.add(new JLabel("Date fin :"), cc.xy(1, 6));
    panel.add(maxDate, cc.xy(3, 6));

    ButtonBarBuilder barBuilder = new ButtonBarBuilder();
    barBuilder.addGlue();

    //Cancel button
    barBuilder.addButton(new AbstractAction() {

        {
            putValue(NAME, I18nSupport.translate("cancel"));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
        }
    });

    //Ok button
    barBuilder.addButton(new AbstractAction() {

        {
            putValue(NAME, I18nSupport.translate("ok"));
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            axis.setDateFormatOverride((DateFormat) dateSelector.getSelectedItem());
            axis.setMinimumDate(minDate.getDate());
            axis.setMaximumDate(maxDate.getDate());
            setVisible(false);
        }
    });

    panel.add(barBuilder.build(), cc.xyw(1, 8, 3));

    minDate.setDate(dateAxis.getMinimumDate());
    maxDate.setDate(dateAxis.getMaximumDate());
    if (dateAxis.getDateFormatOverride() != null
            && dateAxis.getDateFormatOverride() instanceof HumanSimpleDateFormat) {
        dateSelector.setSelectedItem(dateAxis.getDateFormatOverride());
    }

    setContentPane(panel);
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    setSize(panel.getPreferredSize().width + 100, panel.getPreferredSize().height + 100);

}

From source file:net.rptools.maptool.launcher.MapToolLauncher.java

/**
 * This method is called from within the constructor to initialize the form
 * components./* ww  w. ja  va 2  s .co  m*/
 */
private void initComponents() {
    // Lee: for aesthetics and Linux won't display window controls on an untitled window.
    final String version = CopiedFromOtherJars.getVersion();
    setTitle(CopiedFromOtherJars.getText("msg.title.mainWindow", version)); //$NON-NLS-1$

    if (jbPathText == null)
        jbPathText = CopiedFromOtherJars.getText("msg.info.setJavaVersion"); //$NON-NLS-1$
    if (jbMTJarText == null)
        jbMTJarText = CopiedFromOtherJars.getText("msg.info.selectMapToolJar"); //$NON-NLS-1$
    if (mapToolJarName == null)
        mapToolJarName = CopiedFromOtherJars.getText("msg.info.selectMapToolJar"); //$NON-NLS-1$

    final Container cp = getContentPane();
    cp.setLayout(new BorderLayout());

    final JPanel basicPanel = buildBasicPanel();
    final JPanel langPanel = buildLanguagePanel();
    final JPanel advancedPanel = buildAdvancedPanel();
    final JPanel tsPanel = buildTroubleshootingPanel();

    mtlOptions.addTab(CopiedFromOtherJars.getText("msg.tab.basic"), basicPanel); //$NON-NLS-1$
    mtlOptions.addTab(CopiedFromOtherJars.getText("msg.tab.language"), langPanel); //$NON-NLS-1$
    mtlOptions.addTab(CopiedFromOtherJars.getText("msg.tab.advanced"), advancedPanel); //$NON-NLS-1$
    mtlOptions.addTab(CopiedFromOtherJars.getText("msg.tab.troubleshoot"), tsPanel); //$NON-NLS-1$

    cp.add(mtlOptions, BorderLayout.CENTER);
    cp.add(jtfCommand, BorderLayout.SOUTH);

    // Lee: user must register MT executable
    jbLaunch.setEnabled(
            !mapToolJarName.equalsIgnoreCase(CopiedFromOtherJars.getText("msg.info.selectMapToolJar"))); //$NON-NLS-1$

    jbLaunch.setText(CopiedFromOtherJars.getText("msg.info.launchMapTool")); //$NON-NLS-1$
    jbLaunch.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                jbLaunchActionPerformed(evt);
            } catch (final IOException e) {
                e.printStackTrace();
            }
        }
    });

    jtfCommand.setEditable(false);
    jtfCommand.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    jtfCommand.setText(CopiedFromOtherJars.getText("msg.info.cmdLineShownHere")); //$NON-NLS-1$
    jtfCommand.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(FocusEvent arg0) {
            jtfCommand.selectAll();
        }

        @Override
        public void focusLost(FocusEvent arg0) {
            jtfCommand.setCaretPosition(0);
        }
    });

    jcbKeepOpen.setSelected(false);
    jcbKeepOpen.setText(CopiedFromOtherJars.getText("msg.info.keepLauncherOpen")); //$NON-NLS-1$
    jcbKeepOpen.setToolTipText(CopiedFromOtherJars.getText("msg.tooltip.keepLauncherOpen")); //$NON-NLS-1$

    final JPanel lowerPanel = new JPanel();
    lowerPanel.setLayout(new GridLayout(3, 1));
    lowerPanel.setBorder(new LineBorder(Color.BLACK));
    lowerPanel.add(jbLaunch);
    lowerPanel.add(jcbKeepOpen);
    lowerPanel.add(jtfCommand);
    cp.add(lowerPanel, BorderLayout.SOUTH);

    mtlOptions.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            final JTabbedPane source = (JTabbedPane) e.getSource();
            final String tabName = source.getTitleAt(source.getSelectedIndex());

            if (jbLaunch.isEnabled()) {
                jbLaunch.requestFocusInWindow();
            } else {
                if (tabName.equals(CopiedFromOtherJars.getText("msg.tab.basic"))) { //$NON-NLS-1$
                    jbMTJar.requestFocusInWindow();
                } else if (tabName.equals(CopiedFromOtherJars.getText("msg.tab.language"))) { //$NON-NLS-1$
                    // This should work as long as there's at least one language in the list.
                    langGroup.getElements().nextElement().requestFocusInWindow();
                } else if (tabName.equals(CopiedFromOtherJars.getText("msg.tab.advanced"))) { //$NON-NLS-1$
                    jcbConsole.requestFocusInWindow();
                    jtfArgs.setText(extraArgs);
                } else {
                    jcbEnableAssertions.requestFocusInWindow();
                }
            }
        }
    });
    Dimension d = new Dimension(advancedPanel.getPreferredSize().width, 25);
    jtfArgs.setPreferredSize(d);
    //      mtlOptions.setPreferredSize(new Dimension(350, getPreferredSize().height));
    d.width = -1;
    d.height = -1;
    JLabel tabLabel = null;
    int tabs = mtlOptions.getTabCount();
    while (tabs-- > 0) {
        Component tab = mtlOptions.getTabComponentAt(tabs);
        if (tab == null) {
            if (tabLabel == null)
                tabLabel = new JLabel();
            tabLabel.setText(mtlOptions.getTitleAt(tabs));
            tab = tabLabel;
        }
        Dimension dim = tab.getPreferredSize();
        d.width = Math.max(dim.width, d.width);
        d.height = Math.max(dim.height, d.height);
    }
    // Set width to width of largest tab * number of tabs, then add 20%.
    d.width = d.width * 120 / 100 * mtlOptions.getTabCount();
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setIconImage(icon.getImage());

    // To prevent the tabs from wrapping or scrolling
    setMinimumSize(new Dimension(d.width, getSize().height));
    pack();
    setResizable(true);
}

From source file:org.esa.beam.visat.toolviews.stat.StatisticsPanel.java

private JPanel getRightPanel() {

    computePanel = new MultipleRoiComputePanel(this, getRaster());

    final JPanel rightPanel = GridBagUtils.createPanel();

    final JPanel mainPane = GridBagUtils.createPanel();

    //  GridBagConstraints extendedOptionsPanelConstraints = GridBagUtils.createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1,insets.right=-2");
    GridBagConstraints extendedOptionsPanelConstraints = GridBagUtils
            .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1");

    GridBagUtils.addToPanel(rightPanel, computePanel, extendedOptionsPanelConstraints,
            "gridy=0,fill=NONE,weighty=1,weightx=1");

    //  GridBagUtils.addToPanel(rightPanel, statisticsCriteriaPanel.getCriteriaFormattingTabbedPane(), extendedOptionsPanelConstraints, "gridy=1,fill=BOTH,weighty=0, insets.top=10");

    computePanel.getCriteriaPanel().setBorder(UIUtils.createGroupBorder(""));

    GridBagUtils.addToPanel(computePanel.getCriteriaPanel(), statisticsCriteriaPanel.getCriteriaPanel(),
            extendedOptionsPanelConstraints, "insets.top=10, insets.left=5, insets.right=5");

    JButton resetToDefaultsButton = new JButton("Reset");
    resetToDefaultsButton.addActionListener(new ActionListener() {
        @Override//from  w  ww.j av  a 2  s .c om
        public void actionPerformed(ActionEvent e) {
            statisticsCriteriaPanel.reset();
        }
    });

    runButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            computePanel.run();
        }
    });

    runButton.setEnabled(getRaster() != null);

    exportButton = getExportButton();
    exportButton.setToolTipText("Export: This only exports the binning portion of the statistics");
    exportButton.setVisible(exportButtonVisible);

    final JPanel exportAndHelpPanel = GridBagUtils.createPanel();
    GridBagConstraints helpPanelConstraints = GridBagUtils
            .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1,ipadx=0");
    GridBagUtils.addToPanel(exportAndHelpPanel, new JSeparator(), helpPanelConstraints,
            "fill=HORIZONTAL,gridwidth=4,insets.left=5,insets.right=5");
    GridBagUtils.addToPanel(exportAndHelpPanel, exportButton, helpPanelConstraints,
            "gridy=1,anchor=WEST,fill=NONE, gridwidth=1");
    GridBagUtils.addToPanel(exportAndHelpPanel, runButton, helpPanelConstraints,
            "gridx=1, gridy=1,anchor=WEST,fill=NONE");
    GridBagUtils.addToPanel(exportAndHelpPanel, resetToDefaultsButton, helpPanelConstraints,
            "gridx=2, gridy=1,anchor=CENTER,fill=NONE");
    GridBagUtils.addToPanel(exportAndHelpPanel, getHelpButton(), helpPanelConstraints,
            "gridx=3,gridy=1,anchor=EAST,fill=NONE");

    GridBagUtils.addToPanel(rightPanel, exportAndHelpPanel, extendedOptionsPanelConstraints,
            "gridy=2,anchor=SOUTHWEST,fill=HORIZONTAL,weighty=0,insets.top=0");

    rightPanel.setMinimumSize(rightPanel.getPreferredSize());

    return rightPanel;
}

From source file:ffx.ui.ModelingPanel.java

private void loadCommand() {
    synchronized (this) {
        // Force Field X Command
        Element command;/*www .  j a va  2s  . co  m*/
        // Command Options
        NodeList options;
        Element option;
        // Option Values
        NodeList values;
        Element value;
        // Options may be Conditional based on previous Option values (not
        // always supplied)
        NodeList conditionalList;
        Element conditional;
        // JobPanel GUI Components that change based on command
        JPanel optionPanel;
        // Clear the previous components
        commandPanel.removeAll();
        optionsTabbedPane.removeAll();
        conditionals.clear();
        String currentCommand = (String) currentCommandBox.getSelectedItem();
        if (currentCommand == null) {
            commandPanel.validate();
            commandPanel.repaint();
            return;
        }
        command = null;
        for (int i = 0; i < commandList.getLength(); i++) {
            command = (Element) commandList.item(i);
            String name = command.getAttribute("name");
            if (name.equalsIgnoreCase(currentCommand)) {
                break;
            }
        }
        int div = splitPane.getDividerLocation();
        descriptTextArea.setText(currentCommand.toUpperCase() + ": " + command.getAttribute("description"));
        splitPane.setBottomComponent(descriptScrollPane);
        splitPane.setDividerLocation(div);
        // The "action" tells Force Field X what to do when the
        // command finishes
        commandActions = command.getAttribute("action").trim();
        // The "fileType" specifies what file types this command can execute
        // on
        String string = command.getAttribute("fileType").trim();
        String[] types = string.split(" +");
        commandFileTypes.clear();
        for (String type : types) {
            if (type.contains("XYZ")) {
                commandFileTypes.add(FileType.XYZ);
            }
            if (type.contains("INT")) {
                commandFileTypes.add(FileType.INT);
            }
            if (type.contains("ARC")) {
                commandFileTypes.add(FileType.ARC);
            }
            if (type.contains("PDB")) {
                commandFileTypes.add(FileType.PDB);
            }
            if (type.contains("ANY")) {
                commandFileTypes.add(FileType.ANY);
            }
        }
        // Determine what options are available for this command
        options = command.getElementsByTagName("Option");
        int length = options.getLength();
        for (int i = 0; i < length; i++) {
            // This Option will be enabled (isEnabled = true) unless a
            // Conditional disables it
            boolean isEnabled = true;
            option = (Element) options.item(i);
            conditionalList = option.getElementsByTagName("Conditional");
            /*
             * Currently, there can only be 0 or 1 Conditionals per Option
             * There are three types of Conditionals implemented. 1.)
             * Conditional on a previous Option, this option may be
             * available 2.) Conditional on input for this option, a
             * sub-option may be available 3.) Conditional on the presence
             * of keywords, this option may be available
             */
            if (conditionalList != null) {
                conditional = (Element) conditionalList.item(0);
            } else {
                conditional = null;
            }
            // Get the command line flag
            String flag = option.getAttribute("flag").trim();
            // Get the description
            String optionDescript = option.getAttribute("description");
            JTextArea optionTextArea = new JTextArea("  " + optionDescript.trim());
            optionTextArea.setEditable(false);
            optionTextArea.setLineWrap(true);
            optionTextArea.setWrapStyleWord(true);
            optionTextArea.setBorder(etchedBorder);
            // Get the default for this Option (if one exists)
            String defaultOption = option.getAttribute("default");
            // Option Panel
            optionPanel = new JPanel(new BorderLayout());
            optionPanel.add(optionTextArea, BorderLayout.NORTH);
            String swing = option.getAttribute("gui");
            JPanel optionValuesPanel = new JPanel(new FlowLayout());
            optionValuesPanel.setBorder(etchedBorder);
            ButtonGroup bg = null;
            if (swing.equalsIgnoreCase("CHECKBOXES")) {
                // CHECKBOXES allows selection of 1 or more values from a
                // predefined set (Analyze, for example)
                values = option.getElementsByTagName("Value");
                for (int j = 0; j < values.getLength(); j++) {
                    value = (Element) values.item(j);
                    JCheckBox jcb = new JCheckBox(value.getAttribute("name"));
                    jcb.addMouseListener(this);
                    jcb.setName(flag);
                    if (defaultOption != null && jcb.getActionCommand().equalsIgnoreCase(defaultOption)) {
                        jcb.setSelected(true);
                    }
                    optionValuesPanel.add(jcb);
                }
            } else if (swing.equalsIgnoreCase("TEXTFIELD")) {
                // TEXTFIELD takes an arbitrary String as input
                JTextField jtf = new JTextField(20);
                jtf.addMouseListener(this);
                jtf.setName(flag);
                if (defaultOption != null && defaultOption.equals("ATOMS")) {
                    FFXSystem sys = mainPanel.getHierarchy().getActive();
                    if (sys != null) {
                        jtf.setText("" + sys.getAtomList().size());
                    }
                } else if (defaultOption != null) {
                    jtf.setText(defaultOption);
                }
                optionValuesPanel.add(jtf);
            } else if (swing.equalsIgnoreCase("RADIOBUTTONS")) {
                // RADIOBUTTONS allows one choice from a set of predifined
                // values
                bg = new ButtonGroup();
                values = option.getElementsByTagName("Value");
                for (int j = 0; j < values.getLength(); j++) {
                    value = (Element) values.item(j);
                    JRadioButton jrb = new JRadioButton(value.getAttribute("name"));
                    jrb.addMouseListener(this);
                    jrb.setName(flag);
                    bg.add(jrb);
                    if (defaultOption != null && jrb.getActionCommand().equalsIgnoreCase(defaultOption)) {
                        jrb.setSelected(true);
                    }
                    optionValuesPanel.add(jrb);
                }
            } else if (swing.equalsIgnoreCase("PROTEIN")) {
                // Protein allows selection of amino acids for the protein
                // builder
                optionValuesPanel.setLayout(new BoxLayout(optionValuesPanel, BoxLayout.Y_AXIS));
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                optionValuesPanel.add(getAminoAcidPanel());
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                acidComboBox.removeAllItems();
                JButton add = new JButton("Edit");
                add.setActionCommand("PROTEIN");
                add.addActionListener(this);
                add.setAlignmentX(Button.CENTER_ALIGNMENT);
                JPanel comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
                comboPanel.add(acidTextField);
                comboPanel.add(add);
                optionValuesPanel.add(comboPanel);
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                JButton remove = new JButton("Remove");
                add.setMinimumSize(remove.getPreferredSize());
                add.setPreferredSize(remove.getPreferredSize());
                remove.setActionCommand("PROTEIN");
                remove.addActionListener(this);
                remove.setAlignmentX(Button.CENTER_ALIGNMENT);
                comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
                comboPanel.add(acidComboBox);
                comboPanel.add(remove);
                optionValuesPanel.add(comboPanel);
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                optionValuesPanel.add(acidScrollPane);
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                JButton reset = new JButton("Reset");
                reset.setActionCommand("PROTEIN");
                reset.addActionListener(this);
                reset.setAlignmentX(Button.CENTER_ALIGNMENT);
                optionValuesPanel.add(reset);
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                acidTextArea.setText("");
                acidTextField.setText("");
            } else if (swing.equalsIgnoreCase("NUCLEIC")) {
                // Nucleic allows selection of nucleic acids for the nucleic
                // acid builder
                optionValuesPanel.setLayout(new BoxLayout(optionValuesPanel, BoxLayout.Y_AXIS));
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                optionValuesPanel.add(getNucleicAcidPanel());
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                acidComboBox.removeAllItems();
                JButton add = new JButton("Edit");
                add.setActionCommand("NUCLEIC");
                add.addActionListener(this);
                add.setAlignmentX(Button.CENTER_ALIGNMENT);
                JPanel comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
                comboPanel.add(acidTextField);
                comboPanel.add(add);
                optionValuesPanel.add(comboPanel);
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                JButton remove = new JButton("Remove");
                add.setMinimumSize(remove.getPreferredSize());
                add.setPreferredSize(remove.getPreferredSize());
                remove.setActionCommand("NUCLEIC");
                remove.addActionListener(this);
                remove.setAlignmentX(Button.CENTER_ALIGNMENT);
                comboPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
                comboPanel.add(acidComboBox);
                comboPanel.add(remove);
                optionValuesPanel.add(comboPanel);
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                optionValuesPanel.add(acidScrollPane);
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                JButton button = new JButton("Reset");
                button.setActionCommand("NUCLEIC");
                button.addActionListener(this);
                button.setAlignmentX(Button.CENTER_ALIGNMENT);
                optionValuesPanel.add(button);
                optionValuesPanel.add(Box.createRigidArea(new Dimension(0, 5)));
                acidTextArea.setText("");
                acidTextField.setText("");
            } else if (swing.equalsIgnoreCase("SYSTEMS")) {
                // SYSTEMS allows selection of an open system
                JComboBox<FFXSystem> jcb = new JComboBox<>(mainPanel.getHierarchy().getNonActiveSystems());
                jcb.setSize(jcb.getMaximumSize());
                jcb.addActionListener(this);
                optionValuesPanel.add(jcb);
            }
            // Set up a Conditional for this Option
            if (conditional != null) {
                isEnabled = false;
                String conditionalName = conditional.getAttribute("name");
                String conditionalValues = conditional.getAttribute("value");
                String cDescription = conditional.getAttribute("description");
                String cpostProcess = conditional.getAttribute("postProcess");
                if (conditionalName.toUpperCase().startsWith("KEYWORD")) {
                    optionPanel.setName(conditionalName);
                    String keywords[] = conditionalValues.split(" +");
                    if (activeSystem != null) {
                        Hashtable<String, Keyword> systemKeywords = activeSystem.getKeywords();
                        for (String key : keywords) {
                            if (systemKeywords.containsKey(key.toUpperCase())) {
                                isEnabled = true;
                            }
                        }
                    }
                } else if (conditionalName.toUpperCase().startsWith("VALUE")) {
                    isEnabled = true;
                    // Add listeners to the values of this option so
                    // the conditional options can be disabled/enabled.
                    for (int j = 0; j < optionValuesPanel.getComponentCount(); j++) {
                        JToggleButton jtb = (JToggleButton) optionValuesPanel.getComponent(j);
                        jtb.addActionListener(this);
                        jtb.setActionCommand("Conditional");
                    }
                    JPanel condpanel = new JPanel();
                    condpanel.setBorder(etchedBorder);
                    JLabel condlabel = new JLabel(cDescription);
                    condlabel.setEnabled(false);
                    condlabel.setName(conditionalValues);
                    JTextField condtext = new JTextField(10);
                    condlabel.setLabelFor(condtext);
                    if (cpostProcess != null) {
                        condtext.setName(cpostProcess);
                    }
                    condtext.setEnabled(false);
                    condpanel.add(condlabel);
                    condpanel.add(condtext);
                    conditionals.add(condlabel);
                    optionPanel.add(condpanel, BorderLayout.SOUTH);
                } else if (conditionalName.toUpperCase().startsWith("REFLECTION")) {
                    String[] condModifiers;
                    if (conditionalValues.equalsIgnoreCase("AltLoc")) {
                        condModifiers = activeSystem.getAltLocations();
                        if (condModifiers != null && condModifiers.length > 1) {
                            isEnabled = true;
                            bg = new ButtonGroup();
                            for (int j = 0; j < condModifiers.length; j++) {
                                JRadioButton jrbmi = new JRadioButton(condModifiers[j]);
                                jrbmi.addMouseListener(this);
                                bg.add(jrbmi);
                                optionValuesPanel.add(jrbmi);
                                if (j == 0) {
                                    jrbmi.setSelected(true);
                                }
                            }
                        }
                    } else if (conditionalValues.equalsIgnoreCase("Chains")) {
                        condModifiers = activeSystem.getChainNames();
                        if (condModifiers != null && condModifiers.length > 0) {
                            isEnabled = true;
                            for (int j = 0; j < condModifiers.length; j++) {
                                JRadioButton jrbmi = new JRadioButton(condModifiers[j]);
                                jrbmi.addMouseListener(this);
                                bg.add(jrbmi);
                                optionValuesPanel.add(jrbmi, j);
                            }
                        }
                    }
                }
            }
            optionPanel.add(optionValuesPanel, BorderLayout.CENTER);
            optionPanel.setPreferredSize(optionPanel.getPreferredSize());
            optionsTabbedPane.addTab(option.getAttribute("name"), optionPanel);
            optionsTabbedPane.setEnabledAt(optionsTabbedPane.getTabCount() - 1, isEnabled);
        }
    }
    optionsTabbedPane.setPreferredSize(optionsTabbedPane.getPreferredSize());
    commandPanel.setLayout(borderLayout);
    commandPanel.add(optionsTabbedPane, BorderLayout.CENTER);
    commandPanel.validate();
    commandPanel.repaint();
    loadLogSettings();
    statusLabel.setText("  " + createCommandInput());
}

From source file:org.apache.jmeter.protocol.http.config.gui.UrlConfigGui.java

/**
 * This method defines the Panel for the HTTP path, 'Follow Redirects'
 * 'Use KeepAlive', and 'Use multipart for HTTP POST' elements.
 *
 * @return JPanel The Panel for the path, 'Follow Redirects' and 'Use
 *         KeepAlive' elements./*  w  ww. j  av  a  2 s . c om*/
 */
protected Component getPathPanel() {
    path = new JTextField(15);

    JLabel label = new JLabel(JMeterUtils.getResString("path")); //$NON-NLS-1$
    label.setLabelFor(path);

    if (notConfigOnly) {
        followRedirects = new JCheckBox(JMeterUtils.getResString("follow_redirects")); // $NON-NLS-1$
        followRedirects.setFont(null);
        followRedirects.setSelected(true);
        followRedirects.addChangeListener(this);

        autoRedirects = new JCheckBox(JMeterUtils.getResString("follow_redirects_auto")); //$NON-NLS-1$
        autoRedirects.setFont(null);
        autoRedirects.addChangeListener(this);
        autoRedirects.setSelected(false);// Default changed in 2.3 and again in 2.4

        useKeepAlive = new JCheckBox(JMeterUtils.getResString("use_keepalive")); // $NON-NLS-1$
        useKeepAlive.setFont(null);
        useKeepAlive.setSelected(true);

        useMultipartForPost = new JCheckBox(JMeterUtils.getResString("use_multipart_for_http_post")); // $NON-NLS-1$
        useMultipartForPost.setFont(null);
        useMultipartForPost.setSelected(false);

        useBrowserCompatibleMultipartMode = new JCheckBox(
                JMeterUtils.getResString("use_multipart_mode_browser")); // $NON-NLS-1$
        useBrowserCompatibleMultipartMode.setFont(null);
        useBrowserCompatibleMultipartMode
                .setSelected(HTTPSamplerBase.BROWSER_COMPATIBLE_MULTIPART_MODE_DEFAULT);

    }

    JPanel pathPanel = new HorizontalPanel();
    pathPanel.add(label);
    pathPanel.add(path);

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(pathPanel);
    if (notConfigOnly) {
        JPanel optionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        optionPanel.setFont(FONT_SMALL); // all sub-components with setFont(null) inherit this font
        optionPanel.add(autoRedirects);
        optionPanel.add(followRedirects);
        optionPanel.add(useKeepAlive);
        optionPanel.add(useMultipartForPost);
        optionPanel.add(useBrowserCompatibleMultipartMode);
        optionPanel.setMinimumSize(optionPanel.getPreferredSize());
        panel.add(optionPanel);
    }

    return panel;
}

From source file:org.apache.jmeter.protocol.http.config.gui.UrlConfigGui.java

protected JPanel getProtocolAndMethodPanel() {

    // Implementation
    if (showImplementation) {
        httpImplementation = new JLabeledChoice(JMeterUtils.getResString("http_implementation"), // $NON-NLS-1$
                HTTPSamplerFactory.getImplementations());
        httpImplementation.addValue("");
    }/*from  w w w  . j  av a 2 s  .co m*/

    // PROTOCOL
    protocol = new JTextField(4);
    JLabel protocolLabel = new JLabel(JMeterUtils.getResString("protocol")); // $NON-NLS-1$
    protocolLabel.setLabelFor(protocol);

    // CONTENT_ENCODING
    contentEncoding = new JTextField(10);
    JLabel contentEncodingLabel = new JLabel(JMeterUtils.getResString("content_encoding")); // $NON-NLS-1$
    contentEncodingLabel.setLabelFor(contentEncoding);

    if (notConfigOnly) {
        method = new JLabeledChoice(JMeterUtils.getResString("method"), // $NON-NLS-1$
                HTTPSamplerBase.getValidMethodsAsArray(), true, false);
        method.addChangeListener(this);
    }

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));

    if (showImplementation) {
        panel.add(httpImplementation);
    }
    panel.add(protocolLabel);
    panel.add(protocol);
    panel.add(Box.createHorizontalStrut(5));

    if (notConfigOnly) {
        panel.add(method);
    }
    panel.setMinimumSize(panel.getPreferredSize());
    panel.add(Box.createHorizontalStrut(5));

    panel.add(contentEncodingLabel);
    panel.add(contentEncoding);
    panel.setMinimumSize(panel.getPreferredSize());
    return panel;
}

From source file:org.apache.jmeter.protocol.http.config.gui.UrlConfigGuiClassifier.java

/**
 * This method defines the Panel for the HTTP path, 'Follow Redirects'
 * 'Use KeepAlive', and 'Use multipart for HTTP POST' elements.
 *
 * @return JPanel The Panel for the path, 'Follow Redirects' and 'Use
 *         KeepAlive' elements./*  ww  w  . j a va 2s. co  m*/
 */
protected Component getPathPanel() {
    path = new JTextField(15);

    JLabel label = new JLabel(JMeterUtils.getResString("path")); //$NON-NLS-1$
    label.setLabelFor(path);

    if (notConfigOnly) {
        followRedirects = new JCheckBox(JMeterUtils.getResString("follow_redirects")); // $NON-NLS-1$
        followRedirects.setSelected(true);
        followRedirects.addChangeListener(this);

        autoRedirects = new JCheckBox(JMeterUtils.getResString("follow_redirects_auto")); //$NON-NLS-1$
        autoRedirects.addChangeListener(this);
        autoRedirects.setSelected(false);// Default changed in 2.3 and again in 2.4

        useKeepAlive = new JCheckBox(JMeterUtils.getResString("use_keepalive")); // $NON-NLS-1$
        useKeepAlive.setSelected(true);

        useMultipartForPost = new JCheckBox(JMeterUtils.getResString("use_multipart_for_http_post")); // $NON-NLS-1$
        useMultipartForPost.setSelected(false);

        useBrowserCompatibleMultipartMode = new JCheckBox(
                JMeterUtils.getResString("use_multipart_mode_browser")); // $NON-NLS-1$
        useBrowserCompatibleMultipartMode
                .setSelected(HTTPSamplerBase.BROWSER_COMPATIBLE_MULTIPART_MODE_DEFAULT);

    }

    JPanel pathPanel = new JPanel(new BorderLayout(5, 0));
    pathPanel.add(label, BorderLayout.WEST);
    pathPanel.add(path, BorderLayout.CENTER);
    pathPanel.setMinimumSize(pathPanel.getPreferredSize());

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(pathPanel);
    if (notConfigOnly) {
        JPanel optionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        optionPanel.add(autoRedirects);
        optionPanel.add(followRedirects);
        optionPanel.add(useKeepAlive);
        optionPanel.add(useMultipartForPost);
        optionPanel.add(useBrowserCompatibleMultipartMode);
        optionPanel.setMinimumSize(optionPanel.getPreferredSize());
        panel.add(optionPanel);
    }

    return panel;
}

From source file:org.apache.jmeter.protocol.http.config.gui.UrlConfigGuiClassifier.java

protected JPanel getProtocolAndMethodPanel() {

    // Implementation

    if (showImplementation) {
        httpImplementation = new JLabeledChoice(JMeterUtils.getResString("http_implementation"), // $NON-NLS-1$
                HTTPSamplerFactory.getImplementations());
        httpImplementation.addValue("");
    }//www .ja v  a 2  s.  c om
    // PROTOCOL
    protocol = new JTextField(4);
    JLabel protocolLabel = new JLabel(JMeterUtils.getResString("protocol")); // $NON-NLS-1$
    protocolLabel.setLabelFor(protocol);

    // CONTENT_ENCODING
    contentEncoding = new JTextField(10);
    JLabel contentEncodingLabel = new JLabel(JMeterUtils.getResString("content_encoding")); // $NON-NLS-1$
    contentEncodingLabel.setLabelFor(contentEncoding);

    if (notConfigOnly) {
        method = new JLabeledChoice(JMeterUtils.getResString("method"), // $NON-NLS-1$
                HTTPSamplerBase.getValidMethodsAsArray());
    }

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));

    if (showImplementation) {
        panel.add(httpImplementation);
    }
    panel.add(protocolLabel);
    panel.add(protocol);
    panel.add(Box.createHorizontalStrut(5));

    if (notConfigOnly) {
        panel.add(method);
    }
    panel.setMinimumSize(panel.getPreferredSize());
    panel.add(Box.createHorizontalStrut(5));

    panel.add(contentEncodingLabel);
    panel.add(contentEncoding);
    panel.setMinimumSize(panel.getPreferredSize());
    return panel;
}

From source file:org.drugis.addis.gui.components.progressgraph.ProgressGraph.java

public JPanel createPanel() {
    final FormLayout layout = new FormLayout(createFormSpec("pref", d_numCols),
            "p, " + createFormSpec("3dlu, p", d_numTotalRows - 1));
    CellConstraints cc = new CellConstraints();
    JPanel progressPanel = new JPanel(layout);
    Dimension cellSize = new Dimension(d_edgeLength, d_arrowSize);
    Dimension circleSize = new Dimension(d_circleDiameter, d_circleDiameter);

    for (int i = 0; i < d_numberOfChains; ++i) {
        int rowIdx = (2 * i) + 1;
        Task tuningTask = d_model.getModel().getActivityTask().getModel()
                .getStateByName(MCMCModel.TUNING_CHAIN_PREFIX + i);
        progressPanel.add(new GraphLine(cellSize, 2, SwingConstants.EAST), cc.xy(6, rowIdx));
        progressPanel.add(new GraphProgressNode(d_gridCellSize, tuningTask), cc.xy(7, rowIdx));
        Task simulationTask = d_model.getModel().getActivityTask().getModel()
                .getStateByName(MCMCModel.SIMULATION_CHAIN_PREFIX + i);
        progressPanel.add(new GraphLine(new Dimension(d_edgeLength * 2, d_arrowSize), 2, SwingConstants.EAST),
                cc.xy(9, rowIdx));//from  w w w.j  a  v  a  2 s. c o  m
        progressPanel.add(new GraphProgressNode(d_gridCellSize, simulationTask), cc.xy(10, rowIdx));
        progressPanel.add(new GraphLine(cellSize, 2, SwingConstants.EAST), cc.xy(11, rowIdx));
    }

    /** Placement needed for the calculated preferred size */
    progressPanel.add(new GraphSimpleNode(circleSize, GraphSimpleNodeType.START),
            centerCell(cc, d_numMainRows, 1));
    progressPanel.add(new GraphLine(cellSize, 2, SwingConstants.EAST), centerCell(cc, d_numMainRows, 2));
    Task startTask = d_model.getModel().getActivityTask().getModel()
            .getStateByName(MCMCModel.STARTING_SIMULATION_PHASE);
    progressPanel.add(new GraphProgressNode(d_gridCellSize, startTask, false),
            centerCell(cc, d_numMainRows, 3));
    progressPanel.add(new GraphLine(cellSize, 2, SwingConstants.EAST), centerCell(cc, d_numMainRows, 4));
    //NOTE: it is a mystery why numMainRows - 1 is the correct count instead of just numMainRows
    progressPanel.add(
            new GraphBar(new Dimension(d_barWidth, (int) progressPanel.getPreferredSize().getHeight())),
            centerCell(cc, d_numMainRows - 1, 5));
    progressPanel.add(
            new GraphBar(new Dimension(d_barWidth, (int) progressPanel.getPreferredSize().getHeight())),
            centerCell(cc, d_numMainRows - 1, 12));
    Task assessConvergence = d_model.getModel().getActivityTask().getModel()
            .getStateByName(MCMCModel.CALCULATING_SUMMARIES_PHASE);
    progressPanel.add(new GraphLine(cellSize, 2, SwingConstants.EAST), centerCell(cc, d_numMainRows, 13));
    progressPanel.add(new GraphProgressNode(d_gridCellSize, assessConvergence, false),
            centerCell(cc, d_numMainRows, 14));
    progressPanel.add(new GraphLine(new Dimension(d_arrowSize, 50), 2, SwingConstants.SOUTH), cc.xywh(14,
            d_numMainRows / 2 + 2, 1, d_numMainRows / 2 + 1, CellConstraints.CENTER, CellConstraints.BOTTOM));
    progressPanel.add(new GraphSimpleNode(circleSize, GraphSimpleNodeType.DECISION),
            cc.xywh(14, d_numMainRows + 2, 1, 1, CellConstraints.CENTER, CellConstraints.CENTER));
    progressPanel.add(
            new GraphLine(new Dimension((int) (d_edgeLength + (d_edgeLength)), d_arrowSize), 2,
                    SwingConstants.EAST),
            cc.xyw(14, d_numMainRows + 2, 2, CellConstraints.RIGHT, CellConstraints.DEFAULT));
    progressPanel.add(new GraphSimpleNode(circleSize, GraphSimpleNodeType.END), cc.xy(16, d_numMainRows + 2));
    progressPanel.add(new GraphLine(new Dimension(d_edgeLength * 9, d_arrowSize), 2, SwingConstants.WEST),
            cc.xyw(10, d_numMainRows + 2, 14 - 7, CellConstraints.LEFT, CellConstraints.DEFAULT));
    progressPanel.add(new GraphBar(new Dimension(d_edgeLength * 2, d_barWidth)), cc.xy(9, d_numMainRows + 2));

    int totalHeight = (int) progressPanel.getPreferredSize().getHeight();
    progressPanel.add(
            new GraphConnector(new Dimension(d_edgeLength * 2, totalHeight),
                    d_cellHeight + Sizes.DLUY3.getPixelSize(progressPanel), totalHeight - 30, d_numberOfChains),
            cc.xywh(9, 1, 1, d_numTotalRows));

    PanelBuilder builder = new PanelBuilder(new FormLayout("pref", "p"));
    builder.setDefaultDialogBorder();
    builder.add(progressPanel);
    return builder.getPanel();
}