Example usage for javax.swing.border TitledBorder TitledBorder

List of usage examples for javax.swing.border TitledBorder TitledBorder

Introduction

In this page you can find the example usage for javax.swing.border TitledBorder TitledBorder.

Prototype

public TitledBorder(Border border) 

Source Link

Document

Creates a TitledBorder instance with the specified border and an empty title.

Usage

From source file:edu.clemson.cs.nestbed.client.gui.TestbedManagerFrame.java

private final JPanel buildTestbedPanel() throws RemoteException {
    JPanel testbedPanel = new JPanel(new BorderLayout());
    testbedPanel.setBorder(new TitledBorder("Physical Deployments"));

    // --- left-side -------------------------------------------------
    JPanel sidePanel = new JPanel(new BorderLayout());
    sidePanel.setPreferredSize(new Dimension(WINDOW_WIDTH / 3, SIZE_IGNORED));

    testbedList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    testbedList.setListData(testbedManager.getTestbedList().toArray());
    testbedList.addListSelectionListener(new TestbedListSelectionListener());

    sidePanel.add(new JScrollPane(testbedList), BorderLayout.CENTER);
    testbedPanel.add(sidePanel, BorderLayout.WEST);

    // --- right-side ------------------------------------------------
    sidePanel = new JPanel(new BorderLayout());
    sidePanel.setPreferredSize(new Dimension(310, SIZE_IGNORED));

    JPanel rsTopPanel = new JPanel(new BorderLayout());
    rsTopPanel.setPreferredSize(new Dimension(SIZE_IGNORED, 50));

    JPanel labelPanel = new JPanel(new GridLayout(2, 1, 0, 5));
    labelPanel.add(new JLabel("Name:  "));
    labelPanel.add(new JLabel("Description:  "));

    JPanel infoPanel = new JPanel(new GridLayout(2, 1, 0, 5));
    infoPanel.add(testbedName);/*from   w  w  w.  j  ava2s.  c  o m*/
    testbedName.setEditable(false);

    infoPanel.add(testbedDescription);
    testbedDescription.setEditable(false);

    rsTopPanel.add(labelPanel, BorderLayout.WEST);
    rsTopPanel.add(infoPanel, BorderLayout.CENTER);

    sidePanel.add(rsTopPanel, BorderLayout.NORTH);

    testbedPanel.add(sidePanel, BorderLayout.EAST);

    return testbedPanel;
}

From source file:com.floreantpos.main.SetUpWindow.java

private JPanel createUserPanel() {
    JPanel userPanel = new JPanel(new MigLayout("fill,hidemode 3", "[150px][fill, grow]", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    userPanel.setVisible(false);//from  w w w .j a  v a  2 s .  c o  m
    userPanel.setBorder(new TitledBorder(Messages.getString("SetUpWindow.16"))); //$NON-NLS-1$

    lblId = new JLabel();
    lblFirstName = new JLabel();
    lblLastName = new JLabel();
    lblSecretKey = new JLabel();
    lblConfirmSecretKey = new JLabel();
    tfPassword1 = new JPasswordField(new FixedLengthDocument(16), "", 5); //$NON-NLS-1$
    tfPassword2 = new JPasswordField(new FixedLengthDocument(16), "", 5); //$NON-NLS-1$
    tfUserId = new FixedLengthTextField();
    tfFirstName = new FixedLengthTextField();
    tfFirstName.setColumns(20);
    tfFirstName.setLength(30);
    tfLastName = new FixedLengthTextField();
    tfLastName.setLength(30);
    tfLastName.setColumns(20);

    lblId.setText("ID"); //$NON-NLS-1$
    userPanel.add(lblId, "aligny center"); //$NON-NLS-1$
    userPanel.add(tfUserId, "growx,aligny center,wrap"); //$NON-NLS-1$

    lblFirstName.setText("First Name"); //$NON-NLS-1$
    userPanel.add(lblFirstName, "aligny center"); //$NON-NLS-1$
    userPanel.add(tfFirstName, "growx,aligny center,split 3"); //$NON-NLS-1$

    lblLastName.setText("Last Name"); //$NON-NLS-1$
    userPanel.add(lblLastName, "aligny center"); //$NON-NLS-1$
    userPanel.add(tfLastName, "growx,aligny ,w 200!,center,wrap"); //$NON-NLS-1$

    lblSecretKey.setText("Secret Key"); //$NON-NLS-1$
    userPanel.add(lblSecretKey, "aligny center"); //$NON-NLS-1$
    userPanel.add(tfPassword1, "growx,aligny center,split 3"); //$NON-NLS-1$

    lblConfirmSecretKey.setText("Confirm Secret Key"); //$NON-NLS-1$
    userPanel.add(lblConfirmSecretKey, "aligny center"); //$NON-NLS-1$
    userPanel.add(tfPassword2, "growx,w 200!,aligny center"); //$NON-NLS-1$

    return userPanel;
}

From source file:GeometryByReferenceNIOBuffer.java

JPanel createGeometryByReferencePanel() {
    JPanel panel = new JPanel();
    panel.setBorder(new TitledBorder("Geometry Type"));

    String values[] = { "Array", "Strip", "Indexed", "IndexedStrip" };
    geomType = new JComboBox(values);
    geomType.setLightWeightPopupEnabled(false);
    geomType.addActionListener(this);
    geomType.setSelectedIndex(0);//from   w ww . j  av a2 s  .  co m
    panel.add(new JLabel("Geometry Type"));
    panel.add(geomType);

    return panel;
}

From source file:lu.lippmann.cdb.common.gui.ts.TimeSeriesChartUtil.java

public static ChartPanel buildChartPanelForAllAttributesInterval(final Instances dataSet, final int dateIdx,
        final double deviation, final int deviatedAttrIdx) {
    final YIntervalSeriesCollection tsDataset = new YIntervalSeriesCollection();
    final JFreeChart tsChart = ChartFactory.createTimeSeriesChart("", "Time", "Value", tsDataset, true, true,
            false);/*from w ww .  j  ava  2  s .  c o  m*/
    tsChart.getXYPlot().setBackgroundPaint(Color.WHITE);

    double startgap0 = -1d;
    double endgap0 = -1d;
    try {
        java.util.List<double[]> gaps = WekaTimeSeriesUtil.findGaps(dataSet, deviatedAttrIdx);
        startgap0 = gaps.get(0)[2] + gaps.get(0)[3];
        //System.out.println("start -> "+startgap0);
        endgap0 = gaps.get(1)[2] - 1;
        //System.out.println("end -> "+endgap0);
    } catch (Exception e) {
        e.printStackTrace();
    }
    final double startgap = startgap0;
    final double endgap = endgap0;
    System.out.println("gap --> " + startgap + " " + endgap);

    tsChart.getXYPlot().setRenderer(/*deviatedAttrIdx,*/new DeviationRenderer(true, false) {
        /** */
        private static final long serialVersionUID = 1234L;

        private boolean inRange(final int item) {
            return (item >= startgap && item <= endgap);
        }

        @Override
        public boolean getItemShapeVisible(int series, int item) {
            return false;
        }

        @Override
        public boolean getItemLineVisible(int series, int item) {
            return inRange(item);
        }

    });
    for (int i = 0; i < dataSet.numAttributes() - 1; i++) {
        //final Color cc=ColorHelper.COLORBREWER_ALL_QUALITATIVE[i];
        final Color cc = ColorHelper.getColorForAString(dataSet.attribute(i).name());
        tsChart.getXYPlot().getRenderer().setSeriesPaint(i, cc);
        ((AbstractRenderer) tsChart.getXYPlot().getRenderer()).setSeriesFillPaint(i, cc.brighter());
    }

    fillWithSingleAxisInterval(dataSet, dateIdx, tsDataset, deviation, deviatedAttrIdx);

    final ChartPanel cp = new ChartPanel(tsChart, true);
    if (dataSet.numAttributes() <= 2)
        cp.setBorder(new TitledBorder(dataSet.attribute(0).name()));
    return cp;
}

From source file:GeometryByReferenceNIOBuffer.java

JPanel createUpdatePanel() {

    JPanel panel = new JPanel();
    panel.setBorder(new TitledBorder("Other Attributes"));

    String updateComp[] = { "None", "Geometry", "Color" };

    transparency = new JCheckBox("EnableTransparency", false);
    transparency.addActionListener(this);
    panel.add(transparency);/*from   w  w w. j  a v a  2s. c  o m*/

    updates = new JComboBox(updateComp);
    updates.setLightWeightPopupEnabled(false);
    updates.addActionListener(this);
    updates.setSelectedIndex(0);
    panel.add(new JLabel("UpdateData"));
    panel.add(updates);

    return panel;
}

From source file:dk.dma.epd.common.prototype.notification.StrategicRouteNotificationDetailPanelCommon.java

/**
 * Create the panel.//from  w  ww  .  j a  va2 s .  c  o m
 * 
 * @param title the title of the message panel
 * @param routeMessage the request message
 * @param routeChanges the route changes
 * @param the index of the message with 0 being the latest
 */
public StrategicNotificationMessageView(String title, StrategicRouteMessage routeMessage, String routeChanges,
        int index) {

    super(new GridBagLayout());

    boolean isLatest = index == 0;
    if (!isLatest) {
        setBackground(Color.darkGray);
    }

    Insets insets0 = new Insets(0, 0, 0, 0);
    Insets insets1 = new Insets(5, 5, 5, 5);

    // *************************
    // Create the title panel
    // *************************
    JPanel titlePanel = new JPanel(new GridBagLayout());
    add(titlePanel, new GridBagConstraints(0, 0, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets0, 0, 0));

    // Title
    if (isLatest) {
        titlePanel.setBackground(titlePanel.getBackground().darker());
    }
    titlePanel.add(bold(new JLabel(title)),
            new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets1, 0, 0));
    titlePanel.add(new JLabel(Formatter.formatLongDateTime(routeMessage.getSentDate())),
            new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, EAST, NONE, insets1, 0, 0));

    // Type
    CloudMessageStatus cloudStatus = isLatest ? routeMessage.getCloudMessageStatus() : null;
    add(new JLabel("Status:"), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0));
    add(new JLabel(StrategicRouteNotificationDetailPanelCommon.getStatusType(routeMessage.getStatus(),
            cloudStatus, false)), new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0));

    // Message label
    if (!StringUtils.isBlank(routeMessage.getMessage())) {
        JLabel msgLabel = new JLabel("<html>" + Formatter.formatHtml(routeMessage.getMessage()) + "</html>");
        msgLabel.setBorder(new TitledBorder("Message"));
        add(msgLabel, new GridBagConstraints(0, 2, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets1, 0, 0));
    }

    // Route changes
    if (!StringUtils.isBlank(routeChanges)) {
        JLabel routeLabel = new JLabel("<html>" + Formatter.formatHtml(routeChanges) + "</html>");
        routeLabel.setBorder(new TitledBorder("Route changes"));
        add(routeLabel, new GridBagConstraints(0, 3, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets1, 0, 0));
    }
}

From source file:com.funambol.admin.settings.panels.EditServerConfigurationPanel.java

/**
 * Create the panel/*w w  w .  j av  a  2  s .  c  o m*/
 * @throws Exception if error occures during creation of the panel.
 */
private void init() throws Exception {
    final int dy = 25;
    int y = 25;

    int x1 = 15;
    int w1 = 140;
    int w2 = 350;
    int dx = 21;

    int x2 = x1 + w1 + dx;

    setAutoscrolls(true);
    setLayout(null);
    setName(Bundle.getMessage(Bundle.EDIT_SERVER_CONFIGURATION_PANEL_NAME));

    panelNameLabel.setText(Bundle.getMessage(Bundle.EDIT_SERVER_CONFIGURATION_PANEL_NAME));
    panelNameLabel.setBounds(new Rectangle(14, 5, 216, 28));
    panelNameLabel.setAlignmentX(SwingConstants.CENTER);
    panelNameLabel.setBorder(new TitledBorder(""));

    y += dy;

    titleSectionDevInfo.setText(Bundle.getMessage(Bundle.LABEL_DEV_INF));
    titleSectionDevInfo.setBounds(new Rectangle(14, y, 162, 28));
    titleSectionDevInfo.setAlignmentX(SwingConstants.CENTER);
    titleSectionDevInfo.setBorder(new TitledBorder(""));

    y += dy;
    y += 10;

    manLabel.setText(Bundle.getMessage(Bundle.LABEL_MAN) + " :");
    manLabel.setBounds(new Rectangle(x1, y, w1, 18));
    man.setBounds(new Rectangle(x2, y, w2, 18));

    y += dy;

    modLabel.setText(Bundle.getMessage(Bundle.LABEL_MOD) + " :");
    modLabel.setBounds(new Rectangle(x1, y, w1, 18));
    mod.setBounds(new Rectangle(x2, y, w2, 18));

    y += dy;

    swVLabel.setText(Bundle.getMessage(Bundle.LABEL_SWV) + " :");
    swVLabel.setBounds(new Rectangle(x1, y, w1, 18));
    swV.setBounds(new Rectangle(x2, y, w2, 18));
    swV.setEditable(false);

    y += dy;

    hwVLabel.setText(Bundle.getMessage(Bundle.LABEL_HWV) + " :");
    hwVLabel.setBounds(new Rectangle(x1, y, w1, 18));
    hwV.setBounds(new Rectangle(x2, y, w2, 18));

    y += dy;

    fwVLabel.setText(Bundle.getMessage(Bundle.LABEL_FWV) + " :");
    fwVLabel.setBounds(new Rectangle(x1, y, w1, 18));
    fwV.setBounds(new Rectangle(x2, y, w2, 18));

    y += dy;

    oemLabel.setText(Bundle.getMessage(Bundle.LABEL_OEM) + " :");
    oemLabel.setBounds(new Rectangle(x1, y, w1, 18));
    oem.setBounds(new Rectangle(x2, y, w2, 18));

    y += dy;

    devIdLabel.setText(Bundle.getMessage(Bundle.LABEL_DEV_ID) + " :");
    devIdLabel.setBounds(new Rectangle(x1, y, w1, 18));
    devId.setBounds(new Rectangle(x2, y, w2, 18));

    y += dy;

    devTypLabel.setText(Bundle.getMessage(Bundle.LABEL_DEV_TYP) + " :");
    devTypLabel.setBounds(new Rectangle(x1, y, w1, 18));
    devTyp.setBounds(new Rectangle(x2, y, w2, 18));

    y += dy;

    verDTDLabel.setText(Bundle.getMessage(Bundle.LABEL_VER_DTD) + " :");
    verDTDLabel.setBounds(new Rectangle(x1, y, w1, 18));
    verDTD.setBounds(new Rectangle(x2, y, w2, 18));

    y += dy;
    y += 10;

    titleSectionEngineInfo.setText(Bundle.getMessage(Bundle.LABEL_ENGINE_INFO));
    titleSectionEngineInfo.setBounds(new Rectangle(14, y, 162, 28));
    titleSectionEngineInfo.setAlignmentX(SwingConstants.CENTER);
    titleSectionEngineInfo.setBorder(new TitledBorder(""));

    y += 10;
    y += dy;

    serverUriLabel.setText(Bundle.getMessage(Bundle.LABEL_SERVER_URI) + " :");
    serverUriLabel.setBounds(new Rectangle(x1, y, w1, 18));
    serverUri.setBounds(new Rectangle(x2, y, w2, 18));

    y += dy;

    officerLabel.setText(Bundle.getMessage(Bundle.LABEL_OFFICER) + " :");
    officerLabel.setBounds(new Rectangle(x1, y, w1, 18));
    officer.setBounds(new Rectangle(x2, y, w2, 18));

    y += dy;

    handlerLabel.setText(Bundle.getMessage(Bundle.LABEL_HANDLER) + " :");
    handlerLabel.setBounds(new Rectangle(x1, y, w1, 18));
    handler.setBounds(new Rectangle(x2, y, w2, 18));

    y += dy;

    deviceInventoryLabel.setText(Bundle.getMessage(Bundle.LABEL_DEVICE_INVENTORY) + " :");
    deviceInventoryLabel.setBounds(new Rectangle(x1, y, w1, 18));
    deviceInventory.setBounds(new Rectangle(x2, y, w2, 18));

    y += dy;

    dataTransformerManagerLabel.setText(Bundle.getMessage(Bundle.LABEL_DATA_TRANSFORMER_MANAGER) + " :");
    dataTransformerManagerLabel.setBounds(new Rectangle(x1, y, w1, 18));
    dataTransformerManager.setBounds(new Rectangle(x2, y, w2, 18));
    dataTransformerButton.setBounds(new Rectangle(x2 + w2 + 10, y, 85, 18));
    dataTransformerButton.setText(Bundle.getMessage(Bundle.DATA_TRANSFORMER_CONFIGURE_BUTTON));
    dataTransformerButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String path = dataTransformerManager.getText();
            try {
                ExplorerUtil.getSyncAdminController().getServerSettingsController()
                        .editDataTrasnformerConfiguration(path);
            } catch (AdminException ex) {
                String msg = Bundle.getMessage(Bundle.ERROR_GETTING_DTM_CONFIGURATION);
                NotifyDescriptor desc = new NotifyDescriptor.Message(ex.getMessage());
                DialogDisplayer.getDefault().notify(desc);

                Log.error(msg, ex);

                return;
            }
        }
    });

    y += dy;

    strategyLabel.setText(Bundle.getMessage(Bundle.LABEL_STRATEGY) + " :");
    strategyLabel.setBounds(new Rectangle(x1, y, w1, 18));
    strategy.setBounds(new Rectangle(x2, y, w2, 18));
    strategyButton.setBounds(new Rectangle(x2 + w2 + 10, y, 85, 18));
    strategyButton.setText(Bundle.getMessage(Bundle.LABEL_BUTTON_CONFIGURE));
    strategyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String path = strategy.getText();
            try {
                ExplorerUtil.getSyncAdminController().getServerSettingsController()
                        .editStrategyConfiguration(path);
            } catch (AdminException ex) {
                String msg = Bundle.getMessage(Bundle.ERROR_GETTING_STRATEGY_CONFIGURATION);
                NotifyDescriptor desc = new NotifyDescriptor.Message(ex.getMessage());
                DialogDisplayer.getDefault().notify(desc);

                Log.error(msg, ex);

                return;
            }
        }
    });

    y += dy;

    userManagerLabel.setText(Bundle.getMessage(Bundle.LABEL_USER_MANAGER) + " :");
    userManagerLabel.setBounds(new Rectangle(x1, y, w1, 18));
    userManager.setBounds(new Rectangle(x2, y, w2, 18));

    y += dy;

    smsServiceLabel.setText(Bundle.getMessage(Bundle.LABEL_SMS_SERVICE) + " :");
    smsServiceLabel.setBounds(new Rectangle(x1, y, w1, 18));
    smsService.setBounds(new Rectangle(x2, y, w2, 18));

    y += dy;

    minMaxMsgSizeLabel.setText(Bundle.getMessage(Bundle.LABEL_MIN_MAX_MSG_SIZE) + " :");
    minMaxMsgSizeLabel.setBounds(new Rectangle(x1, y, w1, 18));
    minMaxMsgSize.setBounds(new Rectangle(x2, y, w2, 18));

    y += dy;

    checkForUpdatesLabel.setText(Bundle.getMessage(Bundle.LABEL_CHECK_FOR_UPDATES) + " :");
    checkForUpdatesLabel.setBounds(new Rectangle(x1, y, w1, 18));
    checkForUpdates.setBounds(new Rectangle(x2, y, w2, 18));

    y += dy;
    y += dy;

    confirmButton.setText(Bundle.getMessage(Bundle.LABEL_BUTTON_SAVE));
    confirmButton.setBounds(new Rectangle(225, y, 60, 25));

    confirmButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setServerConfiguration();
        }
    });

    cancelButton = new JButton(Bundle.getMessage(Bundle.LABEL_BUTTON_CANCEL));
    cancelButton.setBounds(290, y, 70, 25);

    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            cancelAction();
        }
    });

    //add components to panel
    add(panelNameLabel, null);
    add(titleSectionDevInfo, null);
    add(manLabel, null);
    add(man, null);
    add(modLabel, null);
    add(mod, null);
    add(swVLabel, null);
    add(swV, null);
    add(hwVLabel, null);
    add(hwV, null);
    add(fwVLabel, null);
    add(fwV, null);
    add(oemLabel, null);
    add(oem, null);
    add(devIdLabel, null);
    add(devId, null);
    add(devTypLabel, null);
    add(devTyp, null);
    add(verDTDLabel, null);
    add(verDTD, null);
    add(titleSectionEngineInfo, null);
    add(serverUriLabel, null);
    add(serverUri, null);
    add(officerLabel, null);
    add(officer, null);
    add(handlerLabel, null);
    add(handler, null);
    add(deviceInventoryLabel, null);
    add(deviceInventory, null);
    add(dataTransformerManagerLabel, null);
    add(dataTransformerManager, null);
    add(dataTransformerButton, null);
    add(strategyLabel, null);
    add(strategy, null);
    add(strategyButton, null);
    add(userManagerLabel, null);
    add(userManager, null);
    add(smsServiceLabel, null);
    add(smsService, null);
    add(minMaxMsgSizeLabel, null);
    add(minMaxMsgSize, null);
    add(checkForUpdatesLabel, null);
    add(checkForUpdates, null);
    add(confirmButton, null);
    add(cancelButton, null);

    GuiFactory.setDefaultFont(this);

    panelNameLabel.setFont(GuiFactory.titlePanelFont);
    titleSectionEngineInfo.setFont(new java.awt.Font("Arial", 2, 12));
    titleSectionDevInfo.setFont(new java.awt.Font("Arial", 2, 12));

}

From source file:InterleavedNIOBuffer.java

JPanel createGeometryByReferencePanel() {
    JPanel panel = new JPanel();
    panel.setBorder(new TitledBorder("Geometry Type"));

    String values[] = { "Array", "Strip", "Indexed", "IndexedStrip" };
    geomType = new JComboBox(values);
    geomType.setLightWeightPopupEnabled(false);
    geomType.addActionListener(this);
    geomType.setSelectedIndex(0);//from  w  ww . ja v a2 s .  c o m
    panel.add(new JLabel("Geometry Type"));
    panel.add(geomType);

    transparency = new JCheckBox("EnableTransparency", false);
    transparency.addActionListener(this);
    panel.add(transparency);

    textureBox = new JCheckBox("EnableTexture", false);
    textureBox.addActionListener(this);
    panel.add(textureBox);

    return panel;
}

From source file:com.funambol.foundation.admin.PIMSyncSourceConfigPanel.java

/**
 * Creates the panel's components and layout.
 * @todo adjust layout//from  w  w w . j a  v a  2 s  . c om
 */
private void init() {
    // set layout
    this.setLayout(null);
    // set properties of label, position and border
    //  referred to the title of the panel
    titledBorder = new TitledBorder("");
    panelName.setFont(titlePanelFont);
    panelName.setText(getPanelName());
    panelName.setBounds(new Rectangle(14, 5, 316, 28));
    panelName.setAlignmentX(SwingConstants.CENTER);
    panelName.setBorder(titledBorder);

    final int LABEL_X = 14;
    final int VALUE_X = 170;
    int y = 60;
    final int GAP_X = 150;
    final int GAP_Y = 30;

    sourceUriLabel.setText("Source URI: ");
    sourceUriLabel.setFont(defaultFont);
    sourceUriLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    sourceUriValue.setFont(defaultFont);
    sourceUriValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));

    y += GAP_Y; // New line

    nameLabel.setText("Name: ");
    nameLabel.setFont(defaultFont);
    nameLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    nameValue.setFont(defaultFont);
    nameValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));
    y += GAP_Y; // New line

    typeLabel.setText("Type: ");
    typeLabel.setFont(defaultFont);
    typeLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    typeCombo.setFont(defaultFont);
    typeCombo.setBounds(new Rectangle(VALUE_X, y, 350, 18));

    // What happens when the Type value is changed?
    typeCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (isSIFSelected()) {
                encoding.setSelected(true); // SIFs always encoded
                encoding.setEnabled(false);
            } else {
                encryption.setSelected(false);
                encoding.setSelected(false);
                encoding.setEnabled(true);
            }
        }
    });

    y += GAP_Y; // New line
    int x = LABEL_X;

    y = addExtraComponents(x, y, GAP_X, GAP_Y); // Add other components, if needed

    encryption.setText("Encrypt data");
    encryption.setFont(defaultFont);
    encryption.setSelected(false);
    encryption.setBounds(x, y, 150, 25);

    // What happens if the encryption is enabled?
    encryption.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == e.SELECTED) {
                encoding.setSelected(true); // Encryption implies encoding
                encoding.setEnabled(false);
            }
            if (e.getStateChange() == e.DESELECTED) {
                if (!isSIFSelected()) {
                    encoding.setEnabled(true);
                }
            }
        }
    });

    y += GAP_Y; // New line

    encoding.setText("Encode data in Base 64");
    encoding.setFont(defaultFont);
    encoding.setSelected(false);
    encoding.setBounds(x, y, 150, 25);

    y += GAP_Y; // New line
    y += GAP_Y; // New line

    confirmButton.setFont(defaultFont);
    confirmButton.setText("Add");
    confirmButton.setBounds(VALUE_X, y, 70, 25);

    // What happens when the confirmButton is pressed?
    confirmButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                if (getState() == STATE_INSERT) {
                    PIMSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(PIMSyncSourceConfigPanel.this,
                            ACTION_EVENT_INSERT, event.getActionCommand()));
                } else {
                    PIMSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(PIMSyncSourceConfigPanel.this,
                            ACTION_EVENT_UPDATE, event.getActionCommand()));
                }
            } catch (Exception e) {
                notifyError(new AdminException(e.getMessage(), e));
            }
        }
    });

    // Adds all components to the panel
    this.add(panelName, null);
    this.add(nameLabel, null);
    this.add(sourceUriLabel, null);
    this.add(sourceUriValue, null);
    this.add(nameValue, null);
    this.add(typeLabel, null);
    this.add(typeCombo, null);
    this.add(encryption, null);
    this.add(encoding, null);
    this.add(confirmButton, null);
}

From source file:com.funambol.exchange.admin.ExchangeSyncSourceConfigPanel.java

/**
 * Creates the panel's components and layout.
 * @todo adjust layout/*from w w  w . j ava  2s .com*/
 */
private void init() {
    // set layout
    this.setLayout(null);
    // set properties of label, position and border
    //  referred to the title of the panel
    titledBorder = new TitledBorder("");
    panelName.setFont(titlePanelFont);
    panelName.setText(getPanelName());
    panelName.setBounds(new Rectangle(14, 5, 316, 28));
    panelName.setAlignmentX(SwingConstants.CENTER);
    panelName.setBorder(titledBorder);

    final int LABEL_X = 14;
    final int VALUE_X = 170;
    int y = 60;
    final int GAP_X = 150;
    final int GAP_Y = 30;

    sourceUriLabel.setText("Source URI: ");
    sourceUriLabel.setFont(defaultFont);
    sourceUriLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    sourceUriValue.setFont(defaultFont);
    sourceUriValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));

    y += GAP_Y; // New line

    nameLabel.setText("Name: ");
    nameLabel.setFont(defaultFont);
    nameLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    nameValue.setFont(defaultFont);
    nameValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));
    y += GAP_Y; // New line

    y += GAP_Y; // New line
    typeLabel.setText("Type: ");
    typeLabel.setFont(defaultFont);
    typeLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    typeCombo.setFont(defaultFont);
    typeCombo.setBounds(new Rectangle(VALUE_X, y, 350, 18));

    // What happens when the Type value is changed?
    typeCombo.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (isSIFSelected()) {
                encoding.setSelected(true); // SIFs always encoded
                encoding.setEnabled(false);
            } else {
                encryption.setSelected(false);
                encoding.setSelected(false);
                encoding.setEnabled(true);
            }
        }
    });

    y += GAP_Y; // New line
    int x = LABEL_X;

    y = addExtraComponents(x, y, GAP_X, GAP_Y); // Add other components, if needed

    encryption.setText("Encrypt data");
    encryption.setFont(defaultFont);
    encryption.setSelected(false);
    encryption.setBounds(x, y, 150, 25);

    // What happens if the encryption is enabled?
    encryption.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == e.SELECTED) {
                encoding.setSelected(true); // Encryption implies encoding
                encoding.setEnabled(false);
            }
            if (e.getStateChange() == e.DESELECTED) {
                if (!isSIFSelected()) {
                    encoding.setEnabled(true);
                }
            }
        }
    });

    y += GAP_Y; // New line

    encoding.setText("Encode data in Base 64");
    encoding.setFont(defaultFont);
    encoding.setSelected(false);
    encoding.setBounds(x, y, 150, 25);

    y += GAP_Y; // New line
    y += GAP_Y; // New line

    confirmButton.setFont(defaultFont);
    confirmButton.setText("Add");
    confirmButton.setBounds(VALUE_X, y, 70, 25);

    // What happens when the confirmButton is pressed?
    confirmButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                if (getState() == STATE_INSERT) {
                    ExchangeSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(
                            ExchangeSyncSourceConfigPanel.this, ACTION_EVENT_INSERT, event.getActionCommand()));
                } else {
                    ExchangeSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(
                            ExchangeSyncSourceConfigPanel.this, ACTION_EVENT_UPDATE, event.getActionCommand()));
                }
            } catch (Exception e) {
                notifyError(new AdminException(e.getMessage(), e));
            }
        }
    });

    // Adds all components to the panel
    this.add(panelName, null);
    this.add(nameLabel, null);
    this.add(sourceUriLabel, null);
    this.add(sourceUriValue, null);
    this.add(nameValue, null);
    this.add(typeLabel, null);

    this.add(typeCombo, null);
    this.add(encryption, null);
    this.add(encoding, null);
    this.add(confirmButton, null);
}