Example usage for java.awt GridBagConstraints LINE_END

List of usage examples for java.awt GridBagConstraints LINE_END

Introduction

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

Prototype

int LINE_END

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

Click Source Link

Document

Place the component centered along the edge of its display area where lines of text would normally end for the current ComponentOrientation .

Usage

From source file:de.fhg.igd.iva.explorer.main.CompareViewPanel.java

protected void updateSelection() {
    KnownColormap colormap = (KnownColormap) mapsCombo.getSelectedItem();

    cmView.setColormap(colormap);/*  w ww  . j av  a2  s  .  co m*/

    statsBars.removeAll();

    Map<ColormapQuality, Double> row = table.row(colormap);

    Insets insets = new Insets(0, 0, 0, 0);
    Insets insets5 = new Insets(0, 5, 0, 0);

    GridBagConstraints gbcName = new GridBagConstraints(0, 0, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_START,
            GridBagConstraints.NONE, insets, 0, 0);
    GridBagConstraints gbcQual = new GridBagConstraints(1, 0, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END,
            GridBagConstraints.NONE, insets5, 0, 0);
    GridBagConstraints gbcRank = new GridBagConstraints(2, 0, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END,
            GridBagConstraints.NONE, insets5, 0, 0);
    GridBagConstraints gbcStatL = new GridBagConstraints(3, 0, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_START,
            GridBagConstraints.NONE, insets5, 0, 0);
    GridBagConstraints gbcStatR = new GridBagConstraints(4, 0, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_END,
            GridBagConstraints.NONE, insets5, 0, 0);
    GridBagConstraints gbcStat = new GridBagConstraints(3, 0, 2, 1, 1.0, 1.0, GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL, insets5, 0, 0);

    statsBars.add(new JLabel("Name"), gbcName);
    statsBars.add(new JLabel("Score"), gbcQual);
    statsBars.add(new JLabel("Rank"), gbcRank);

    // maybe use a best/worst arrow down marker instead? unicode: \u2193
    statsBars.add(new JLabel("\u2190Worse"), gbcStatL);
    statsBars.add(new JLabel("Better\u2192"), gbcStatR);

    GridBagConstraints gbcSpace = new GridBagConstraints(0, 1, 5, 1, 1.0, 1.0, GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0);
    JSeparator spacing = new JSeparator(SwingConstants.HORIZONTAL);
    statsBars.add(spacing, gbcSpace);

    int count = table.rowKeySet().size();

    int rowIdx = 2;
    for (ColormapQuality metric : row.keySet()) {
        double quality = row.get(metric);
        DescriptiveStatistics stats = computeStats(metric);
        int index = Arrays.binarySearch(stats.getSortedValues(), quality);

        int rank = metric.moreIsBetter() ? count - index : index + 1;

        gbcName = (GridBagConstraints) gbcName.clone();
        gbcQual = (GridBagConstraints) gbcQual.clone();
        gbcRank = (GridBagConstraints) gbcRank.clone();
        gbcStat = (GridBagConstraints) gbcStat.clone();

        gbcName.gridy = rowIdx;
        gbcQual.gridy = rowIdx;
        gbcRank.gridy = rowIdx;
        gbcStat.gridy = rowIdx;

        statsBars.add(new JLabel(metric.getName()), gbcName);
        statsBars.add(new JLabel(String.format("%.2f", quality)), gbcQual);
        statsBars.add(new JLabel(Integer.toString(rank)), gbcRank);
        statsBars.add(new JStatBar(metric, stats, quality), gbcStat);
        rowIdx++;
    }

    // I find it strange that both revalidate and repaint must be explicitly called here
    revalidate();
    repaint();
}

From source file:ImageOpByRomain.java

private void buildControlsPanel() {
    JPanel controls = new JPanel(new GridBagLayout());

    // red component
    controls.add(new JLabel("Red: 0"), new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_END,
            GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(redSlider = new JSlider(0, 255, 255), new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(new JLabel("255"), new GridBagConstraints(2, 0, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_START,
            GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    // green component
    controls.add(new JLabel("Green: 0"), new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0,
            GridBagConstraints.LINE_END, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(greenSlider = new JSlider(0, 255, 255), new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(new JLabel("255"), new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_START,
            GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    // blue component
    controls.add(new JLabel("Blue: 0"), new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0,
            GridBagConstraints.LINE_END, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(blueSlider = new JSlider(0, 255, 255), new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(new JLabel("255"), new GridBagConstraints(2, 2, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_START,
            GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    // mix value//w w  w.j  ava2  s  .  c  o m
    controls.add(new JLabel("Mix: 0%"), new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
            GridBagConstraints.LINE_END, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(alphaSlider = new JSlider(0, 100, 50), new GridBagConstraints(1, 3, 1, 1, 1.0, 1.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(new JLabel("100%"), new GridBagConstraints(2, 3, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_START,
            GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    // change listener
    ChangeListener colorChange = new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            imagePanel.setColor(new Color(redSlider.getValue(), greenSlider.getValue(), blueSlider.getValue()));
        }
    };
    redSlider.addChangeListener(colorChange);
    greenSlider.addChangeListener(colorChange);
    blueSlider.addChangeListener(colorChange);

    // alpha listener
    alphaSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            imagePanel.setMix((float) alphaSlider.getValue() / 100.0f);
        }
    });

    add(controls, BorderLayout.SOUTH);
}

From source file:Data.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*from   w  w  w .  j a  v  a 2s .com*/
 * @throws ClassNotFoundException 
 * @throws IOException 
 * @throws SQLException 
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
private void initComponents() throws ClassNotFoundException, IOException, SQLException {
    Connection dataFridge = getDbConnection();
    Statement stmt = dataFridge.createStatement();

    GridBagConstraints gridBagConstraints;

    panelPrincipal = new JPanel();
    panelCenter = new JPanel();
    panelHeader = new JPanel();
    btnHome = new JButton();
    dataList = new JComboBox();
    btnOk = new JButton();
    panelData = new JScrollPane();
    panelRealTime = new JPanel();
    tempRealTime = new JLabel();
    humRealTime = new JLabel();

    // Set unit temperature
    switch (param.tempUnitList.getSelectedIndex()) {
    case 0:
        tempUnit = "C";
        break;

    case 1:
        tempUnit = "F";
        break;

    default:
        break;
    }

    setPreferredSize(new Dimension(512, 400));
    setLayout(null);

    panelPrincipal.setPreferredSize(new Dimension(512, 400));
    panelPrincipal.setLayout(new BorderLayout());

    panelHeader.setPreferredSize(new Dimension(512, 40));
    panelHeader.setLayout(new GridBagLayout());

    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    InputStream input = classLoader.getResourceAsStream("home.png");
    Image iconeHome = ImageIO.read(input);

    btnHome.setIcon(new ImageIcon(iconeHome));
    btnHome.setPreferredSize(new Dimension(40, 40));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.anchor = GridBagConstraints.LINE_START;
    gridBagConstraints.insets = new Insets(0, 0, 0, 50);
    panelHeader.add(btnHome, gridBagConstraints);

    dataList.setModel(
            new DefaultComboBoxModel(new String[] { "Donnes en temps rel", "Graphique des temperatures" }));
    dataList.setPreferredSize(new Dimension(250, 40));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.anchor = GridBagConstraints.LINE_END;
    gridBagConstraints.insets = new Insets(0, 0, 0, 10);
    panelHeader.add(dataList, gridBagConstraints);

    btnOk.setFont(new Font("Tahoma", 0, 10)); // NOI18N
    btnOk.setText("OK");
    btnOk.setPreferredSize(new Dimension(60, 40));
    btnOk.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            btnOKActionPerformed(evt);
        }
    });
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.anchor = GridBagConstraints.LINE_START;
    gridBagConstraints.insets = new Insets(0, 5, 0, 70);
    panelHeader.add(btnOk, gridBagConstraints);

    panelPrincipal.add(panelHeader, BorderLayout.NORTH);
    panelCenter.setLayout(new BorderLayout());

    JFreeChart chart = createChart(createDataset(stmt));
    panelChart = new ChartPanel(chart);
    panelChart.setVisible(true);

    panelData = new JScrollPane(getTbleData(stmt));

    tempRealTime.setFont(new java.awt.Font("Meiryo UI", 1, 18)); // NOI18N
    humRealTime.setFont(new java.awt.Font("Meiryo UI", 1, 18)); // NOI18N

    panelRealTime.setLayout(new GridBagLayout());
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.insets = new Insets(18, 0, 0, 0);
    gridBagConstraints.anchor = GridBagConstraints.LINE_START;
    panelRealTime.add(tempRealTime, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.insets = new Insets(0, 0, 10, 0);
    gridBagConstraints.anchor = GridBagConstraints.LINE_START;
    panelRealTime.add(humRealTime, gridBagConstraints);

    panelCenter.add(panelRealTime, BorderLayout.NORTH);
    panelCenter.add(panelData, BorderLayout.CENTER);

    panelPrincipal.add(panelCenter, BorderLayout.CENTER);

    add(panelPrincipal);
    panelPrincipal.setBounds(0, 0, 512, 340);

    stmt.close();
    dataFridge.close();
}

From source file:edu.scripps.fl.pubchem.xmltool.gui.GUIComponent.java

public GridBagConstraints createGridBagConstraint(int gridx, int gridy, Component component, String position) {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = gridx;// w w  w . j  a v a2s. c o m
    gbc.gridy = gridy;
    gbc.ipady = 4;
    gbc.insets = new Insets(5, 5, 5, 5);
    if (position.equals("line start"))
        gbc.anchor = GridBagConstraints.LINE_START;
    else if (position.equals("center"))
        gbc.anchor = GridBagConstraints.CENTER;
    else if (position.equals("line end"))
        gbc.anchor = GridBagConstraints.LINE_END;
    return gbc;
}

From source file:com._17od.upm.gui.OptionsDialog.java

public OptionsDialog(JFrame frame) {
    super(frame, Translator.translate("options"), true);

    Container container = getContentPane();

    // Create a pane with an empty border for spacing
    Border emptyBorder = BorderFactory.createEmptyBorder(2, 5, 5, 5);
    JPanel emptyBorderPanel = new JPanel();
    emptyBorderPanel.setLayout(new BoxLayout(emptyBorderPanel, BoxLayout.Y_AXIS));
    emptyBorderPanel.setBorder(emptyBorder);
    container.add(emptyBorderPanel);//from w w w.  j  a v  a  2 s. co m

    // ******************
    // *** The DB TO Load On Startup Section
    // ******************
    // Create a pane with an title etched border
    Border etchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    Border etchedTitleBorder = BorderFactory.createTitledBorder(etchedBorder,
            ' ' + Translator.translate("general") + ' ');
    JPanel mainPanel = new JPanel(new GridBagLayout());
    mainPanel.setBorder(etchedTitleBorder);
    emptyBorderPanel.add(mainPanel);

    GridBagConstraints c = new GridBagConstraints();

    // The "Database to Load on Startup" row
    JLabel urlLabel = new JLabel(Translator.translate("dbToLoadOnStartup"));
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(urlLabel, c);

    // The "Database to Load on Startup" input field row
    dbToLoadOnStartup = new JTextField(Preferences.get(Preferences.ApplicationOptions.DB_TO_LOAD_ON_STARTUP),
            25);
    dbToLoadOnStartup.setHorizontalAlignment(JTextField.LEFT);
    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(dbToLoadOnStartup, c);

    JButton dbToLoadOnStartupButton = new JButton("...");
    dbToLoadOnStartupButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            getDBToLoadOnStartup();
        }
    });
    c.gridx = 1;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(0, 0, 5, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(dbToLoadOnStartupButton, c);

    // The "Language" label row
    JLabel localeLabel = new JLabel(Translator.translate("language"));
    c.gridx = 0;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(localeLabel, c);

    // The "Locale" field row
    localeComboBox = new JComboBox(getSupportedLocaleNames());
    for (int i = 0; i < localeComboBox.getItemCount(); i++) {
        // If the locale language is blank then set it to the English language
        // I'm not sure why this happens. Maybe it's because the default locale
        // is English???
        String currentLanguage = Translator.getCurrentLocale().getLanguage();
        if (currentLanguage.equals("")) {
            currentLanguage = "en";
        }

        if (currentLanguage.equals(Translator.SUPPORTED_LOCALES[i].getLanguage())) {
            localeComboBox.setSelectedIndex(i);
            break;
        }
    }
    c.gridx = 0;
    c.gridy = 3;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 8, 5);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(localeComboBox, c);

    // The "Hide account password" row
    Boolean hideAccountPassword = new Boolean(
            Preferences.get(Preferences.ApplicationOptions.ACCOUNT_HIDE_PASSWORD, "true"));
    hideAccountPasswordCheckbox = new JCheckBox(Translator.translate("hideAccountPassword"),
            hideAccountPassword.booleanValue());
    c.gridx = 0;
    c.gridy = 4;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 2, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(hideAccountPasswordCheckbox, c);

    // The "Database auto lock" row
    Boolean databaseAutoLock = new Boolean(
            Preferences.get(Preferences.ApplicationOptions.DATABASE_AUTO_LOCK, "false"));
    databaseAutoLockCheckbox = new JCheckBox(Translator.translate("databaseAutoLock"),
            databaseAutoLock.booleanValue());
    c.gridx = 0;
    c.gridy = 5;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 2, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(databaseAutoLockCheckbox, c);
    databaseAutoLockCheckbox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            databaseAutoLockTime.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    // The "Database auto lock" field row
    databaseAutoLockTime = new JTextField(
            Preferences.get(Preferences.ApplicationOptions.DATABASE_AUTO_LOCK_TIME), 5);
    c.gridx = 1;
    c.gridy = 5;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(databaseAutoLockTime, c);
    databaseAutoLockTime.setEnabled(databaseAutoLockCheckbox.isSelected());

    // The "Generated password length" row
    accountPasswordLengthLabel = new JLabel(Translator.translate("generatedPasswodLength"));
    c.gridx = 0;
    c.gridy = 6;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 2, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(accountPasswordLengthLabel, c);

    accountPasswordLength = new JTextField(
            Preferences.get(Preferences.ApplicationOptions.ACCOUNT_PASSWORD_LENGTH, "8"), 5);
    c.gridx = 1;
    c.gridy = 6;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(accountPasswordLength, c);

    // Some spacing
    emptyBorderPanel.add(Box.createVerticalGlue());

    // ******************
    // *** The HTTPS Section
    // ******************
    // Create a pane with an title etched border
    Border httpsEtchedTitleBorder = BorderFactory.createTitledBorder(etchedBorder, " HTTPS ");
    final JPanel httpsPanel = new JPanel(new GridBagLayout());
    httpsPanel.setBorder(httpsEtchedTitleBorder);
    emptyBorderPanel.add(httpsPanel);

    // The "Accept Self Sigend Certificates" checkbox row
    Boolean acceptSelfSignedCerts = new Boolean(
            Preferences.get(Preferences.ApplicationOptions.HTTPS_ACCEPT_SELFSIGNED_CERTS, "false"));
    acceptSelfSignedCertsCheckbox = new JCheckBox(Translator.translate("acceptSelfSignedCerts"),
            acceptSelfSignedCerts.booleanValue());
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 2, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    httpsPanel.add(acceptSelfSignedCertsCheckbox, c);

    // ******************
    // *** The Proxy Section
    // ******************
    // Create a pane with an title etched border
    Border proxyEtchedTitleBorder = BorderFactory.createTitledBorder(etchedBorder,
            ' ' + Translator.translate("httpProxy") + ' ');
    final JPanel proxyPanel = new JPanel(new GridBagLayout());
    proxyPanel.setBorder(proxyEtchedTitleBorder);
    emptyBorderPanel.add(proxyPanel);

    // The "Enable Proxy" row
    Boolean proxyEnabled = new Boolean(Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_ENABLED));
    enableProxyCheckbox = new JCheckBox(Translator.translate("enableProxy"), proxyEnabled.booleanValue());
    enableProxyCheckbox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                enableProxyComponents(true);
            } else {
                enableProxyComponents(false);
            }
        }
    });
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 2, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(enableProxyCheckbox, c);

    // The "HTTP Proxy" label row
    proxyLabel = new JLabel(Translator.translate("httpProxy"));
    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(proxyLabel, c);

    // The "HTTP Proxy Port" label
    proxyPortLabel = new JLabel(Translator.translate("port"));
    c.gridx = 1;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 5);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(proxyPortLabel, c);

    // The "HTTP Proxy" field row
    httpProxyHost = new JTextField(Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_HOST), 20);
    c.gridx = 0;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    proxyPanel.add(httpProxyHost, c);

    httpProxyPort = new JTextField(Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_PORT), 6);
    c.gridx = 1;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    proxyPanel.add(httpProxyPort, c);

    // The "HTTP Proxy Username" label row
    proxyUsernameLabel = new JLabel(Translator.translate("httpProxyUsername"));
    c.gridx = 0;
    c.gridy = 3;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(proxyUsernameLabel, c);

    // The "HTTP Proxy Username" field row
    httpProxyUsername = new JTextField(Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_USERNAME), 20);
    c.gridx = 0;
    c.gridy = 4;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.HORIZONTAL;
    proxyPanel.add(httpProxyUsername, c);

    // The "HTTP Proxy Password" label row
    proxyPasswordLabel = new JLabel(Translator.translate("httpProxyPassword"));
    c.gridx = 0;
    c.gridy = 5;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(proxyPasswordLabel, c);

    // The "HTTP Proxy Password" field row
    String encodedPassword = Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_PASSWORD);
    String decodedPassword = null;
    if (encodedPassword != null) {
        decodedPassword = new String(Base64.decodeBase64(encodedPassword.getBytes()));
    }
    httpProxyPassword = new JPasswordField(decodedPassword, 20);
    c.gridx = 0;
    c.gridy = 6;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    proxyPanel.add(httpProxyPassword, c);

    hidePasswordCheckbox = new JCheckBox(Translator.translate("hide"), true);
    defaultEchoChar = httpProxyPassword.getEchoChar();
    hidePasswordCheckbox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                httpProxyPassword.setEchoChar(defaultEchoChar);
            } else {
                httpProxyPassword.setEchoChar((char) 0);
            }
        }
    });
    c.gridx = 1;
    c.gridy = 6;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 0);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(hidePasswordCheckbox, c);

    // Some spacing
    emptyBorderPanel.add(Box.createVerticalGlue());

    // The buttons row
    JPanel buttonPanel = new JPanel(new FlowLayout());
    emptyBorderPanel.add(buttonPanel);
    JButton okButton = new JButton(Translator.translate("ok"));
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            okButtonAction();
        }
    });
    buttonPanel.add(okButton);

    JButton cancelButton = new JButton(Translator.translate("cancel"));
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
            dispose();
        }
    });
    buttonPanel.add(cancelButton);

    enableProxyComponents(proxyEnabled.booleanValue());
}

From source file:net.vanosten.dings.swing.SummaryView.java

private void initializeChartPropertiesPanel() {
    chartPropertiesP = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    chartPropertiesP.setLayout(gbl);//from www .  j a  v a  2  s .c  o m

    TitledBorder title;
    title = BorderFactory.createTitledBorder("Chart Properties");
    chartPropertiesP.setBorder(title);

    JLabel typeL = new JLabel("Chart Type:");
    typeL.setDisplayedMnemonic("C".charAt(0));
    typeL.setLabelFor(chartTypeCB);
    JLabel emptyL = new JLabel();

    Insets vghg = new Insets(DingsSwingConstants.SP_V_G, DingsSwingConstants.SP_H_G, 0, 0);
    //----type
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.LINE_END;
    gbc.insets = vghg;
    gbl.setConstraints(typeL, gbc);
    chartPropertiesP.add(typeL);
    //----
    gbc.gridx = 1;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbl.setConstraints(chartTypeCB, gbc);
    chartPropertiesP.add(chartTypeCB);
    //----
    gbc.gridx = 2;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbl.setConstraints(emptyL, gbc);
    chartPropertiesP.add(emptyL);
    //----chosen
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.weightx = 0.0;
    gbc.fill = GridBagConstraints.NONE;
    gbl.setConstraints(chosenCB, gbc);
    chartPropertiesP.add(chosenCB);
}

From source file:com.oracle.tutorial.jdbc.CoffeesFrame.java

public CoffeesFrame(JDBCTutorialUtilities settingsArg) throws SQLException {

    super("The Coffee Break: COFFEES Table"); // Set window title

    this.settings = settingsArg;
    connection = settings.getConnection();

    // Close connections exit the application when the user
    // closes the window

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {

            try {
                connection.close();//  w w  w .  j  a va 2s. c o m
            } catch (SQLException sqle) {
                JDBCTutorialUtilities.printSQLException(sqle);
            }
            System.exit(0);
        }
    });

    // Initialize and lay out window controls

    CachedRowSet myCachedRowSet = getContentsOfCoffeesTable();
    myCoffeesTableModel = new CoffeesTableModel(myCachedRowSet);
    myCoffeesTableModel.addEventHandlersToRowSet(this);

    table = new JTable(); // Displays the table
    table.setModel(myCoffeesTableModel);

    label_COF_NAME = new JLabel();
    label_SUP_ID = new JLabel();
    label_PRICE = new JLabel();
    label_SALES = new JLabel();
    label_TOTAL = new JLabel();

    textField_COF_NAME = new JTextField(10);
    textField_SUP_ID = new JTextField(10);
    textField_PRICE = new JTextField(10);
    textField_SALES = new JTextField(10);
    textField_TOTAL = new JTextField(10);

    button_ADD_ROW = new JButton();
    button_UPDATE_DATABASE = new JButton();
    button_DISCARD_CHANGES = new JButton();

    label_COF_NAME.setText("Coffee Name:");
    label_SUP_ID.setText("Supplier ID:");
    label_PRICE.setText("Price:");
    label_SALES.setText("Sales:");
    label_TOTAL.setText("Total Sales:");

    textField_COF_NAME.setText("Enter new coffee name");
    textField_SUP_ID.setText("101");
    textField_PRICE.setText("0");
    textField_SALES.setText("0");
    textField_TOTAL.setText("0");

    button_ADD_ROW.setText("Add row to table");
    button_UPDATE_DATABASE.setText("Update database");
    button_DISCARD_CHANGES.setText("Discard changes");

    // Place the components within the container contentPane; use GridBagLayout
    // as the layout.

    Container contentPane = getContentPane();
    contentPane.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    contentPane.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    c.weightx = 0.5;
    c.weighty = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    contentPane.add(new JScrollPane(table), c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.25;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    contentPane.add(label_COF_NAME, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = 1;
    contentPane.add(textField_COF_NAME, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.25;
    c.weighty = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    contentPane.add(label_SUP_ID, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 2;
    c.gridwidth = 1;
    contentPane.add(textField_SUP_ID, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.25;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 1;
    contentPane.add(label_PRICE, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 3;
    c.gridwidth = 1;
    contentPane.add(textField_PRICE, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.25;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 1;
    contentPane.add(label_SALES, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 4;
    c.gridwidth = 1;
    contentPane.add(textField_SALES, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.25;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 1;
    contentPane.add(label_TOTAL, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.75;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 5;
    c.gridwidth = 1;
    contentPane.add(textField_TOTAL, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.5;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 1;
    contentPane.add(button_ADD_ROW, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.weightx = 0.5;
    c.weighty = 0;
    c.gridx = 1;
    c.gridy = 6;
    c.gridwidth = 1;
    contentPane.add(button_UPDATE_DATABASE, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0.5;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 7;
    c.gridwidth = 1;
    contentPane.add(button_DISCARD_CHANGES, c);

    // Add listeners for the buttons in the application

    button_ADD_ROW.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            JOptionPane.showMessageDialog(CoffeesFrame.this, new String[] { "Adding the following row:",
                    "Coffee name: [" + textField_COF_NAME.getText() + "]",
                    "Supplier ID: [" + textField_SUP_ID.getText() + "]",
                    "Price: [" + textField_PRICE.getText() + "]", "Sales: [" + textField_SALES.getText() + "]",
                    "Total: [" + textField_TOTAL.getText() + "]" });

            try {

                myCoffeesTableModel.insertRow(textField_COF_NAME.getText(),
                        Integer.parseInt(textField_SUP_ID.getText().trim()),
                        Float.parseFloat(textField_PRICE.getText().trim()),
                        Integer.parseInt(textField_SALES.getText().trim()),
                        Integer.parseInt(textField_TOTAL.getText().trim()));
            } catch (SQLException sqle) {
                displaySQLExceptionDialog(sqle);
            }
        }
    });

    button_UPDATE_DATABASE.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {
                myCoffeesTableModel.coffeesRowSet.acceptChanges();
            } catch (SQLException sqle) {
                displaySQLExceptionDialog(sqle);
                // Now revert back changes
                try {
                    createNewTableModel();
                } catch (SQLException sqle2) {
                    displaySQLExceptionDialog(sqle2);
                }
            }
        }
    });

    button_DISCARD_CHANGES.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                createNewTableModel();
            } catch (SQLException sqle) {
                displaySQLExceptionDialog(sqle);
            }
        }
    });
}

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

public RunningFrame() {

    /* Initialization of the frame */
    setTitle("Gatling Recorder - Running...");
    setMinimumSize(new Dimension(800, 640));
    setLocationRelativeTo(null);/*from w w w .j  a v  a  2s . c o  m*/
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GridBagLayout gbl = new GridBagLayout();
    setLayout(gbl);

    setIconImages(Commons.getIconList());

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

From source file:it.cnr.icar.eric.client.ui.swing.AdhocQuerySearchPanel.java

@SuppressWarnings({ "rawtypes", "unchecked" })
private JPanel createQuerySelectionPanel() {
    JPanel querySelectionPanel = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    querySelectionPanel.setLayout(gbl);//from   w  ww  .  ja v a2 s.com

    //The selectQueryCombo
    selectQueryLabel = new JLabel(resourceBundle.getString("title.selectQuery"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(selectQueryLabel, c);
    querySelectionPanel.add(selectQueryLabel);

    //TODO: SwingBoost: localize this:
    selectQueryCombo = new JComboBox(new String[] { "loading queries..." });
    selectQueryCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ev) {
            RegistryBrowser.setWaitCursor();
            if (ev.getStateChange() == ItemEvent.DESELECTED) {
                return;
            }

            @SuppressWarnings("unused")
            String item = (String) ev.getItem();
            int index = ((JComboBox) ev.getSource()).getSelectedIndex();

            QueryType uiQueryType = queries.get(index);

            try {
                setQuery(uiQueryType);
            } catch (JAXRException e) {
                RegistryBrowser.setDefaultCursor();
                throw new UndeclaredThrowableException(e);
            }
            RegistryBrowser.setDefaultCursor();
        }
    });

    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(selectQueryCombo, c);
    querySelectionPanel.add(selectQueryCombo);

    //The nameTextField
    queryNameLabel = new JLabel(resourceBundle.getString("title.name"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(queryNameLabel, c);
    querySelectionPanel.add(queryNameLabel);

    queryNameText = new JTextField();
    queryNameText.setEditable(false);
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(queryNameText, c);
    querySelectionPanel.add(queryNameText);

    //The description TextArea
    queryDescLabel = new JLabel(resourceBundle.getString("title.description"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(queryDescLabel, c);
    querySelectionPanel.add(queryDescLabel);

    queryDescText = new JTextArea(4, 25);
    queryDescText.setLineWrap(true);
    queryDescText.setEditable(false);
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(queryDescText, c);
    querySelectionPanel.add(queryDescText);

    return querySelectionPanel;
}

From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java

@SuppressWarnings("unchecked")
private JPanel buildSimpleCentral(final String labelPie, final SaveOrUpdateAction guardar, final JFrame d) {
    JPanel central = new JPanel(new GridBagLayout());
    central.setOpaque(false);//w w  w. j av  a2 s .c  o m
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.insets = new Insets(2, 1, 2, 1);
    gbc.gridwidth = 1;
    central.add(Box.createVerticalStrut(10), gbc);

    gbc.gridy++;
    gbc.gridx = 0;
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel nombreLbl = new JLabel("Nombre:", SwingConstants.RIGHT);
    central.add(nombreLbl, gbc);
    gbc.gridx++;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(nombre, gbc);
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.gridwidth = 1;
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel apellidosLbl = new JLabel("Apellidos: ", SwingConstants.RIGHT);
    central.add(apellidosLbl, gbc);
    gbc.gridx++;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(apellidos, gbc);
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel rolLbl = new JLabel("Rol:", SwingConstants.RIGHT);
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.gridwidth = 1;
    central.add(rolLbl, gbc);
    gbc.gridx++;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(rol, gbc);
    gbc.gridwidth = 1;
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel contrasenyaLbl = new JLabel("Contrasea:", SwingConstants.RIGHT);
    gbc.gridy++;
    gbc.gridx = 0;
    central.add(contrasenyaLbl, gbc);
    gbc.gridx++;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(contrasenya, gbc);
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel contrasenya2Lbl = new JLabel("Repetir Contrasea:", SwingConstants.RIGHT);
    gbc.gridx++;
    central.add(contrasenya2Lbl, gbc);
    gbc.gridx++;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(repetir, gbc);
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel administradorLbl = new JLabel("Administrador:", SwingConstants.RIGHT);
    gbc.gridy++;
    gbc.gridx = 0;
    central.add(administradorLbl, gbc);
    gbc.gridx++;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(administrador, gbc);
    administrador.setOpaque(false);
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel habilitadoLbl = new JLabel("Habilitado", SwingConstants.RIGHT);
    gbc.gridx++;
    central.add(habilitadoLbl, gbc);
    gbc.gridx++;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(habilitado, gbc);
    habilitado.setOpaque(false);

    gbc.gridx = 0;
    gbc.gridy++;
    gbc.anchor = GridBagConstraints.LINE_END;
    JLabel labl_pie = new JLabel(labelPie, JLabel.LEFT);
    central.add(labl_pie, gbc);
    textfieldPie.setColumns(textfieldSize);
    labl_pie.setLabelFor(textfieldPie);
    gbc.gridx++;
    gbc.gridwidth = 4;
    gbc.anchor = GridBagConstraints.LINE_START;
    central.add(textfieldPie, gbc);

    gbc.gridy++;
    gbc.gridx = 0;
    central.add(Box.createVerticalStrut(10), gbc);

    gbc.gridwidth = 2;
    gbc.gridy++;
    gbc.gridx = 1;
    JPanel botones = getBotonesSalir(guardar, d, 250);
    central.add(botones, gbc);

    ((DefaultComboBoxModel) rol.getModel()).removeAllElements();
    for (String r : RolConsultas.getAllNames()) {
        ((DefaultComboBoxModel) rol.getModel()).addElement(r);
    }

    return central;
}