Example usage for javax.swing GroupLayout setAutoCreateGaps

List of usage examples for javax.swing GroupLayout setAutoCreateGaps

Introduction

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

Prototype

public void setAutoCreateGaps(boolean autoCreatePadding) 

Source Link

Document

Sets whether a gap between components should automatically be created.

Usage

From source file:lookandfeel.SynthDialog.java

public SynthDialog() {
   JLabel label = new JLabel("Find What:");;
    JTextField textField = new JTextField();
    JCheckBox caseCheckBox = new JCheckBox("Match Case");
    JCheckBox wrapCheckBox = new JCheckBox("Wrap Around");
    JCheckBox wholeCheckBox = new JCheckBox("Whole Words");
    JCheckBox backCheckBox = new JCheckBox("Search Backwards");
    JButton findButton = new JButton("Find");
    JButton cancelButton = new JButton("Cancel");

    // remove redundant default border of check boxes - they would hinder
    // correct spacing and aligning (maybe not needed on some look and feels)
    caseCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    wrapCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    wholeCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    backCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);/*from  w w w  . j  a  v  a 2s.com*/
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(layout.createSequentialGroup()
        .addComponent(label)
        .addGroup(layout.createParallelGroup(LEADING)
            .addComponent(textField)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(LEADING)
                    .addComponent(caseCheckBox)
                    .addComponent(wholeCheckBox))
                .addGroup(layout.createParallelGroup(LEADING)
                    .addComponent(wrapCheckBox)
                    .addComponent(backCheckBox))))
        .addGroup(layout.createParallelGroup(LEADING)
            .addComponent(findButton)
            .addComponent(cancelButton))
    );
       
    layout.linkSize(SwingConstants.HORIZONTAL, findButton, cancelButton);

    layout.setVerticalGroup(layout.createSequentialGroup()
        .addGroup(layout.createParallelGroup(BASELINE)
            .addComponent(label)
            .addComponent(textField)
            .addComponent(findButton))
        .addGroup(layout.createParallelGroup(LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(BASELINE)
                    .addComponent(caseCheckBox)
                    .addComponent(wrapCheckBox))
                .addGroup(layout.createParallelGroup(BASELINE)
                    .addComponent(wholeCheckBox)
                    .addComponent(backCheckBox)))
            .addComponent(cancelButton))
    );

    setTitle("Find");
    pack();
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}

From source file:Main.java

public Main() {
    Container pane = getContentPane();
    GroupLayout gl = new GroupLayout(pane);
    pane.setLayout(gl);/*  w ww  .  j  a  va 2 s  .  c om*/

    JLabel avLbl = new JLabel("Available");
    JLabel tagsLbl = new JLabel("Tags");
    JLabel selLbl = new JLabel("Selected");

    JButton newBtn = new JButton("New");
    JButton moveBtn = new JButton(">>");
    JButton remBtn = new JButton("Remove");

    JList leftList = new JList();
    JScrollPane spleft = new JScrollPane(leftList);
    JList rightList = new JList();
    JScrollPane spright = new JScrollPane(rightList);

    gl.setAutoCreateGaps(true);
    gl.setAutoCreateContainerGaps(true);

    gl.setHorizontalGroup(gl.createParallelGroup(CENTER).addComponent(tagsLbl)
            .addGroup(gl.createSequentialGroup()
                    .addGroup(gl.createParallelGroup(CENTER).addComponent(avLbl)
                            .addComponent(spleft, 100, 200, Short.MAX_VALUE).addComponent(newBtn))
                    .addComponent(moveBtn).addGroup(gl.createParallelGroup(CENTER).addComponent(selLbl)
                            .addComponent(spright, 100, 200, Short.MAX_VALUE).addComponent(remBtn))));
    gl.setVerticalGroup(gl.createSequentialGroup().addComponent(tagsLbl)
            .addGroup(gl.createParallelGroup(CENTER)
                    .addGroup(gl.createSequentialGroup().addComponent(avLbl)
                            .addComponent(spleft, 100, 250, Short.MAX_VALUE).addComponent(newBtn))
                    .addComponent(moveBtn).addGroup(gl.createSequentialGroup().addComponent(selLbl)
                            .addComponent(spright, 100, 250, Short.MAX_VALUE).addComponent(remBtn))));
    pack();
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:misc.DesktopDemo.java

/** Create and show components
 *//*  w w w . jav  a  2s  . co m*/
private void initComponents() {

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setTitle("DesktopDemo");
    txtBrowserURI.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            onLaunchBrowser(null);
        }
    });

    btnLaunchBrowser.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            onLaunchBrowser(evt);
        }
    });

    txtMailTo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            onLaunchMail(null);
        }
    });

    btnLaunchEmail.setText("Launch Mail");
    btnLaunchEmail.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            onLaunchMail(evt);
        }
    });

    txtFile.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            onLaunchDefaultApplication(null);
        }
    });

    rbOpen.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            onOpenAction(evt);
        }
    });

    rbEdit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            onEditAction(evt);
        }
    });

    rbPrint.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            onPrintAction(evt);
        }
    });

    btnLaunchApplication.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            onLaunchDefaultApplication(evt);
        }
    });

    btnFile.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            onChooseFile(evt);
        }
    });

    Container conFrame = this.getContentPane();

    bgAppAction.add(rbOpen);
    bgAppAction.add(rbEdit);
    bgAppAction.add(rbPrint);

    // Components layouting

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

    GroupLayout.SequentialGroup majorHGroup = layout.createSequentialGroup();

    // Horizontal group

    GroupLayout.ParallelGroup lblHGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    lblHGroup.addComponent(lblBrowserUri, GroupLayout.Alignment.TRAILING);
    lblHGroup.addComponent(lblMailRecipient, GroupLayout.Alignment.TRAILING);
    lblHGroup.addComponent(lblFile, GroupLayout.Alignment.TRAILING);

    GroupLayout.ParallelGroup txtFieldsHGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    txtFieldsHGroup.addComponent(txtMailTo);
    txtFieldsHGroup.addComponent(txtBrowserURI);
    GroupLayout.SequentialGroup rbHGroup = layout.createSequentialGroup();
    rbHGroup.addComponent(rbOpen);
    rbHGroup.addComponent(rbEdit);
    rbHGroup.addComponent(rbPrint);
    txtFieldsHGroup.addGroup(rbHGroup);
    GroupLayout.SequentialGroup fileHGroup = layout.createSequentialGroup();
    fileHGroup.addComponent(txtFile);
    fileHGroup.addComponent(btnFile);
    txtFieldsHGroup.addGroup(fileHGroup);

    GroupLayout.ParallelGroup btnHGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    btnHGroup.addComponent(btnLaunchBrowser);
    btnHGroup.addComponent(btnLaunchEmail);
    btnHGroup.addComponent(btnLaunchApplication);

    majorHGroup.addGroup(lblHGroup);
    majorHGroup.addGroup(txtFieldsHGroup);
    majorHGroup.addGroup(btnHGroup);

    layout.setHorizontalGroup(majorHGroup);

    // Vertical group

    GroupLayout.SequentialGroup majorVGroup = layout.createSequentialGroup();

    GroupLayout.ParallelGroup uriVGroup = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    uriVGroup.addComponent(lblBrowserUri);
    uriVGroup.addComponent(txtBrowserURI);
    uriVGroup.addComponent(btnLaunchBrowser);

    GroupLayout.ParallelGroup mailVGroup = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    mailVGroup.addComponent(lblMailRecipient);
    mailVGroup.addComponent(txtMailTo);
    mailVGroup.addComponent(btnLaunchEmail);

    GroupLayout.ParallelGroup rbVGroup = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    rbVGroup.addComponent(rbOpen);
    rbVGroup.addComponent(rbEdit);
    rbVGroup.addComponent(rbPrint);

    GroupLayout.ParallelGroup fileVGroup = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    fileVGroup.addComponent(lblFile);
    fileVGroup.addComponent(btnLaunchApplication);
    fileVGroup.addComponent(txtFile);
    fileVGroup.addComponent(btnFile);

    majorVGroup.addGroup(uriVGroup);
    majorVGroup.addGroup(mailVGroup);
    majorVGroup.addGroup(rbVGroup);
    majorVGroup.addGroup(fileVGroup);

    layout.setVerticalGroup(majorVGroup);

    pack();
}

From source file:econtroller.gui.ControllerGUI.java

private void createModelerControlPanel() {
    modelerControlPanelSection = new JPanel();
    GroupLayout group = new GroupLayout(modelerControlPanelSection);
    modelerControlPanelSection.setLayout(group);
    group.setAutoCreateGaps(true);
    group.setAutoCreateContainerGaps(true);

    modelerControlPanelSection.setBorder(BorderFactory.createTitledBorder("Black Box System Identification"));

    createSamplingAndNodeOrderingSection();
    createNrInstanceSection();//w ww.j  ava  2s .c  om
    createControlPanelButtons();
    createChartPanels();

    group.setHorizontalGroup(group.createSequentialGroup()
            .addGroup(group.createParallelGroup().addComponent(orderedEnabled).addComponent(samplingOrderLbl)
                    .addComponent(maxNrInstancesLbl).addComponent(startModelerButton)
                    .addComponent(dumpDataIntoFilesBtn).addComponent(cpuLoadPanel)
                    .addComponent(responseTimePanel).addComponent(nrInstancePanel))
            .addGroup(group.createParallelGroup().addComponent(sampleOrderLayout).addComponent(instanceLayout)
                    .addComponent(stopModelerButton).addComponent(resetModelerButton)
                    .addComponent(bandwidthPanel).addComponent(costPanel).addComponent(throughputPanel)));

    group.setVerticalGroup(group.createSequentialGroup()
            .addGroup(group.createParallelGroup().addComponent(orderedEnabled))
            .addGroup(
                    group.createParallelGroup().addComponent(samplingOrderLbl).addComponent(sampleOrderLayout))
            .addGroup(group.createParallelGroup().addComponent(maxNrInstancesLbl).addComponent(instanceLayout))
            .addGroup(group.createParallelGroup().addComponent(startModelerButton)
                    .addComponent(stopModelerButton))
            .addGroup(group.createParallelGroup().addComponent(dumpDataIntoFilesBtn)
                    .addComponent(resetModelerButton))
            .addGroup(group.createParallelGroup().addComponent(cpuLoadPanel).addComponent(bandwidthPanel))
            .addGroup(group.createParallelGroup().addComponent(responseTimePanel).addComponent(costPanel))
            .addGroup(group.createParallelGroup().addComponent(nrInstancePanel).addComponent(throughputPanel)));

    modelerPanel.add(modelerControlPanelSection);
}

From source file:MyStatsPanel.java

JPanel setFields() {
    getDatabaseInfo();//from  w ww  . jav a2 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:org.zaproxy.zap.extension.fuzz.impl.ProcessorsMessageLocationDialog.java

@Override
protected JPanel getFieldsPanel() {
    JPanel fieldsPanel = new JPanel();

    GroupLayout layout = new GroupLayout(fieldsPanel);
    fieldsPanel.setLayout(layout);/*  w w w .  j  av  a 2  s.  c o m*/
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    JLabel locationLabel = new JLabel(Constant.messages
            .getString("fuzz.fuzzer.dialog.messagelocations.dialog.processors.location.label"));
    messageLocationLabel = new JLabel();
    JLabel valueLabel = new JLabel(
            Constant.messages.getString("fuzz.fuzzer.dialog.messagelocations.dialog.processors.value.label"));
    messageLocationValueLabel = new JLabel();
    JLabel payloadsLabel = new JLabel(Constant.messages
            .getString("fuzz.fuzzer.dialog.messagelocations.dialog.processors.processors.label"));

    layout.setHorizontalGroup(layout.createParallelGroup()
            .addGroup(layout.createSequentialGroup().addComponent(locationLabel)
                    .addComponent(messageLocationLabel))
            .addGroup(layout.createSequentialGroup().addComponent(valueLabel)
                    .addComponent(messageLocationValueLabel))
            .addComponent(payloadsLabel).addComponent(processorsTablePanel));

    layout.setVerticalGroup(layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(locationLabel)
                    .addComponent(messageLocationLabel))
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(valueLabel)
                    .addComponent(messageLocationValueLabel))
            .addComponent(payloadsLabel).addComponent(processorsTablePanel));

    return fieldsPanel;
}

From source file:se.llbit.chunky.renderer.ui.RenderControls.java

private JPanel buildSkyPane() {

    JLabel skyModeLbl = new JLabel("Sky Mode:");
    skyModeCB.setModel(new DefaultComboBoxModel(Sky.SkyMode.values()));
    skyModeCB.addActionListener(skyModeListener);
    updateSkyMode();/* w ww .jav  a2 s  .c o  m*/

    JLabel skymapRotationLbl = new JLabel("Skymap rotation:");
    skymapRotationSlider.setMinimum(1);
    skymapRotationSlider.setMaximum(100);
    skymapRotationSlider.addChangeListener(skyRotationListener);
    skymapRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap");
    JLabel lightProbeRotationLbl = new JLabel("Skymap rotation:");
    lightProbeRotationSlider.setMinimum(1);
    lightProbeRotationSlider.setMaximum(100);
    lightProbeRotationSlider.addChangeListener(skyRotationListener);
    lightProbeRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap");
    JLabel skyboxRotationLbl = new JLabel("Skybox rotation:");
    skyboxRotationSlider.setMinimum(1);
    skyboxRotationSlider.setMaximum(100);
    skyboxRotationSlider.addChangeListener(skyRotationListener);
    skyboxRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap");
    updateSkyRotation();

    skyHorizonOffset.update();
    cloudSize.update();
    cloudXOffset.update();
    cloudYOffset.update();
    cloudZOffset.update();

    JLabel verticalResolutionLbl = new JLabel("Vertical resolution (degrees):");
    ButtonGroup verticalResolution = new ButtonGroup();
    v90Btn.setSelected(true);
    v180Btn.setSelected(false);
    verticalResolution.add(v90Btn);
    verticalResolution.add(v180Btn);

    v90Btn.addActionListener(v90Listener);
    v180Btn.addActionListener(v180Listener);
    updateVerticalResolution();

    simulatedSkyPanel.setBorder(BorderFactory.createTitledBorder("Simulated Sky Settings"));
    GroupLayout simulatedSkyLayout = new GroupLayout(simulatedSkyPanel);
    simulatedSkyPanel.setLayout(simulatedSkyLayout);
    simulatedSkyLayout.setAutoCreateContainerGaps(true);
    simulatedSkyLayout.setAutoCreateGaps(true);
    simulatedSkyLayout.setHorizontalGroup(simulatedSkyLayout.createParallelGroup()
            .addGroup(skyHorizonOffset.horizontalGroup(simulatedSkyLayout)));
    simulatedSkyLayout.setVerticalGroup(simulatedSkyLayout.createSequentialGroup()
            .addGroup(skyHorizonOffset.verticalGroup(simulatedSkyLayout)));

    skymapPanel.setBorder(BorderFactory.createTitledBorder("Skymap Settings"));
    GroupLayout skymapLayout = new GroupLayout(skymapPanel);
    skymapPanel.setLayout(skymapLayout);
    skymapLayout.setAutoCreateContainerGaps(true);
    skymapLayout.setAutoCreateGaps(true);
    skymapLayout.setHorizontalGroup(skymapLayout.createParallelGroup().addComponent(loadSkymapBtn)
            .addGroup(skymapLayout.createSequentialGroup().addComponent(skymapRotationLbl)
                    .addComponent(skymapRotationSlider))
            .addGroup(skymapLayout.createSequentialGroup().addComponent(verticalResolutionLbl)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(v90Btn)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(v180Btn)));
    skymapLayout.setVerticalGroup(skymapLayout.createSequentialGroup().addComponent(loadSkymapBtn)
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(skymapLayout.createParallelGroup(Alignment.BASELINE).addComponent(verticalResolutionLbl)
                    .addComponent(v90Btn).addComponent(v180Btn))
            .addPreferredGap(ComponentPlacement.RELATED).addGroup(skymapLayout.createParallelGroup()
                    .addComponent(skymapRotationLbl).addComponent(skymapRotationSlider)));

    loadSkymapBtn.setText("Load Skymap");
    loadSkymapBtn.setToolTipText("Use a panoramic skymap");
    loadSkymapBtn.addActionListener(new SkymapTextureLoader(renderMan));

    lightProbePanel.setBorder(BorderFactory.createTitledBorder("Spherical Skymap Settings"));
    GroupLayout lightProbeLayout = new GroupLayout(lightProbePanel);
    lightProbePanel.setLayout(lightProbeLayout);
    lightProbeLayout.setAutoCreateContainerGaps(true);
    lightProbeLayout.setAutoCreateGaps(true);
    lightProbeLayout.setHorizontalGroup(lightProbeLayout.createParallelGroup().addComponent(loadLightProbeBtn)
            .addGroup(lightProbeLayout.createSequentialGroup().addComponent(lightProbeRotationLbl)
                    .addComponent(lightProbeRotationSlider)));
    lightProbeLayout.setVerticalGroup(lightProbeLayout.createSequentialGroup().addComponent(loadLightProbeBtn)
            .addPreferredGap(ComponentPlacement.RELATED).addGroup(lightProbeLayout.createParallelGroup()
                    .addComponent(lightProbeRotationLbl).addComponent(lightProbeRotationSlider)));

    loadLightProbeBtn.setText("Load Spherical Skymap");
    loadLightProbeBtn.setToolTipText("Select the spherical skymap to use");
    loadLightProbeBtn.addActionListener(new SkymapTextureLoader(renderMan));

    skyGradientPanel.setBorder(BorderFactory.createTitledBorder("Sky Gradient"));
    gradientEditor = new GradientEditor();
    gradientEditor.addGradientListener(gradientListener);
    updateSkyGradient();
    skyGradientPanel.add(gradientEditor);

    GroupLayout skyboxLayout = new GroupLayout(skyboxPanel);
    skyboxPanel.setLayout(skyboxLayout);
    skyboxPanel.setBorder(BorderFactory.createTitledBorder("Skybox"));

    JLabel skyboxLbl = new JLabel("Load skybox textures:");

    JButton loadUpTexture = new JButton("Up");
    loadUpTexture.setToolTipText("Load up texture");
    loadUpTexture.setIcon(Icon.skyboxUp.imageIcon());
    loadUpTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_UP));

    JButton loadDownTexture = new JButton("Down");
    loadDownTexture.setToolTipText("Load down texture");
    loadDownTexture.setIcon(Icon.skyboxDown.imageIcon());
    loadDownTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_DOWN));

    JButton loadFrontTexture = new JButton("Front");
    loadFrontTexture.setToolTipText("Load front (north) texture");
    loadFrontTexture.setIcon(Icon.skyboxFront.imageIcon());
    loadFrontTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_FRONT));

    JButton loadBackTexture = new JButton("Back");
    loadBackTexture.setToolTipText("Load back (south) texture");
    loadBackTexture.setIcon(Icon.skyboxBack.imageIcon());
    loadBackTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_BACK));

    JButton loadRightTexture = new JButton("Right");
    loadRightTexture.setToolTipText("Load right (east) texture");
    loadRightTexture.setIcon(Icon.skyboxRight.imageIcon());
    loadRightTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_RIGHT));

    JButton loadLeftTexture = new JButton("Left");
    loadLeftTexture.setToolTipText("Load left (west) texture");
    loadLeftTexture.setIcon(Icon.skyboxLeft.imageIcon());
    loadLeftTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_LEFT));

    skyboxLayout.setAutoCreateContainerGaps(true);
    skyboxLayout.setAutoCreateGaps(true);
    skyboxLayout.setHorizontalGroup(skyboxLayout.createParallelGroup()
            .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl)
                    .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture)
                            .addComponent(loadFrontTexture).addComponent(loadRightTexture))
                    .addGroup(skyboxLayout.createParallelGroup().addComponent(loadDownTexture)
                            .addComponent(loadBackTexture).addComponent(loadLeftTexture)))
            .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxRotationLbl)
                    .addComponent(skyboxRotationSlider)));
    skyboxLayout.setVerticalGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl)
            .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture)
                    .addComponent(loadDownTexture))
            .addGroup(skyboxLayout.createParallelGroup().addComponent(loadFrontTexture)
                    .addComponent(loadBackTexture))
            .addGroup(skyboxLayout.createParallelGroup().addComponent(loadRightTexture)
                    .addComponent(loadLeftTexture))
            .addGroup(skyboxLayout.createParallelGroup().addComponent(skyboxRotationLbl)
                    .addComponent(skyboxRotationSlider)));

    atmosphereEnabled.setText("enable atmosphere");
    atmosphereEnabled.addActionListener(atmosphereListener);
    updateAtmosphereCheckBox();

    transparentSky.setText("transparent sky");
    transparentSky.addActionListener(transparentSkyListener);
    updateTransparentSky();

    volumetricFogEnabled.setText("enable volumetric fog");
    volumetricFogEnabled.addActionListener(volumetricFogListener);
    updateVolumetricFogCheckBox();

    cloudsEnabled.setText("enable clouds");
    cloudsEnabled.addActionListener(cloudsEnabledListener);
    updateCloudsEnabledCheckBox();

    JPanel panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
            .createParallelGroup()
            .addGroup(layout.createSequentialGroup().addComponent(skyModeLbl)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(skyModeCB,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
            .addComponent(simulatedSkyPanel).addComponent(skymapPanel).addComponent(lightProbePanel)
            .addComponent(skyGradientPanel).addComponent(skyboxPanel).addComponent(atmosphereEnabled)
            .addComponent(transparentSky).addComponent(volumetricFogEnabled).addComponent(cloudsEnabled)
            .addGroup(cloudSize.horizontalGroup(layout)).addGroup(cloudXOffset.horizontalGroup(layout))
            .addGroup(cloudYOffset.horizontalGroup(layout)).addGroup(cloudZOffset.horizontalGroup(layout)))
            .addContainerGap());
    layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(skyModeLbl)
                    .addComponent(skyModeCB))
            .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(simulatedSkyPanel)
            .addComponent(skymapPanel).addComponent(lightProbePanel).addComponent(skyGradientPanel)
            .addComponent(skyboxPanel).addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(atmosphereEnabled).addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(transparentSky).addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(volumetricFogEnabled).addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(cloudsEnabled).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudSize.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudXOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudYOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudZOffset.verticalGroup(layout)).addContainerGap());
    return panel;
}

From source file:se.llbit.chunky.renderer.ui.tabs.SkyTab.java

public SkyTab(RenderControls renderControls) {
    super(renderControls);

    JLabel skyModeLbl = new JLabel("Sky Mode:");
    skyModeCB.setModel(new DefaultComboBoxModel(Sky.SkyMode.values()));
    skyModeCB.addActionListener(skyModeListener);

    // Need to hide these to not warp the Swing layout:
    simulatedSkyPanel.setVisible(false);
    skymapPanel.setVisible(false);/*from  w  w w. j a va 2 s  . c om*/
    lightProbePanel.setVisible(false);
    skyGradientPanel.setVisible(false);
    skyboxPanel.setVisible(false);

    JLabel skymapRotationLbl = new JLabel("Skymap rotation:");
    skymapRotationSlider.setMinimum(1);
    skymapRotationSlider.setMaximum(100);
    skymapRotationSlider.addChangeListener(skyRotationListener);
    skymapRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap");
    JLabel lightProbeRotationLbl = new JLabel("Skymap rotation:");
    lightProbeRotationSlider.setMinimum(1);
    lightProbeRotationSlider.setMaximum(100);
    lightProbeRotationSlider.addChangeListener(skyRotationListener);
    lightProbeRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap");
    JLabel skyboxRotationLbl = new JLabel("Skybox rotation:");
    skyboxRotationSlider.setMinimum(1);
    skyboxRotationSlider.setMaximum(100);
    skyboxRotationSlider.addChangeListener(skyRotationListener);
    skyboxRotationSlider.setToolTipText("Controls the horizontal rotational offset for the skymap");

    JLabel verticalResolutionLbl = new JLabel("Vertical resolution (degrees):");
    ButtonGroup verticalResolution = new ButtonGroup();
    v90Btn.setSelected(true);
    v180Btn.setSelected(false);
    verticalResolution.add(v90Btn);
    verticalResolution.add(v180Btn);

    v90Btn.addActionListener(v90Listener);
    v180Btn.addActionListener(v180Listener);

    simulatedSkyPanel.setBorder(BorderFactory.createTitledBorder("Simulated Sky Settings"));
    GroupLayout simulatedSkyLayout = new GroupLayout(simulatedSkyPanel);
    simulatedSkyPanel.setLayout(simulatedSkyLayout);
    simulatedSkyLayout.setAutoCreateContainerGaps(true);
    simulatedSkyLayout.setAutoCreateGaps(true);
    simulatedSkyLayout.setHorizontalGroup(simulatedSkyLayout.createParallelGroup()
            .addGroup(skyHorizonOffset.horizontalGroup(simulatedSkyLayout)));
    simulatedSkyLayout.setVerticalGroup(simulatedSkyLayout.createSequentialGroup()
            .addGroup(skyHorizonOffset.verticalGroup(simulatedSkyLayout)));

    skymapPanel.setBorder(BorderFactory.createTitledBorder("Skymap Settings"));
    GroupLayout skymapLayout = new GroupLayout(skymapPanel);
    skymapPanel.setLayout(skymapLayout);
    skymapLayout.setAutoCreateContainerGaps(true);
    skymapLayout.setAutoCreateGaps(true);
    skymapLayout.setHorizontalGroup(skymapLayout.createParallelGroup().addComponent(loadSkymapBtn)
            .addGroup(skymapLayout.createSequentialGroup().addComponent(skymapRotationLbl)
                    .addComponent(skymapRotationSlider))
            .addGroup(skymapLayout.createSequentialGroup().addComponent(verticalResolutionLbl)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(v90Btn)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(v180Btn)));
    skymapLayout.setVerticalGroup(skymapLayout.createSequentialGroup().addComponent(loadSkymapBtn)
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(skymapLayout.createParallelGroup(Alignment.BASELINE).addComponent(verticalResolutionLbl)
                    .addComponent(v90Btn).addComponent(v180Btn))
            .addPreferredGap(ComponentPlacement.RELATED).addGroup(skymapLayout.createParallelGroup()
                    .addComponent(skymapRotationLbl).addComponent(skymapRotationSlider)));

    loadSkymapBtn.setText("Load Skymap");
    loadSkymapBtn.setToolTipText("Use a panoramic skymap");
    loadSkymapBtn.addActionListener(new SkymapTextureLoader(renderMan));

    lightProbePanel.setBorder(BorderFactory.createTitledBorder("Spherical Skymap Settings"));
    GroupLayout lightProbeLayout = new GroupLayout(lightProbePanel);
    lightProbePanel.setLayout(lightProbeLayout);
    lightProbeLayout.setAutoCreateContainerGaps(true);
    lightProbeLayout.setAutoCreateGaps(true);
    lightProbeLayout.setHorizontalGroup(lightProbeLayout.createParallelGroup().addComponent(loadLightProbeBtn)
            .addGroup(lightProbeLayout.createSequentialGroup().addComponent(lightProbeRotationLbl)
                    .addComponent(lightProbeRotationSlider)));
    lightProbeLayout.setVerticalGroup(lightProbeLayout.createSequentialGroup().addComponent(loadLightProbeBtn)
            .addPreferredGap(ComponentPlacement.RELATED).addGroup(lightProbeLayout.createParallelGroup()
                    .addComponent(lightProbeRotationLbl).addComponent(lightProbeRotationSlider)));

    loadLightProbeBtn.setText("Load Spherical Skymap");
    loadLightProbeBtn.setToolTipText("Select the spherical skymap to use");
    loadLightProbeBtn.addActionListener(new SkymapTextureLoader(renderMan));

    skyGradientPanel.setBorder(BorderFactory.createTitledBorder("Sky Gradient"));
    gradientEditor = new GradientEditor();
    gradientEditor.addGradientListener(gradientListener);
    skyGradientPanel.add(gradientEditor);

    GroupLayout skyboxLayout = new GroupLayout(skyboxPanel);
    skyboxPanel.setLayout(skyboxLayout);
    skyboxPanel.setBorder(BorderFactory.createTitledBorder("Skybox"));

    JLabel skyboxLbl = new JLabel("Load skybox textures:");

    JButton loadUpTexture = new JButton("Up");
    loadUpTexture.setToolTipText("Load up texture");
    loadUpTexture.setIcon(Icon.skyboxUp.imageIcon());
    loadUpTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_UP));

    JButton loadDownTexture = new JButton("Down");
    loadDownTexture.setToolTipText("Load down texture");
    loadDownTexture.setIcon(Icon.skyboxDown.imageIcon());
    loadDownTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_DOWN));

    JButton loadFrontTexture = new JButton("Front");
    loadFrontTexture.setToolTipText("Load front (north) texture");
    loadFrontTexture.setIcon(Icon.skyboxFront.imageIcon());
    loadFrontTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_FRONT));

    JButton loadBackTexture = new JButton("Back");
    loadBackTexture.setToolTipText("Load back (south) texture");
    loadBackTexture.setIcon(Icon.skyboxBack.imageIcon());
    loadBackTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_BACK));

    JButton loadRightTexture = new JButton("Right");
    loadRightTexture.setToolTipText("Load right (east) texture");
    loadRightTexture.setIcon(Icon.skyboxRight.imageIcon());
    loadRightTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_RIGHT));

    JButton loadLeftTexture = new JButton("Left");
    loadLeftTexture.setToolTipText("Load left (west) texture");
    loadLeftTexture.setIcon(Icon.skyboxLeft.imageIcon());
    loadLeftTexture.addActionListener(new SkyboxTextureLoader(renderMan, Sky.SKYBOX_LEFT));

    skyboxLayout.setAutoCreateContainerGaps(true);
    skyboxLayout.setAutoCreateGaps(true);
    skyboxLayout.setHorizontalGroup(skyboxLayout.createParallelGroup()
            .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl)
                    .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture)
                            .addComponent(loadFrontTexture).addComponent(loadRightTexture))
                    .addGroup(skyboxLayout.createParallelGroup().addComponent(loadDownTexture)
                            .addComponent(loadBackTexture).addComponent(loadLeftTexture)))
            .addGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxRotationLbl)
                    .addComponent(skyboxRotationSlider)));
    skyboxLayout.setVerticalGroup(skyboxLayout.createSequentialGroup().addComponent(skyboxLbl)
            .addGroup(skyboxLayout.createParallelGroup().addComponent(loadUpTexture)
                    .addComponent(loadDownTexture))
            .addGroup(skyboxLayout.createParallelGroup().addComponent(loadFrontTexture)
                    .addComponent(loadBackTexture))
            .addGroup(skyboxLayout.createParallelGroup().addComponent(loadRightTexture)
                    .addComponent(loadLeftTexture))
            .addGroup(skyboxLayout.createParallelGroup().addComponent(skyboxRotationLbl)
                    .addComponent(skyboxRotationSlider)));

    transparentSky.setText("transparent sky");
    transparentSky.setToolTipText("Disables rendering the skybox");
    transparentSky.addActionListener(transparentSkyListener);

    JLabel fogColorLbl = new JLabel(
            "<html>Hint: set fog density &gt; 0.1 for thick fog,<br>set it &lt; 0.1 for haze/atmosphere effect");
    fogColorBtn.setIcon(Icon.colors.imageIcon());
    fogColorBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ColorPicker picker = new ColorPicker(fogColorBtn, renderMan.scene().getFogColor());
            picker.addColorListener(new ColorListener() {
                @Override
                public void onColorPicked(Vector3d color) {
                    renderMan.scene().setFogColor(color);
                }
            });
        }
    });

    cloudsEnabled.setText("enable clouds");
    cloudsEnabled.addActionListener(cloudsEnabledListener);

    GroupLayout layout = new GroupLayout(this);
    setLayout(layout);
    layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
            .createParallelGroup()
            .addGroup(layout.createSequentialGroup().addComponent(skyModeLbl)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(skyModeCB,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
            .addComponent(simulatedSkyPanel).addComponent(skymapPanel).addComponent(lightProbePanel)
            .addComponent(skyGradientPanel).addComponent(skyboxPanel).addComponent(transparentSky)
            .addComponent(cloudsEnabled).addGroup(cloudSize.horizontalGroup(layout))
            .addGroup(cloudXOffset.horizontalGroup(layout)).addGroup(cloudYOffset.horizontalGroup(layout))
            .addGroup(cloudZOffset.horizontalGroup(layout)).addGroup(fogDensity.horizontalGroup(layout))
            .addGroup(layout.createSequentialGroup().addComponent(fogColorBtn)
                    .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(fogColorLbl)))
            .addContainerGap());
    layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(skyModeLbl)
                    .addComponent(skyModeCB))
            .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(simulatedSkyPanel)
            .addComponent(skymapPanel).addComponent(lightProbePanel).addComponent(skyGradientPanel)
            .addComponent(skyboxPanel).addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(transparentSky).addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(cloudsEnabled).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudSize.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudXOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudYOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(cloudZOffset.verticalGroup(layout)).addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(fogDensity.verticalGroup(layout)).addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup().addComponent(fogColorBtn).addComponent(fogColorLbl))
            .addContainerGap());
}