Example usage for javax.swing GroupLayout GroupLayout

List of usage examples for javax.swing GroupLayout GroupLayout

Introduction

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

Prototype

public GroupLayout(Container host) 

Source Link

Document

Creates a GroupLayout for the specified Container .

Usage

From source file:components.TextFieldDemo.java

/** This method is called from within the constructor to
 * initialize the form.//from w w w .  j a  va  2 s  .  c om
 */

private void initComponents() {
    entry = new JTextField();
    textArea = new JTextArea();
    status = new JLabel();
    jLabel1 = new JLabel();

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setTitle("TextFieldDemo");

    textArea.setColumns(20);
    textArea.setLineWrap(true);
    textArea.setRows(5);
    textArea.setWrapStyleWord(true);
    textArea.setEditable(false);
    jScrollPane1 = new JScrollPane(textArea);

    jLabel1.setText("Enter text to search:");

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);

    //Create a parallel group for the horizontal axis
    ParallelGroup hGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING);

    //Create a sequential and a parallel groups
    SequentialGroup h1 = layout.createSequentialGroup();
    ParallelGroup h2 = layout.createParallelGroup(GroupLayout.Alignment.TRAILING);

    //Add a container gap to the sequential group h1
    h1.addContainerGap();

    //Add a scroll pane and a label to the parallel group h2
    h2.addComponent(jScrollPane1, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 450,
            Short.MAX_VALUE);
    h2.addComponent(status, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE);

    //Create a sequential group h3
    SequentialGroup h3 = layout.createSequentialGroup();
    h3.addComponent(jLabel1);
    h3.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED);
    h3.addComponent(entry, GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE);

    //Add the group h3 to the group h2
    h2.addGroup(h3);
    //Add the group h2 to the group h1
    h1.addGroup(h2);

    h1.addContainerGap();

    //Add the group h1 to the hGroup
    hGroup.addGroup(GroupLayout.Alignment.TRAILING, h1);
    //Create the horizontal group
    layout.setHorizontalGroup(hGroup);

    //Create a parallel group for the vertical axis
    ParallelGroup vGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    //Create a sequential group v1
    SequentialGroup v1 = layout.createSequentialGroup();
    //Add a container gap to the sequential group v1
    v1.addContainerGap();
    //Create a parallel group v2
    ParallelGroup v2 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v2.addComponent(jLabel1);
    v2.addComponent(entry, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
    //Add the group v2 tp the group v1
    v1.addGroup(v2);
    v1.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED);
    v1.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE);
    v1.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED);
    v1.addComponent(status);
    v1.addContainerGap();

    //Add the group v1 to the group vGroup
    vGroup.addGroup(v1);
    //Create the vertical group
    layout.setVerticalGroup(vGroup);
    pack();
}

From source file:com.codeasylum.stress.ui.Jormungandr.java

private synchronized Jormungandr init() throws IOException, SAXException, ParserConfigurationException {

    TestPlan testPlan;/*from  ww  w  .ja  v a  2s .c o m*/
    GhostPanel ghostPanel;
    GroupLayout groupLayout;
    ViewPanel viewPanel;
    JTree testTree;
    JSplitPane workSplitPane;
    JScrollPane paletteScrollPane;
    JScrollPane testScrollPane;

    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    exchangeTransport = new ExchangeTransportImpl(exchangeTransportRMIPort);
    menuHandler = new JormungandrMenuHandler(this, menuDelegateFactory);

    testExecutor = new TestExecutor(testPlan = new TestPlan(), exchangeTransport);
    testExecutor.addTestExecutorListener(this);
    testPlan.getRootTask().setName(palette.getAvatar(RootTask.class).getName());

    setGlassPane(ghostPanel = new GhostPanel());
    setLayout(groupLayout = new GroupLayout(getContentPane()));

    testTree = new JTree();
    palettePanel = new PalettePanel(this, ghostPanel, palette);
    testPanel = new TestPanel(this, ghostPanel, palette, viewPanel = new ViewPanel(testTree), testTree);

    paletteScrollPane = new JScrollPane(palettePanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    testScrollPane = new JScrollPane(testPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    workSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, testScrollPane, viewPanel);
    workSplitPane.setDoubleBuffered(true);
    workSplitPane.setContinuousLayout(true);
    workSplitPane.setResizeWeight(0.3);

    groupLayout.setAutoCreateContainerGaps(true);

    groupLayout.setHorizontalGroup(groupLayout.createSequentialGroup()
            .addComponent(paletteScrollPane, (int) palettePanel.getMinimumSize().getWidth() + 3,
                    (int) palettePanel.getPreferredSize().getWidth() + 3,
                    (int) palettePanel.getMaximumSize().getWidth() + 3)
            .addComponent(workSplitPane));
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup()
            .addComponent(paletteScrollPane, 0, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
            .addComponent(workSplitPane, 0, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE));

    setSize(new Dimension(Math.max(800, ((int) getLayout().preferredLayoutSize(this).getWidth()) + 120),
            Math.min(600, ((int) getLayout().preferredLayoutSize(this).getHeight()) + 38)));
    setLocationByPlatform(true);

    addWindowListener(this);

    return this;
}

From source file:com.actian.services.knime.core.operators.DeriveGroupNodeDialogPane.java

private void initComponents() {
    this.expression = new JTextArea(10, 20);
    expression.setWrapStyleWord(true);/*from   ww  w.jav a 2 s .c om*/
    expression.setFont(new Font("Monospaced", Font.PLAIN, 11));

    this.expressionPanel = new JScrollPane(expression);
    this.expressionPanel.setBorder(BorderFactory.createTitledBorder("Group Expressions"));

    functionPanel = new JPanel();
    functionPanel.setLayout(new GridLayout(0, 1, 0, 0));
    functionPanel.setBorder(BorderFactory.createTitledBorder("Available Aggregate Functions"));

    fcomboBox = new JComboBox();
    fcomboBox.setMaximumRowCount(10);
    fcomboBox.setModel(new DefaultComboBoxModel(new String[] { "Function - Description" }));
    fcomboBox.setFont(new Font("Monospaced", Font.PLAIN, 10));
    functionPanel.add(fcomboBox);

    GroupLayout groupLayout = new GroupLayout(this);
    groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.TRAILING).addGroup(groupLayout
            .createSequentialGroup()
            .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
                    .addGroup(Alignment.LEADING,
                            groupLayout.createSequentialGroup().addContainerGap().addComponent(columnSelect,
                                    GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE))
                    .addGroup(Alignment.LEADING,
                            groupLayout.createSequentialGroup().addGap(7).addComponent(expressionPanel,
                                    GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE))
                    .addGroup(Alignment.LEADING, groupLayout.createSequentialGroup().addContainerGap()
                            .addComponent(functionPanel, GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE)))
            .addGap(7)));
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(groupLayout.createSequentialGroup().addGap(5)
                    .addComponent(expressionPanel, GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(functionPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(columnSelect, GroupLayout.PREFERRED_SIZE, 248, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
    setLayout(groupLayout);
}

From source file:au.org.ala.delta.intkey.ui.AddOrEditDataIndexItemDialog.java

private void init() {
    ActionMap actionMap = Application.getInstance().getContext().getActionMap(this);
    ResourceMap resourceMap = Application.getInstance().getContext()
            .getResourceMap(AddOrEditDataIndexItemDialog.class);
    resourceMap.injectFields(this);

    _pnlMain = new JPanel();
    getContentPane().add(_pnlMain, BorderLayout.CENTER);

    _lblDescription = new JLabel(descriptionCaption);

    _txtFldDescription = new JTextField();
    _txtFldDescription.setColumns(10);//from  w  w w. j ava  2 s  .com

    _btnBrowse = new JButton();
    _btnBrowse.setAction(actionMap.get("AddOrEditDataIndexItemDialog_Browse"));

    _lblFilePath = new JLabel(pathCaption);

    _txtFldFilePath = new JTextField();
    _txtFldFilePath.setColumns(10);
    GroupLayout gl__pnlMain = new GroupLayout(_pnlMain);
    gl__pnlMain.setHorizontalGroup(gl__pnlMain.createParallelGroup(Alignment.LEADING).addGroup(gl__pnlMain
            .createSequentialGroup().addContainerGap()
            .addGroup(gl__pnlMain.createParallelGroup(Alignment.LEADING, false)
                    .addComponent(_lblFilePath, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                            Short.MAX_VALUE)
                    .addComponent(_lblDescription, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                            Short.MAX_VALUE))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(gl__pnlMain.createParallelGroup(Alignment.TRAILING)
                    .addGroup(gl__pnlMain.createSequentialGroup()
                            .addComponent(_txtFldFilePath, GroupLayout.DEFAULT_SIZE, 314, Short.MAX_VALUE)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(_btnBrowse))
                    .addComponent(_txtFldDescription, GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE))
            .addContainerGap()));
    gl__pnlMain.setVerticalGroup(gl__pnlMain.createParallelGroup(Alignment.LEADING)
            .addGroup(gl__pnlMain.createSequentialGroup().addContainerGap()
                    .addGroup(gl__pnlMain.createParallelGroup(Alignment.BASELINE).addComponent(_lblDescription)
                            .addComponent(_txtFldDescription, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addGap(18)
                    .addGroup(gl__pnlMain.createParallelGroup(Alignment.BASELINE)
                            .addComponent(_btnBrowse, GroupLayout.PREFERRED_SIZE, 20,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(_txtFldFilePath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(_lblFilePath, GroupLayout.PREFERRED_SIZE, 20,
                                    GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(25, Short.MAX_VALUE)));
    _pnlMain.setLayout(gl__pnlMain);

    _pnlButtons = new JPanel();
    getContentPane().add(_pnlButtons, BorderLayout.SOUTH);

    _btnOk = new JButton();
    _btnOk.setAction(actionMap.get("AddOrEditDataIndexItemDialog_OK"));
    _pnlButtons.add(_btnOk);

    _btnCancel = new JButton();
    _btnCancel.setAction(actionMap.get("AddOrEditDataIndexItemDialog_Cancel"));
    _pnlButtons.add(_btnCancel);
}

From source file:com.cactus.ClientChatGUI.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 ww  w  . j  a  v a2  s  . c om
 */

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    Message_Area = new JTextField();
    Send_Button = new JButton();
    Back_Button = new JButton();
    jScrollPane1 = new JScrollPane();
    Chat_Area = new JTextArea();

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    Send_Button.setText("Send");
    Send_Button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            try {
                Send_ButtonActionPerformed(evt);
            } catch (ClientProtocolException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });

    Chat_Area.setColumns(20);
    Chat_Area.setRows(5);
    Chat_Area.setEditable(false);
    jScrollPane1.setViewportView(Chat_Area);

    try {
        updateChatBox();
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    Back_Button.setText("Back");
    Back_Button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            Back_ButtonActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout layout = new GroupLayout(getContentPane());
    layout.setHorizontalGroup(layout.createParallelGroup(Alignment.TRAILING).addGroup(layout
            .createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.TRAILING)
                    .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 412, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                            .addComponent(
                                    Message_Area, GroupLayout.PREFERRED_SIZE, 337, GroupLayout.PREFERRED_SIZE)
                            .addGap(18)
                            .addGroup(layout.createParallelGroup(Alignment.TRAILING, false)
                                    .addComponent(Back_Button, 0, 0, Short.MAX_VALUE).addComponent(Send_Button,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                            Short.MAX_VALUE))))
            .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(Alignment.TRAILING).addGroup(layout
            .createSequentialGroup().addContainerGap()
            .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE).addGap(18)
            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup().addComponent(Send_Button)
                            .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(Back_Button))
                    .addComponent(Message_Area, GroupLayout.PREFERRED_SIZE, 68, GroupLayout.PREFERRED_SIZE))
            .addContainerGap()));
    getContentPane().setLayout(layout);

    pack();
}

From source file:MyStatsPanel.java

JPanel setFields() {
    getDatabaseInfo();/*from w  w  w .  j  ava 2 s.  c  o  m*/
    GroupLayout layout;
    JPanel p;

    numGuestsIn = new JLabel("Total guests in house .............................");
    numGuestsIn.setFont(new Font("Courier New", Font.PLAIN, 20));
    numGuestsIn.setForeground(Color.WHITE);
    checkIns = new JLabel("Todays guest check ins ............................");
    checkIns.setForeground(Color.WHITE);
    checkIns.setFont(new Font("Courier New", Font.PLAIN, 20));
    numGuestsOut = new JLabel("Todays guest check outs ...........................");
    numGuestsOut.setFont(new Font("Courier New", Font.PLAIN, 20));
    numGuestsOut.setForeground(Color.WHITE);
    overnights = new JLabel("Total overnight guests ............................");
    overnights.setForeground(Color.WHITE);
    overnights.setFont(new Font("Courier New", Font.PLAIN, 20));

    JLabel n1 = new JLabel(totalGuestsIn);
    n1.setForeground(Color.WHITE);
    n1.setFont(new Font("Courier New", Font.PLAIN, 20));
    JLabel n2 = new JLabel(todaysCheckIns);
    n2.setForeground(Color.WHITE);
    n2.setFont(new Font("Courier New", Font.PLAIN, 20));
    JLabel n3 = new JLabel(todaysCheckOuts);
    n3.setForeground(Color.WHITE);
    n3.setFont(new Font("Courier New", Font.PLAIN, 20));
    JLabel n4 = new JLabel(totalOvernights);
    n4.setForeground(Color.WHITE);
    n4.setFont(new Font("Courier New", Font.PLAIN, 20));

    p = new JPanel();
    p.setBackground(Color.GRAY);

    layout = new GroupLayout(p);
    p.setLayout(layout);
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
    hGroup.addGroup(layout.createParallelGroup().addComponent(numGuestsIn).addComponent(checkIns)
            .addComponent(numGuestsOut).addComponent(overnights));
    hGroup.addGroup(
            layout.createParallelGroup().addComponent(n1).addComponent(n2).addComponent(n3).addComponent(n4));
    layout.setHorizontalGroup(hGroup);

    GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup();
    vGroup.addGroup(layout.createParallelGroup(BASELINE).addComponent(numGuestsIn).addComponent(n1));
    vGroup.addGroup(layout.createParallelGroup(BASELINE).addComponent(checkIns).addComponent(n2));
    vGroup.addGroup(layout.createParallelGroup(BASELINE).addComponent(numGuestsOut).addComponent(n3));
    vGroup.addGroup(layout.createParallelGroup(BASELINE).addComponent(overnights).addComponent(n4));

    layout.setVerticalGroup(vGroup);

    return (p);
}

From source file:com.fisher.mainFrame.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - nick xu
    dialogPane = new JPanel();
    contentPanel = new JPanel();
    scrollPaneLogArea = new JScrollPane();
    logArea = new JTextArea();
    buttonBar = new JPanel();
    startButton = new JButton();
    stopButton = new JButton();

    //======== this ========
    setTitle("Fish Transform Trading");
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    //======== dialogPane ========
    {//  w  ww .j  a  va2 s .c  o  m
        dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
        dialogPane.setPreferredSize(new Dimension(758, 900));

        // JFormDesigner evaluation mark
        dialogPane.setBorder(new javax.swing.border.CompoundBorder(
                new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
                        "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
                        javax.swing.border.TitledBorder.BOTTOM,
                        new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.red),
                dialogPane.getBorder()));
        dialogPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent e) {
                if ("border".equals(e.getPropertyName()))
                    throw new RuntimeException();
            }
        });

        dialogPane.setLayout(new BorderLayout());

        //======== contentPanel ========
        {

            //======== scrollPaneLogArea ========
            {
                scrollPaneLogArea.setViewportView(logArea);
            }

            GroupLayout contentPanelLayout = new GroupLayout(contentPanel);
            contentPanel.setLayout(contentPanelLayout);
            contentPanelLayout.setHorizontalGroup(contentPanelLayout.createParallelGroup()
                    .addComponent(scrollPaneLogArea, GroupLayout.DEFAULT_SIZE, 734, Short.MAX_VALUE));
            contentPanelLayout
                    .setVerticalGroup(contentPanelLayout.createParallelGroup()
                            .addGroup(contentPanelLayout
                                    .createSequentialGroup().addComponent(scrollPaneLogArea,
                                            GroupLayout.PREFERRED_SIZE, 225, GroupLayout.PREFERRED_SIZE)
                                    .addGap(0, 476, Short.MAX_VALUE)));
        }
        dialogPane.add(contentPanel, BorderLayout.CENTER);

        //======== buttonBar ========
        {
            buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
            buttonBar.setLayout(new GridBagLayout());
            ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] { 0, 85, 80 };
            ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] { 1.0, 0.0, 0.0 };

            //---- startButton ----
            startButton.setText("Start");
            startButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    startButtonActionPerformed(e);
                }
            });
            buttonBar.add(startButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));

            //---- stopButton ----
            stopButton.setText("Stop");
            stopButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    stopButtonActionPerformed(e);
                }
            });
            buttonBar.add(stopButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
        }
        dialogPane.add(buttonBar, BorderLayout.SOUTH);
    }
    contentPane.add(dialogPane, BorderLayout.CENTER);
    pack();
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:com.cactus.ClientRegisterGUI.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.// w w  w .j a  v  a 2 s  .  co  m
 */

// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    this.pack();
    this.setLocationRelativeTo(null);

    Username_TextField = new JTextField();
    Email_TextField = new JTextField();
    Email_Confirm_TextField = new JTextField();
    Password_TextField = new JPasswordField();
    Confirm_Password_TextField = new JPasswordField();
    Username_Label = new JLabel();
    Email_Label = new JLabel();
    Email_Confirm_Label = new JLabel();
    Password_Label = new JLabel();
    Confirm_Password_Label = new JLabel();
    Register_Button = new JButton();
    Cancel_Button = new JButton();

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    Email_TextField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            Email_TextFieldActionPerformed(evt);
        }
    });

    Username_Label.setText("Username:");
    Email_Label.setText("Email:");
    Email_Confirm_Label.setText("Confirm Email:");
    Password_Label.setText("Password:");
    Confirm_Password_Label.setText("Confirm Password:");

    Register_Button.setText("Register");
    Register_Button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            try {
                Register_ButtonActionPerformed(evt);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });

    Cancel_Button.setText("Cancel");
    Cancel_Button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            try {
                Cancel_ButtonActionPerformed(evt);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });

    javax.swing.GroupLayout layout = new GroupLayout(getContentPane());
    layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addGap(67)
            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup().addComponent(Confirm_Password_Label)
                            .addContainerGap())
                    .addGroup(layout.createParallelGroup(Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup().addComponent(Email_Confirm_Label)
                                    .addContainerGap())
                            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup().addComponent(Email_Label)
                                            .addContainerGap())
                                    .addGroup(layout.createSequentialGroup().addComponent(Password_Label)
                                            .addContainerGap())
                                    .addGroup(layout.createSequentialGroup().addGroup(layout
                                            .createParallelGroup(Alignment.LEADING)
                                            .addComponent(Password_TextField, GroupLayout.DEFAULT_SIZE, 250,
                                                    Short.MAX_VALUE)
                                            .addComponent(Confirm_Password_TextField, GroupLayout.DEFAULT_SIZE,
                                                    250, Short.MAX_VALUE)
                                            .addGroup(layout.createSequentialGroup().addComponent(Cancel_Button)
                                                    .addPreferredGap(ComponentPlacement.RELATED, 112,
                                                            Short.MAX_VALUE)
                                                    .addComponent(Register_Button))
                                            .addComponent(Username_Label)
                                            .addComponent(Username_TextField, 250, 250, Short.MAX_VALUE)
                                            .addComponent(Email_TextField, GroupLayout.DEFAULT_SIZE, 250,
                                                    Short.MAX_VALUE)
                                            .addComponent(Email_Confirm_TextField, GroupLayout.DEFAULT_SIZE,
                                                    250, Short.MAX_VALUE))
                                            .addGap(83)))))));
    layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap().addComponent(Username_Label)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(Username_TextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(Email_Label)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(Email_TextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(Email_Confirm_Label).addGap(10)
                    .addComponent(Email_Confirm_TextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(Password_Label)
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addComponent(Password_TextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(Confirm_Password_Label)
                    .addGap(11)
                    .addComponent(Confirm_Password_TextField, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addGap(18).addGroup(layout.createParallelGroup(Alignment.BASELINE)
                            .addComponent(Cancel_Button).addComponent(Register_Button))
                    .addContainerGap(26, Short.MAX_VALUE)));
    getContentPane().setLayout(layout);

    pack();
}

From source file:com.iisigroup.ris.WebFileScanUtilBrowserUI.java

private void initGUI() {
    final SwingActionUtil swingUtil = (SwingActionUtil) SwingActionUtil.newInstance(this);
    try {//  w  w  w .  ja  v a 2s  . co  m
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        this.setTitle("browser source code");
        {
            informationMenu = new JPopupMenu();
            setComponentPopupMenu(this, informationMenu);
        }
        {
            ListModel openFileListModel = new DefaultListModel();
            openFileList = new JList();
            openFileList.setModel(openFileListModel);
            getContentPane().add(openFileList, BorderLayout.NORTH);
            openFileList.setPreferredSize(new java.awt.Dimension(663, 281));
            openFileList.addListSelectionListener(new ListSelectionListener() {
                public void valueChanged(ListSelectionEvent evt) {
                    swingUtil.invokeAction("openFileList.valueChanged", evt);
                }
            });
            openFileList.addMouseMotionListener(new MouseMotionAdapter() {
                public void mouseMoved(MouseEvent evt) {
                    swingUtil.invokeAction("openFileList.mouseMoved", evt);
                }
            });
            openFileList.addKeyListener(new KeyAdapter() {
                public void keyPressed(KeyEvent evt) {
                    swingUtil.invokeAction("openFileList.keyPressed", evt);
                }
            });
        }
        {
            jPanel1 = new JPanel();
            GroupLayout jPanel1Layout = new GroupLayout((JComponent) jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            getContentPane().add(jPanel1, BorderLayout.SOUTH);
            jPanel1.setPreferredSize(new java.awt.Dimension(478, 35));
            {
                openSelected = new JButton();
                openSelected.setText("open all");
                openSelected.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        swingUtil.invokeAction("openSelected.actionPerformed", evt);
                    }
                });
            }
            jPanel1Layout.setHorizontalGroup(jPanel1Layout.createSequentialGroup().addContainerGap(178, 178)
                    .addComponent(openSelected, GroupLayout.PREFERRED_SIZE, 126, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(174, Short.MAX_VALUE));
            jPanel1Layout.setVerticalGroup(jPanel1Layout.createSequentialGroup().addGap(7)
                    .addComponent(openSelected, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 6, Short.MAX_VALUE));
        }
        {
            informationMenu = new JPopupMenu();
        }

        this.setSize(486, 350);
        this.setLocationRelativeTo(null);

        //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        // ?tooltip
        //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        int initialDelay = ToolTipManager.sharedInstance().getInitialDelay();
        ToolTipManager.sharedInstance().setInitialDelay(0);
        //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        // ?tooltip
        //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        swingUtil.addAction("openFileList.mouseClicked", new Action() {
            public void action(EventObject evt) throws Exception {
                DefaultListModel model = (DefaultListModel) openFileList.getModel();
                int pos = openFileList.getLeadSelectionIndex();
                if (pos == -1) {
                    return;
                }
                setOpenFileListToolTip();
                MouseEvent eeev = (MouseEvent) evt;
                if (eeev.getClickCount() != 2) {
                    return;
                }
                MFile file = (MFile) model.elementAt(pos);
                openSource(file.file);
            }
        });
        final JListUtil jlistUtil = JListUtil.newInstance(openFileList);
        swingUtil.addAction("openFileList.keyPressed", new Action() {
            public void action(EventObject evt) throws Exception {
                jlistUtil.defaultJListKeyPressed((KeyEvent) evt);
                setOpenFileListToolTip();
            }
        });
        swingUtil.addAction("openSelected.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                DefaultListModel model = (DefaultListModel) openFileList.getModel();
                for (Enumeration<?> enu = model.elements(); enu.hasMoreElements();) {
                    MFile file = (MFile) enu.nextElement();
                    openSource(file.file);
                }
            }
        });
        swingUtil.addAction("openFileList.mouseMoved", new Action() {
            public void action(EventObject evt) throws Exception {
                setOpenFileListToolTip();
            }
        });
        swingUtil.addAction("openFileList.valueChanged", new Action() {
            public void action(EventObject evt) throws Exception {
                System.out.println(evt);
                setOpenFileListToolTip();
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:TextFieldDemo.java

/**
 * This method is called from within the constructor to initialize the form.
 *//*from  w w w .  j  av  a 2  s.c  om*/

private void initComponents() {
    entry = new JTextField();
    textArea = new JTextArea();
    status = new JLabel();
    jLabel1 = new JLabel();

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setTitle("TextFieldDemo");

    textArea.setColumns(20);
    textArea.setLineWrap(true);
    textArea.setRows(5);
    textArea.setWrapStyleWord(true);
    textArea.setEditable(false);
    jScrollPane1 = new JScrollPane(textArea);

    jLabel1.setText("Enter text to search:");

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);

    // Create a parallel group for the horizontal axis
    ParallelGroup hGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING);

    // Create a sequential and a parallel groups
    SequentialGroup h1 = layout.createSequentialGroup();
    ParallelGroup h2 = layout.createParallelGroup(GroupLayout.Alignment.TRAILING);

    // Add a container gap to the sequential group h1
    h1.addContainerGap();

    // Add a scroll pane and a label to the parallel group h2
    h2.addComponent(jScrollPane1, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 450,
            Short.MAX_VALUE);
    h2.addComponent(status, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE);

    // Create a sequential group h3
    SequentialGroup h3 = layout.createSequentialGroup();
    h3.addComponent(jLabel1);
    h3.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED);
    h3.addComponent(entry, GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE);

    // Add the group h3 to the group h2
    h2.addGroup(h3);
    // Add the group h2 to the group h1
    h1.addGroup(h2);

    h1.addContainerGap();

    // Add the group h1 to the hGroup
    hGroup.addGroup(GroupLayout.Alignment.TRAILING, h1);
    // Create the horizontal group
    layout.setHorizontalGroup(hGroup);

    // Create a parallel group for the vertical axis
    ParallelGroup vGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    // Create a sequential group v1
    SequentialGroup v1 = layout.createSequentialGroup();
    // Add a container gap to the sequential group v1
    v1.addContainerGap();
    // Create a parallel group v2
    ParallelGroup v2 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v2.addComponent(jLabel1);
    v2.addComponent(entry, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
    // Add the group v2 tp the group v1
    v1.addGroup(v2);
    v1.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED);
    v1.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE);
    v1.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED);
    v1.addComponent(status);
    v1.addContainerGap();

    // Add the group v1 to the group vGroup
    vGroup.addGroup(v1);
    // Create the vertical group
    layout.setVerticalGroup(vGroup);
    pack();
}