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:com.floreantpos.config.ui.AddPrinterGroupDialog.java

private void init() {
    JPanel contentPane = (JPanel) getContentPane();
    contentPane.setLayout(new MigLayout("", "[][grow]", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    add(new JLabel(Messages.getString("AddPrinterGroupDialog.4"))); //$NON-NLS-1$
    add(tfName, "grow, wrap"); //$NON-NLS-1$

    chkDefault = new JCheckBox(Messages.getString("AddPrinterGroupDialog.1")); //$NON-NLS-1$

    add(new JLabel(), "grow"); //$NON-NLS-1$
    add(chkDefault, "wrap"); //$NON-NLS-1$

    PosPrinters printersKitchen = PosPrinters.load();
    printers = printersKitchen.getKitchenPrinters();
    printerList = new CheckBoxList(new Vector<Printer>(printers));

    JPanel listPanel = new JPanel(new BorderLayout());
    listPanel.setBorder(new TitledBorder(Messages.getString("AddPrinterGroupDialog.6"))); //$NON-NLS-1$
    listPanel.add(new JScrollPane(printerList));

    add(listPanel, "newline, span 2, grow"); //$NON-NLS-1$

    JPanel panel = new JPanel();
    contentPane.add(panel, "cell 0 4 3 1,grow"); //$NON-NLS-1$

    JButton btnOk = new JButton(Messages.getString("AddPrinterGroupDialog.9")); //$NON-NLS-1$
    btnOk.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (StringUtils.isEmpty(tfName.getText())) {
                POSMessageDialog.showError(Application.getPosWindow(),
                        Messages.getString("AddPrinterGroupDialog.10")); //$NON-NLS-1$
                return;
            }//  ww w.ja va  2  s.  co  m

            List checkedValues = printerList.getCheckedValues();
            if (checkedValues == null || checkedValues.size() == 0) {
                POSMessageDialog.showError(Application.getPosWindow(),
                        Messages.getString("AddPrinterGroupDialog.11")); //$NON-NLS-1$
                return;
            }

            setCanceled(false);
            dispose();
        }
    });
    panel.add(btnOk);

    JButton btnCancel = new JButton(Messages.getString("AddPrinterGroupDialog.12")); //$NON-NLS-1$
    btnCancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setCanceled(true);
            dispose();
        }
    });
    panel.add(btnCancel);
}

From source file:XPathTest.java

public XPathFrame() {
        setTitle("XPathTest");

        JMenu fileMenu = new JMenu("File");
        JMenuItem openItem = new JMenuItem("Open");
        openItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                openFile();//w w w.  j  a va  2s.c  o m
            }
        });
        fileMenu.add(openItem);

        JMenuItem exitItem = new JMenuItem("Exit");
        exitItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                System.exit(0);
            }
        });
        fileMenu.add(exitItem);

        JMenuBar menuBar = new JMenuBar();
        menuBar.add(fileMenu);
        setJMenuBar(menuBar);

        ActionListener listener = new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                evaluate();
            }
        };
        expression = new JTextField(20);
        expression.addActionListener(listener);
        JButton evaluateButton = new JButton("Evaluate");
        evaluateButton.addActionListener(listener);

        typeCombo = new JComboBox(new Object[] { "STRING", "NODE", "NODESET", "NUMBER", "BOOLEAN" });
        typeCombo.setSelectedItem("STRING");

        JPanel panel = new JPanel();
        panel.add(expression);
        panel.add(typeCombo);
        panel.add(evaluateButton);
        docText = new JTextArea(10, 40);
        result = new JTextField();
        result.setBorder(new TitledBorder("Result"));

        add(panel, BorderLayout.NORTH);
        add(new JScrollPane(docText), BorderLayout.CENTER);
        add(result, BorderLayout.SOUTH);

        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            builder = factory.newDocumentBuilder();
        } catch (ParserConfigurationException e) {
            JOptionPane.showMessageDialog(this, e);
        }

        XPathFactory xpfactory = XPathFactory.newInstance();
        path = xpfactory.newXPath();
        pack();
    }

From source file:TaskManager.java

public TaskPanel(Tasks taskList) {
    this.taskList = taskList;

    setLayout(new BorderLayout());

    connPane = new ConnectionPane();
    connPane.setBorder(new TitledBorder("Connection Data"));

    taskPane = new TaskPane();
    taskPane.setBorder(new TitledBorder("Tasks"));

    add(connPane, BorderLayout.NORTH);
    add(taskPane, BorderLayout.SOUTH);
}

From source file:com.funambol.json.admin.JsonConnectorConfigPanel.java

/**
 * Create the panel//from  ww w .ja  va2  s  .com
 */
private void init() {

    JLabel title, serverLabel;
    JPanel seccPanel;
    JPanel behaviourOnErrorsPanel;

    title = new JLabel();
    seccPanel = new JPanel();
    behaviourOnErrorsPanel = new JPanel();

    serverLabel = new JLabel();
    serverValue = new JTextField();

    setLayout(null);

    title.setFont(titlePanelFont);
    title.setText("Funambol Json Connector");
    title.setBounds(new Rectangle(14, 5, 316, 28));
    title.setAlignmentX(SwingConstants.CENTER);
    title.setBorder(new TitledBorder(""));

    seccPanel.setLayout(null);
    seccPanel.setBorder(new TitledBorder("HTTP Server Configuration"));

    serverLabel.setText("Server:");
    seccPanel.add(serverLabel);
    serverLabel.setBounds(10, 20, 116, 15);
    seccPanel.add(serverValue);
    serverValue.setBounds(150, 20, 220, 19);
    serverValue.setFont(defaultFont);

    add(seccPanel);
    seccPanel.setBounds(10, 50, 380, 70);

    //the ssl option panel

    behaviourOnErrorsPanel.setBorder(new TitledBorder("Behaviour on errors"));
    behaviourOnErrorsPanel.setLayout(null);

    stopSyncOnFatalError.setText("Stop sync on fatal errors");
    stopSyncOnFatalError.setBounds(10, 25, 200, 15);

    behaviourOnErrorsPanel.add(stopSyncOnFatalError);

    add(behaviourOnErrorsPanel);
    behaviourOnErrorsPanel.setBounds(10, 130, 380, 60);

    confirmButton.setFont(defaultFont);
    confirmButton.setText("Save");
    add(confirmButton);
    confirmButton.setBounds(160, 200, 70, 25);

    confirmButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                JsonConnectorConfigPanel.this.actionPerformed(new ActionEvent(JsonConnectorConfigPanel.this,
                        ACTION_EVENT_UPDATE, event.getActionCommand()));
            } catch (Exception e) {
                notifyError(new AdminException(e.getMessage()));
            }
        }
    });

    //
    // Setting font...
    //
    Component[] components = getComponents();
    for (int i = 0; (components != null) && (i < components.length); ++i) {
        components[i].setFont(defaultFont);
    }

    //
    // We add it as the last one so that the font won't be changed
    //
    add(title);
}

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

private JPanel getJPanelSelectedPart() {
    if (jPanelSelectedPart == null) {
        jPanelSelectedPart = new JPanel();
        jPanelSelectedPart.setBorder(new TitledBorder("Selected Project(s)"));
        BorderLayout borderLayout = new BorderLayout();
        borderLayout.setVgap(10);/*w  ww . j  a v a  2  s .  c  o m*/
        jPanelSelectedPart.setLayout(borderLayout);
        jPanelSelectedPart.add(getJScrollPaneProjectList(), BorderLayout.CENTER);

    }
    return jPanelSelectedPart;
}

From source file:org.jfree.chart.demo.CategoryLabelPositionsDemo1.java

public static JPanel createDemoPanel() {
    CategoryDataset categorydataset = createDataset();
    chart = createChart(categorydataset);
    JPanel jpanel = new JPanel(new BorderLayout());
    JPanel jpanel1 = new JPanel(new BorderLayout());
    JPanel jpanel2 = new JPanel();
    invertCheckBox = new JCheckBox("Invert Range Axis?");
    invertCheckBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionevent) {
            CategoryPlot categoryplot = (CategoryPlot) CategoryLabelPositionsDemo1.chart.getPlot();
            categoryplot.getRangeAxis().setInverted(CategoryLabelPositionsDemo1.invertCheckBox.isSelected());
        }//  w  w  w  .j a va2  s  .com

    });
    jpanel2.add(invertCheckBox);
    ButtonGroup buttongroup = new ButtonGroup();
    horizontalRadioButton = new JRadioButton("Horizontal", false);
    horizontalRadioButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionevent) {
            if (CategoryLabelPositionsDemo1.horizontalRadioButton.isSelected()) {
                CategoryPlot categoryplot = (CategoryPlot) CategoryLabelPositionsDemo1.chart.getPlot();
                categoryplot.setOrientation(PlotOrientation.HORIZONTAL);
            }
        }

    });
    buttongroup.add(horizontalRadioButton);
    verticalRadioButton = new JRadioButton("Vertical", true);
    verticalRadioButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionevent) {
            if (CategoryLabelPositionsDemo1.verticalRadioButton.isSelected()) {
                CategoryPlot categoryplot = (CategoryPlot) CategoryLabelPositionsDemo1.chart.getPlot();
                categoryplot.setOrientation(PlotOrientation.VERTICAL);
            }
        }

    });
    buttongroup.add(verticalRadioButton);
    jpanel2.add(horizontalRadioButton);
    jpanel2.add(verticalRadioButton);
    jpanel2.setBorder(new TitledBorder("Plot Settings: "));
    JPanel jpanel3 = new JPanel(new BorderLayout());
    slider = new JSlider(0, 90, 45);
    slider.setMajorTickSpacing(10);
    slider.setMinorTickSpacing(5);
    slider.setPaintLabels(true);
    slider.setPaintTicks(true);
    slider.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent changeevent) {
            CategoryPlot categoryplot = (CategoryPlot) CategoryLabelPositionsDemo1.chart.getPlot();
            CategoryAxis categoryaxis = categoryplot.getDomainAxis();
            categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(
                    ((double) CategoryLabelPositionsDemo1.slider.getValue() * 3.1415926535897931D) / 180D));
        }

    });
    jpanel3.add(slider);
    jpanel3.setBorder(new TitledBorder("Axis Label Rotation Angle:"));
    jpanel1.add("North", jpanel2);
    jpanel1.add(jpanel3);
    jpanel.add(new ChartPanel(chart));
    jpanel.add("South", jpanel1);
    return jpanel;
}

From source file:com.raphfrk.craftproxyclient.gui.CraftProxyGUI.java

public CraftProxyGUI(String buildId) {

    pf = new PropertiesFile("CraftProxyClientGUI.txt");

    try {/*  w  ww. j av  a 2 s. c om*/
        pf.load();
    } catch (IOException e) {
        JOptionPane.showMessageDialog(CraftProxyGUI.this, "Unable to open settings file");
    }

    String defaultHostname = pf.getString("connect_hostname", "");
    int defaultPort = pf.getInt("connect_port", 20000);
    int listenPort = pf.getInt("listen_port", 25565);
    int desired = pf.getInt("cache_size", 48);

    try {
        pf.save();
    } catch (IOException e) {
        JOptionPane.showMessageDialog(CraftProxyGUI.this, "Unable to save settings file");
    }

    setTitle("CraftProxyClient Local (" + buildId + ")");
    setSize(500, 375);
    setLocation(40, 150);

    topPanel.setLayout(new BorderLayout());
    topPanel.setBorder(new TitledBorder("Remote Server"));
    topPanel.setBackground(Color.WHITE);
    secondPanel.setLayout(new BorderLayout());
    secondPanel.setBorder(new TitledBorder("Local Server"));
    secondPanel.setBackground(Color.WHITE);

    serverName = new JTextField(defaultHostname, 20);
    TitledBorder border = new TitledBorder("Name");
    serverName.setBorder(border);
    serverName.addActionListener(this);

    portNum = new JTextField(Integer.toString(defaultPort), 6);
    border = new TitledBorder("Port");
    portNum.setBorder(border);
    portNum.addActionListener(this);

    localServerName = new JLabel("localhost");
    localServerName.setBackground(Color.GRAY);
    border = new TitledBorder("Name");
    localServerName.setBorder(border);

    localServerPortnum = new JTextField(Integer.toString(listenPort), 6);
    border = new TitledBorder("Port");
    localServerPortnum.setBorder(border);
    localServerPortnum.addActionListener(this);

    topPanel.add(serverName, BorderLayout.CENTER);
    topPanel.add(portNum, BorderLayout.LINE_END);

    secondPanel.setLayout(new BorderLayout());
    secondPanel.add(localServerName, BorderLayout.CENTER);
    secondPanel.add(localServerPortnum, BorderLayout.LINE_END);

    combinedTop.setLayout(new BorderLayout());
    combinedTop.add(topPanel, BorderLayout.CENTER);
    combinedTop.add(secondPanel, BorderLayout.SOUTH);

    currentSize = new JTextField("Unknown");
    currentSize.setBorder(new TitledBorder("Current Size (MB)"));
    currentSize.setEditable(false);

    desiredSize = new JTextField(Integer.toString(desired));
    desiredSize.setBorder(new TitledBorder("Max Size (MB)"));

    connect = new JButton(buttonText);
    connect.addActionListener(this);

    filePanel = new JPanel();
    filePanel.setLayout(new BorderLayout());
    JPanel fileLinePanel = new JPanel();
    fileLinePanel.setBorder(new TitledBorder("Cache Size"));
    fileLinePanel.setLayout(new GridLayout(1, 3));
    fileLinePanel.add(currentSize);
    fileLinePanel.add(desiredSize);
    filePanel.add(fileLinePanel, BorderLayout.CENTER);
    filePanel.add(connect, BorderLayout.PAGE_END);

    info = new JLabel();
    border = new TitledBorder("Status");
    info.setBorder(border);

    setLayout(new BorderLayout());
    add(combinedTop, BorderLayout.PAGE_START);
    add(info, BorderLayout.CENTER);
    add(filePanel, BorderLayout.PAGE_END);

    this.setResizable(false);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    this.addWindowListener(this);

}

From source file:rhinova.gui.dataentry.reserve.ReserveDataEntryPanel.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner non-commercial license
    vSpacer6 = new JPanel(null);
    label1 = new JLabel();
    hSpacer1 = new JPanel(null);
    label2 = new JLabel();
    txtName = new JTextField();
    vSpacer1 = new JPanel(null);
    label3 = new JLabel();
    txtXPos = new JTextField();
    vSpacer2 = new JPanel(null);
    label4 = new JLabel();
    txtYPos = new JTextField();
    hSpacer2 = new JPanel(null);
    vSpacer3 = new JPanel(null);
    label8 = new JLabel();
    txtMin = new JTextField();
    vSpacer4 = new JPanel(null);
    label5 = new JLabel();
    txtMax = new JTextField();
    vSpacer5 = new JPanel(null);
    label6 = new JLabel();
    txtCur = new JTextField();
    vSpacer9 = new JPanel(null);
    label7 = new JLabel();
    txtReg = new JTextField();
    vSpacer7 = new JPanel(null);
    btnCreateReserve = new JButton();
    vSpacer8 = new JPanel(null);

    //======== this ========
    setBorder(new TitledBorder("Reserve"));
    setLayout(new GridBagLayout());
    ((GridBagLayout) getLayout()).columnWidths = new int[] { 0, 65, 145, 0, 0 };
    ((GridBagLayout) getLayout()).rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0 };//from   w ww. j ava 2  s  . c o  m
    ((GridBagLayout) getLayout()).columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 1.0E-4 };
    ((GridBagLayout) getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4 };
    add(vSpacer6, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label1 ----
    label1.setText("Reserve Entry Panel");
    label1.setFont(new Font("Tahoma", Font.PLAIN, 16));
    add(label1, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(hSpacer1, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label2 ----
    label2.setText("name");
    add(label2, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtName, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer1, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label3 ----
    label3.setText("x - position");
    add(label3, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtXPos, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer2, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label4 ----
    label4.setText("y - position");
    add(label4, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtYPos, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(hSpacer2, new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0));
    add(vSpacer3, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label8 ----
    label8.setText("minimum population");
    add(label8, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtMin, new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer4, new GridBagConstraints(1, 9, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label5 ----
    label5.setText("maximum population");
    add(label5, new GridBagConstraints(1, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(txtMax, new GridBagConstraints(2, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer5, new GridBagConstraints(1, 11, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label6 ----
    label6.setText("current population");
    add(label6, new GridBagConstraints(1, 12, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(txtCur, new GridBagConstraints(2, 12, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer9, new GridBagConstraints(1, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label7 ----
    label7.setText("regeneration rate");
    add(label7, new GridBagConstraints(1, 14, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(txtReg, new GridBagConstraints(2, 14, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer7, new GridBagConstraints(1, 15, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- btnCreateReserve ----
    btnCreateReserve.setText("Create Reserve");
    btnCreateReserve.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btnCreateReserveActionPerformed(e);
        }
    });
    add(btnCreateReserve, new GridBagConstraints(2, 16, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer8, new GridBagConstraints(2, 17, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:com.emental.mindraider.ui.dialogs.AttachmentJDialog.java

/**
 * Concetructor.//from w  ww  .  j  a v  a  2  s .c  o m
 * 
 * @param noteResource
 *            The concept resource.
 * @param dragAndDropReference
 *            The drag'n'drop reference.
 */
public AttachmentJDialog(ConceptResource conceptResource, DragAndDropReference dragAndDropReference) {

    super(Messages.getString("AttachmentJDialog.title"));
    this.conceptResource = conceptResource;
    getContentPane().setLayout(new BorderLayout());
    JPanel p, pp;

    p = new JPanel();
    p.setLayout(new BorderLayout());
    JLabel intro = new JLabel("<html>&nbsp;&nbsp;" + Messages.getString("AttachmentJDialog.introduction")
            + "&nbsp;&nbsp;<br><br></html>");
    p.add(intro, BorderLayout.NORTH);
    p.add(new JLabel("<html>&nbsp;&nbsp;" + Messages.getString("AttachmentJDialog.description") + "</html>"),
            BorderLayout.CENTER);
    description = new JTextField(38);
    pp = new JPanel(new FlowLayout(FlowLayout.LEFT));
    pp.add(description);
    p.add(pp, BorderLayout.SOUTH);
    getContentPane().add(p, BorderLayout.NORTH);

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    mainPanel.setBorder(new TitledBorder(Messages.getString("AttachmentJDialog.resource")));

    ButtonGroup attachType = new ButtonGroup();

    JPanel webPanel = new JPanel();
    webPanel.setLayout(new BorderLayout());
    webType = new JRadioButton(Messages.getString("AttachmentJDialog.web"));
    webType.setActionCommand(WEB);
    webType.addActionListener(this);
    webType.setSelected(true);
    attachType.add(webType);
    webPanel.add(webType, BorderLayout.NORTH);
    urlTextField = new JTextField("http://", 35);
    urlTextField.selectAll();
    urlTextField.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) {
                attach();
            }
        }

        public void keyReleased(KeyEvent keyEvent) {
        }

        public void keyTyped(KeyEvent keyEvent) {
        }
    });
    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.LEFT));
    p.add(new JLabel("   "));
    p.add(urlTextField);
    webPanel.add(p, BorderLayout.SOUTH);
    mainPanel.add(webPanel, BorderLayout.NORTH);

    JPanel localPanel = new JPanel();
    localPanel.setLayout(new BorderLayout());
    JRadioButton localType = new JRadioButton(Messages.getString("AttachmentJDialog.local"));
    localType.setActionCommand(LOCAL);
    localType.addActionListener(this);
    localPanel.add(localType, BorderLayout.NORTH);
    pathTextField = new JTextField(35);
    pathTextField.setEnabled(false);
    browseButton = new JButton(Messages.getString("AttachmentJDialog.browse"));
    browseButton.setToolTipText(Messages.getString("AttachmentJDialog.browseTip"));
    browseButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JFileChooser fc = new JFileChooser();
            fc.setApproveButtonText(Messages.getString("AttachmentJDialog.attach"));
            fc.setControlButtonsAreShown(true);
            fc.setDialogTitle(Messages.getString("AttachmentJDialog.chooseAttachment"));
            fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            int returnVal = fc.showOpenDialog(AttachmentJDialog.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                pathTextField.setText(file.toString());
            }
        }
    });
    browseButton.setEnabled(false);
    pp = new JPanel();
    pp.setLayout(new BorderLayout());
    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.LEFT));
    p.add(new JLabel("   "));
    pp.add(p, BorderLayout.NORTH);
    p.add(pathTextField);
    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.RIGHT));
    p.add(browseButton);
    pp.add(p, BorderLayout.SOUTH);
    localPanel.add(pp, BorderLayout.SOUTH);
    attachType.add(localType);
    mainPanel.add(localPanel, BorderLayout.SOUTH);

    getContentPane().add(mainPanel, BorderLayout.CENTER);

    // buttons
    p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.CENTER));
    JButton addButton = new JButton(Messages.getString("AttachmentJDialog.attach"));

    p.add(addButton);
    addButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            attach();
        }
    });
    JButton cancelButton = new JButton(Messages.getString("AttachmentJDialog.cancel"));
    p.add(cancelButton);
    cancelButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            AttachmentJDialog.this.dispose();
        }
    });
    getContentPane().add(p, BorderLayout.SOUTH);

    /*
     * drag and drop initialization
     */
    if (dragAndDropReference != null) {
        if (dragAndDropReference.getType() == DragAndDropReference.BROWSER_LINK) {
            urlTextField.setText(dragAndDropReference.getReference());
            localType.setSelected(false);
            webType.setSelected(true);
            enableWebTypeButtons();
        } else {
            pathTextField.setText(dragAndDropReference.getReference());
            localType.setSelected(true);
            webType.setSelected(false);
            enableLocalTypeButtons();
        }
        description.setText(dragAndDropReference.getTitle());
    }

    pack();
    Gfx.centerAndShowWindow(this);
}

From source file:com.funambol.json.admin.NoteSyncSourceAdminPanel.java

/**
 * Create the panel//from  ww  w.  j av  a 2s. c  om
 * @throws Exception if error occures during creation of the panel
 */
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("Client 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));

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

    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) {
                    NoteSyncSourceAdminPanel.this.actionPerformed(new ActionEvent(NoteSyncSourceAdminPanel.this,
                            ACTION_EVENT_INSERT, event.getActionCommand()));
                } else {
                    NoteSyncSourceAdminPanel.this.actionPerformed(new ActionEvent(NoteSyncSourceAdminPanel.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(confirmButton, null);

}