Example usage for java.awt GridBagLayout GridBagLayout

List of usage examples for java.awt GridBagLayout GridBagLayout

Introduction

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

Prototype

public GridBagLayout() 

Source Link

Document

Creates a grid bag layout manager.

Usage

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

/**
 * This method initializes jPanel   //from w w w . jav  a 2s .  c om
 *    
 * @return javax.swing.JPanel   
 */
private JPanel getJPanelbutton() {
    if (jPanel == null) {
        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
        gridBagConstraints4.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints4.insets = new Insets(10, 0, 0, 10);
        gridBagConstraints4.anchor = GridBagConstraints.NORTH;
        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
        gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints5.insets = new Insets(10, 0, 0, 10);
        gridBagConstraints5.gridx = 0;
        gridBagConstraints5.gridy = 1;

        jPanel = new JPanel();
        jPanel.setLayout(new GridBagLayout());
        jPanel.add(getJButtonReportExport(), gridBagConstraints4);
    }
    return jPanel;
}

From source file:ImageOpByRomain.java

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

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

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

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

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

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

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

    add(controls, BorderLayout.SOUTH);
}

From source file:gdt.jgui.entity.webset.JWeblinkEditor.java

/**
 * The default constructor./* w w w .  jav  a2  s .  c  o  m*/
 */
public JWeblinkEditor() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0 };
    gridBagLayout.columnWeights = new double[] { 0.0, 1.0 };
    gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0 };
    setLayout(gridBagLayout);

    String icon$ = Support.readHandlerIcon(null, JEntitiesPanel.class, "globe.png");
    byte[] ba = Base64.decodeBase64(icon$);
    ImageIcon icon = new ImageIcon(ba);
    Image image = icon.getImage().getScaledInstance(24, 24, 0);
    icon.setImage(image);
    JLabel iconLabel = new JLabel("Icon");
    c = new GridBagConstraints();
    c.insets = new Insets(5, 5, 5, 5);
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 0;
    add(iconLabel, c);
    iconLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            showIconMenu(e);
        }
    });
    iconIcon = new JLabel();
    iconIcon.setIcon(icon);
    c_0 = new GridBagConstraints();
    c_0.anchor = GridBagConstraints.WEST;
    c_0.insets = new Insets(0, 5, 5, 0);
    c.anchor = GridBagConstraints.WEST;
    c_0.gridx = 1;
    c_0.gridy = 0;
    add(iconIcon, c_0);
    iconIcon.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            showIconMenu(e);
        }
    });
    JLabel lblName = new JLabel("Name");
    c_1 = new GridBagConstraints();
    c_1.insets = new Insets(5, 5, 5, 5);
    c_1.fill = GridBagConstraints.HORIZONTAL;
    c_1.gridx = 0;
    c_1.gridy = 1;
    add(lblName, c_1);

    nameField = new JTextField();
    c_2 = new GridBagConstraints();
    c_2.insets = new Insets(0, 5, 5, 0);
    c_2.fill = GridBagConstraints.HORIZONTAL;
    c_2.gridx = 1;
    c_2.gridy = 1;
    add(nameField, c_2);

    JLabel lblUrl = new JLabel("Address");
    c_3 = new GridBagConstraints();
    c_3.insets = new Insets(5, 5, 5, 5);
    c_3.fill = GridBagConstraints.HORIZONTAL;
    c_3.gridx = 0;
    c_3.gridy = 2;
    add(lblUrl, c_3);

    addressField = new JTextField();
    c_4 = new GridBagConstraints();
    c_4.insets = new Insets(0, 5, 5, 0);
    c_4.fill = GridBagConstraints.HORIZONTAL;
    c_4.gridx = 1;
    c_4.gridy = 2;
    add(addressField, c_4);

    JLabel lblLogin = new JLabel("Login");
    c_5 = new GridBagConstraints();
    c_5.insets = new Insets(5, 5, 5, 5);
    c_5.fill = GridBagConstraints.HORIZONTAL;
    c_5.gridx = 0;
    c_5.gridy = 3;
    add(lblLogin, c_5);
    lblLogin.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            showLoginMenu(e);
        }
    });
    loginField = new JTextField();
    c_6 = new GridBagConstraints();
    c_6.insets = new Insets(0, 5, 5, 0);
    c_6.fill = GridBagConstraints.HORIZONTAL;
    c_6.gridx = 1;
    c_6.gridy = 3;
    add(loginField, c_6);

    JLabel lblPassword = new JLabel("Password");
    c_7 = new GridBagConstraints();
    c_7.insets = new Insets(5, 5, 5, 5);
    c_7.fill = GridBagConstraints.HORIZONTAL;
    c_7.gridx = 0;
    c_7.gridy = 4;
    add(lblPassword, c_7);
    lblPassword.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            showPasswordMenu(e);
        }
    });

    passwordField = new JTextField();
    c_8 = new GridBagConstraints();
    c_8.insets = new Insets(0, 5, 5, 0);
    c_8.fill = GridBagConstraints.HORIZONTAL;
    c_8.gridx = 1;
    c_8.gridy = 4;
    add(passwordField, c_8);

    JPanel bottom = new JPanel();
    c_9 = new GridBagConstraints();
    c_9.weighty = 1;
    c_9.fill = GridBagConstraints.VERTICAL;
    c_9.gridx = 0;
    c_9.gridy = 5;
    add(bottom, c_9);
}

From source file:com.sec.ose.osi.ui.frm.login.JPanLogin.java

/**
 * This method initializes this/*w  ww .j  ava2  s . com*/
 * 
 * @return void
 */
private void initialize() {

    this.setSize(496, 320);
    this.setLayout(new GridBagLayout());

    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridx = 0;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new Insets(0, 0, 0, 0);
    this.add(getJPanelBase(), gridBagConstraints);

    // PROXY
    getJTextProxyHost().setText(ProxyUtil.getInstance().getProxyHost());
    getJTextProxyPort().setText(ProxyUtil.getInstance().getProxyPort());
    getJTextProxyBypass().setText(ProxyUtil.getInstance().getProxyBypass());

}

From source file:DownloadDialog.java

/********************************************************************
 * Constructor: DownloadDialog/*  www . j a v a2s  .c o m*/
 * Purpose: constructor for download, with necessary references
/*******************************************************************/
public DownloadDialog(final MainApplication context, Scheduler scheduler_Ref, JList courseListSelected_Ref,
        JList courseListAll_Ref) {

    // Basic setup for dialog
    setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

    setTitle(TITLE);

    // Setup proper references
    this.scheduler = scheduler_Ref;
    this.courseListSelected = courseListSelected_Ref;
    this.courseListAll = courseListAll_Ref;

    // Store available terms
    storeTerms();

    // Constraints
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(10, 10, 10, 10);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;

    // Main panel
    panel = new JPanel(new GridBagLayout());

    // Add term select box
    termCB = new JComboBox(termsName.toArray());
    panel.add(termCB, c);

    // Setup username and password labels
    JLabel userL = new JLabel("Username:");
    JLabel passL = new JLabel("Password:");
    c.gridwidth = 1;
    c.gridx = 0;
    c.weightx = 0;

    // Add user label
    c.gridy = 1;
    c.insets = new Insets(5, 10, 0, 10);
    panel.add(userL, c);

    // Add password label
    c.gridy = 2;
    c.insets = new Insets(0, 10, 5, 10);
    panel.add(passL, c);

    // Setup user and pass text fields
    user = new JTextField();
    pass = new JPasswordField();
    c.weightx = 1;
    c.gridx = 1;

    // Add user field
    c.gridy = 1;
    c.insets = new Insets(5, 10, 2, 10);
    panel.add(user, c);

    // Add pass field
    c.gridy = 2;
    c.insets = new Insets(2, 10, 5, 10);
    panel.add(pass, c);

    // Setup login button
    JButton login = new JButton("Login");
    login.addActionListener(this);
    c.insets = new Insets(10, 10, 10, 10);
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 2;
    c.weightx = 1;
    panel.add(login, c);

    // Add panel to main box
    add(panel);

    // Pack the components and give userbox focus
    pack();
    user.requestFocus();

    // Create worker to download courses
    worker = new SwingWorker<Void, Void>() {
        protected Void doInBackground() throws Exception {

            // Reset courses
            scheduler.resetCourses();

            // Constraints
            GridBagConstraints c = new GridBagConstraints();
            c.fill = GridBagConstraints.BOTH;
            c.insets = new Insets(10, 10, 10, 10);
            c.gridx = 0;
            c.weightx = 1;
            c.weighty = 0;

            // Remove all elements
            panel.removeAll();

            // Add status
            JLabel status = new JLabel("Connecting...");
            c.gridy = 0;
            panel.add(status, c);

            // Add progress bar
            JProgressBar progressBar = new JProgressBar(0, SUBJECTS.length);
            c.gridy = 1;
            panel.add(progressBar, c);
            progressBar.setPreferredSize(new Dimension(275, 12));

            // Revalidate, repaint, and pack
            //revalidate();
            repaint();
            pack();

            try {

                // Create client
                DefaultHttpClient client = new DefaultHttpClient();

                // Setup and execute initial login
                HttpGet initialLogin = new HttpGet("http://jweb.kettering.edu/cku1/twbkwbis.P_ValLogin");
                HttpResponse response = client.execute(initialLogin);
                HTMLParser.parse(response);

                // Get current term
                String term = termsValue.get(termCB.getSelectedIndex());

                // Consume entity (cookies)
                HttpEntity entity = response.getEntity();
                if (entity != null)
                    entity.consumeContent();

                // Create post for login
                HttpPost login = new HttpPost("http://jweb.kettering.edu/cku1/twbkwbis.P_ValLogin");

                // Parameters
                List<NameValuePair> parameters = new ArrayList<NameValuePair>();
                parameters.add(new BasicNameValuePair("sid", user.getText()));
                parameters.add(new BasicNameValuePair("PIN", pass.getText()));
                login.setEntity(new UrlEncodedFormEntity(parameters));
                login.setHeader("Referer", "http://jweb.kettering.edu/cku1/twbkwbis.P_ValLogin");

                // Login !
                response = client.execute(login);

                // Store proper cookies
                List<Cookie> cookies = client.getCookieStore().getCookies();

                // Start off assuming logging in failed
                boolean loggedIn = false;

                // Check cookies for successful login
                for (int i = 0; i < cookies.size(); i++)
                    if (cookies.get(i).getName().equals("SESSID"))
                        loggedIn = true;

                // Success?
                if (loggedIn) {

                    // Consumption of feed
                    HTMLParser.parse(response);

                    // Execute GET class list page
                    HttpGet classList = new HttpGet(
                            "http://jweb.kettering.edu/cku1/bwskfcls.p_sel_crse_search");
                    classList.setHeader("Referer", "https://jweb.kettering.edu/cku1/twbkwbis.P_GenMenu");
                    response = client.execute(classList);
                    HTMLParser.parse(response);

                    // Execute GET for course page
                    HttpGet coursePage = new HttpGet(
                            "http://jweb.kettering.edu/cku1/bwckgens.p_proc_term_date?p_calling_proc=P_CrseSearch&p_term="
                                    + term);
                    coursePage.setHeader("Referer",
                            "http://jweb.kettering.edu/cku1/bwskfcls.p_sel_crse_search");
                    response = client.execute(coursePage);
                    HTMLParser.parse(response);

                    // Download every subject's data
                    for (int index = 0; index < SUBJECTS.length; index++) {

                        // Don't download if cancel was pressed
                        if (isCancelled())
                            break;

                        // Update status, progress bar, then store course
                        String subject = SUBJECTS[index];
                        status.setText("Downloading " + subject);
                        progressBar.setValue(index);
                        scheduler.storeDynamicCourse(subject, client, term);
                    }

                    // Update course list data
                    courseListAll.setListData(scheduler.getCourseIDs().toArray());

                    // Clear course list data
                    String[] empty = {};
                    courseListSelected.setListData(empty);
                    context.updatePermutations();
                    context.updateSchedule();

                    // Dispose of dialog if cancelled
                    if (!isCancelled()) {
                        dispose();
                    }

                }

                // Invalid login?
                else {

                    // Update status
                    status.setText("Invalid login.");
                }
            }

            // Failed to download?
            catch (Exception exc) {

                // Show stack trace, and update status
                exc.printStackTrace();
                status.setText("Failed downloading.");
            }

            return null;
        }
    };

    // Setup window close event to be same as cancel
    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {

            // Cancel all downloads then dispose
            worker.cancel(true);
            dispose();
        }
    });

    // Make sure dialog is visible
    setLocationRelativeTo(context);
    setVisible(true);

}

From source file:org.zaproxy.zap.extension.customFire.ScanProgressDialog.java

/**
 * /*  ww w .ja v  a  2  s.com*/
 */
private void initialize() {
    this.setSize(new Dimension(580, 504));

    if (site != null) {

        this.setTitle("Scann Progress");

    }

    JTabbedPane tabbedPane = new JTabbedPane();
    JPanel tab1 = new JPanel();
    tab1.setLayout(new GridBagLayout());

    JPanel hostPanel = new JPanel();

    hostPanel.setLayout(new GridBagLayout());

    hostPanel.add(new JLabel("Host:"), LayoutHelper.getGBC(0, 0, 1, 0.4D));

    hostPanel.add(getHostSelect(), LayoutHelper.getGBC(1, 0, 1, 0.6D));

    tab1.add(hostPanel, LayoutHelper.getGBC(0, 0, 3, 1.0D, 0.0D));

    tab1.add(getJScrollPane(), LayoutHelper.getGBC(0, 1, 3, 1.0D, 1.0D));//*

    tab1.add(new JLabel(), LayoutHelper.getGBC(0, 1, 1, 1.0D, 0.0D)); // spacer
    tab1.add(getCloseButton(), LayoutHelper.getGBC(1, 2, 1, 0.0D, 0.0D));

    tab1.add(new JLabel(), LayoutHelper.getGBC(2, 1, 1, 1.0D, 0.0D)); // spacer

    tabbedPane.insertTab("Progress", null, tab1, null, 0);
    this.add(tabbedPane);

    int mins = extension.getScannerParam().getMaxChartTimeInMins();
    if (mins > 0) {
        // Treat zero mins as disabled

        JPanel tab2 = new JPanel();

        tab2.setLayout(new GridBagLayout());

        this.seriesTotal = new TimeSeries("TotalResponses"); // Name not shown, so no need to i18n
        final TimeSeriesCollection dataset = new TimeSeriesCollection(this.seriesTotal);

        this.series100 = new TimeSeries("1xx");
        this.series200 = new TimeSeries("2xx");
        this.series300 = new TimeSeries("3xx");
        this.series400 = new TimeSeries("4xx");
        this.series500 = new TimeSeries("5xx");

        this.seriesTotal.setMaximumItemAge(mins * 60);
        this.series100.setMaximumItemAge(mins * 60);
        this.series200.setMaximumItemAge(mins * 60);
        this.series300.setMaximumItemAge(mins * 60);
        this.series400.setMaximumItemAge(mins * 60);
        this.series500.setMaximumItemAge(mins * 60);

        dataset.addSeries(series100);
        dataset.addSeries(series200);
        dataset.addSeries(series300);
        dataset.addSeries(series400);
        dataset.addSeries(series500);

        chart = createChart(dataset);//*

        // Set up some vaguesly sensible colours
        chart.getXYPlot().getRenderer(0).setSeriesPaint(0, Color.BLACK); // Totals
        chart.getXYPlot().getRenderer(0).setSeriesPaint(1, Color.ORANGE); // 100: Info
        chart.getXYPlot().getRenderer(0).setSeriesPaint(2, Color.GREEN); // 200: OK
        chart.getXYPlot().getRenderer(0).setSeriesPaint(3, Color.BLUE); // 300: Info
        chart.getXYPlot().getRenderer(0).setSeriesPaint(4, Color.YELLOW); // 400: Bad req
        chart.getXYPlot().getRenderer(0).setSeriesPaint(5, Color.RED); // 500: Internal error

        chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(5.0f)); // Totals
        chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(3.0f)); // 100: Info
        chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(3.0f)); // 200: OK
        chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(3.0f)); // 300: Info
        chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(3.0f)); // 400: Bad req
        chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(3.0f)); // 500: Internal error

        final ChartPanel chartPanel = new ChartPanel(chart);

        tab2.add(chartPanel, LayoutHelper.getGBC(0, 0, 1, 1.0D, 1.0D));

        tabbedPane.insertTab("ResponseCharts", null, tab2, null, 1);

    }

    // Stop the updating thread when the window is closed
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {
            stopThread = true;
        }
    });

}

From source file:com.digitalgeneralists.assurance.ui.components.ScanDefinitionPanel.java

@Override
protected void initializeComponent() {
    if (!this.initialized) {
        if (this.definition == null) {
            mode = AssuranceDialogMode.ADD;
            this.dialogTitle = "Add New Scan Definition";
            this.definition = new ScanDefinition();
        } else {//w ww  . j ava 2s. c o m
            mode = AssuranceDialogMode.EDIT;
            this.dialogTitle = "Edit Scan Definition";
        }

        GridBagLayout gridbag = new GridBagLayout();
        this.setLayout(gridbag);

        final JPanel optionsPanel = new JPanel();
        optionsPanel.setLayout(new GridBagLayout());

        Border optionsBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        optionsBorder = BorderFactory.createTitledBorder(optionsBorder, "Merge Options", TitledBorder.CENTER,
                TitledBorder.TOP);

        GridBagConstraints nameTextFieldConstraints = new GridBagConstraints();
        nameTextFieldConstraints.anchor = GridBagConstraints.NORTH;
        nameTextFieldConstraints.fill = GridBagConstraints.HORIZONTAL;
        nameTextFieldConstraints.gridx = 0;
        nameTextFieldConstraints.gridy = 0;
        nameTextFieldConstraints.weightx = 1.0;
        nameTextFieldConstraints.weighty = 1.0;
        nameTextFieldConstraints.gridheight = 1;
        nameTextFieldConstraints.gridwidth = 2;
        nameTextFieldConstraints.insets = new Insets(10, 5, 0, 5);

        this.nameTextField.setText(this.definition.getName());
        this.nameTextField.getDocument().addDocumentListener(this.textPropertyValidationListener);
        this.add(this.nameTextField, nameTextFieldConstraints);

        Border existingScanMappingsPanelBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        existingScanMappingsPanelBorder = BorderFactory.createTitledBorder(existingScanMappingsPanelBorder,
                "Paths", TitledBorder.CENTER, TitledBorder.TOP);

        GridBagConstraints existingScanMappingsPanelConstraints = new GridBagConstraints();
        existingScanMappingsPanelConstraints.anchor = GridBagConstraints.WEST;
        existingScanMappingsPanelConstraints.fill = GridBagConstraints.BOTH;
        existingScanMappingsPanelConstraints.gridx = 0;
        existingScanMappingsPanelConstraints.gridy = 1;
        existingScanMappingsPanelConstraints.weightx = 1.0;
        existingScanMappingsPanelConstraints.weighty = 1.0;
        existingScanMappingsPanelConstraints.gridheight = 1;
        existingScanMappingsPanelConstraints.gridwidth = 2;
        existingScanMappingsPanelConstraints.insets = new Insets(5, 5, 0, 5);

        JPanel existingScanMappingsPanel = new JPanel();
        GridBagLayout panelGridbag = new GridBagLayout();
        existingScanMappingsPanel.setLayout(panelGridbag);
        existingScanMappingsPanel.setBorder(existingScanMappingsPanelBorder);
        this.add(existingScanMappingsPanel, existingScanMappingsPanelConstraints);

        GridBagConstraints existingScanMappingsListConstraints = new GridBagConstraints();
        existingScanMappingsListConstraints.anchor = GridBagConstraints.WEST;
        existingScanMappingsListConstraints.fill = GridBagConstraints.BOTH;
        existingScanMappingsListConstraints.gridx = 0;
        existingScanMappingsListConstraints.gridy = 0;
        existingScanMappingsListConstraints.weightx = 1.0;
        existingScanMappingsListConstraints.weighty = 0.9;
        existingScanMappingsListConstraints.gridheight = 1;
        existingScanMappingsListConstraints.gridwidth = 2;
        existingScanMappingsListConstraints.insets = new Insets(5, 5, 5, 5);

        this.definition = (ScanDefinition) ModelUtils.initializeEntity(this.definition,
                ScanDefinition.SCAN_MAPPING_PROPERTY);
        this.scanMappingsList = new ListInputPanel<ScanMappingDefinition>(this.definition, this);
        existingScanMappingsPanel.add(this.scanMappingsList, existingScanMappingsListConstraints);

        GridBagConstraints optionsPanelConstraints = new GridBagConstraints();
        optionsPanelConstraints.anchor = GridBagConstraints.SOUTH;
        optionsPanelConstraints.fill = GridBagConstraints.HORIZONTAL;
        optionsPanelConstraints.gridx = 0;
        optionsPanelConstraints.gridy = 3;
        optionsPanelConstraints.weightx = 1.0;
        optionsPanelConstraints.weighty = 1.0;
        optionsPanelConstraints.gridheight = 1;
        optionsPanelConstraints.gridwidth = 2;
        optionsPanelConstraints.insets = new Insets(5, 5, 5, 5);

        optionsPanel.setBorder(optionsBorder);
        this.add(optionsPanel, optionsPanelConstraints);

        GridBagConstraints strategyLabelConstraints = new GridBagConstraints();
        strategyLabelConstraints.anchor = GridBagConstraints.WEST;
        strategyLabelConstraints.fill = GridBagConstraints.BOTH;
        strategyLabelConstraints.gridx = 0;
        strategyLabelConstraints.gridy = 0;
        strategyLabelConstraints.weightx = 1.0;
        strategyLabelConstraints.weighty = 1.0;
        strategyLabelConstraints.gridheight = 1;
        strategyLabelConstraints.gridwidth = 1;
        strategyLabelConstraints.insets = new Insets(5, 5, 0, 5);

        final JLabel strategyLabel = new JLabel("Strategy", SwingConstants.RIGHT);
        optionsPanel.add(strategyLabel, strategyLabelConstraints);

        GridBagConstraints strategyComboBoxConstraints = new GridBagConstraints();
        strategyComboBoxConstraints.anchor = GridBagConstraints.WEST;
        strategyComboBoxConstraints.fill = GridBagConstraints.VERTICAL;
        strategyComboBoxConstraints.gridx = 1;
        strategyComboBoxConstraints.gridy = 0;
        strategyComboBoxConstraints.weightx = 1.0;
        strategyComboBoxConstraints.weighty = 1.0;
        strategyComboBoxConstraints.gridheight = 1;
        strategyComboBoxConstraints.gridwidth = 1;
        strategyComboBoxConstraints.insets = new Insets(5, 5, 0, 5);

        String[] strategyLabels = { "Source", "Target", "Both" };
        this.strategyComboBox = new JComboBox<String>(strategyLabels);
        // NOTE: We should have better validation of the data state for these controls.
        // We could run into problems as the application versions over time.
        this.strategyComboBox.setSelectedIndex(this.definition.getMergeStrategy().ordinal());
        this.strategyComboBox.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                validateFormState();
            }
        });
        optionsPanel.add(this.strategyComboBox, strategyComboBoxConstraints);

        GridBagConstraints autoMergeCheckBoxConstraints = new GridBagConstraints();
        autoMergeCheckBoxConstraints.gridx = 0;
        autoMergeCheckBoxConstraints.gridy = 1;
        autoMergeCheckBoxConstraints.weightx = 1.0;
        autoMergeCheckBoxConstraints.weighty = 1.0;
        autoMergeCheckBoxConstraints.gridheight = 1;
        autoMergeCheckBoxConstraints.gridwidth = 2;
        autoMergeCheckBoxConstraints.insets = new Insets(2, 5, 5, 5);

        this.autoMergeCheckBox.setHorizontalTextPosition(SwingConstants.LEFT);
        this.autoMergeCheckBox.setSelected(this.definition.getAutoResolveConflicts());
        this.autoMergeCheckBox.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                validateFormState();
            }
        });
        optionsPanel.add(this.autoMergeCheckBox, autoMergeCheckBoxConstraints);

        GridBagConstraints includeNonCreationTimestampsCheckBoxConstraints = new GridBagConstraints();
        includeNonCreationTimestampsCheckBoxConstraints.gridx = 0;
        includeNonCreationTimestampsCheckBoxConstraints.gridy = 2;
        includeNonCreationTimestampsCheckBoxConstraints.weightx = 1.0;
        includeNonCreationTimestampsCheckBoxConstraints.weighty = 1.0;
        includeNonCreationTimestampsCheckBoxConstraints.gridheight = 1;
        includeNonCreationTimestampsCheckBoxConstraints.gridwidth = 2;
        includeNonCreationTimestampsCheckBoxConstraints.insets = new Insets(2, 5, 5, 5);

        this.includeNonCreationTimestampCheckBox.setHorizontalTextPosition(SwingConstants.LEFT);
        this.includeNonCreationTimestampCheckBox.setSelected(this.definition.getIncludeNonCreationTimestamps());
        this.includeNonCreationTimestampCheckBox.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                validateFormState();
            }
        });
        optionsPanel.add(this.includeNonCreationTimestampCheckBox,
                includeNonCreationTimestampsCheckBoxConstraints);

        GridBagConstraints advancedAttributesCheckBoxConstraints = new GridBagConstraints();
        advancedAttributesCheckBoxConstraints.gridx = 0;
        advancedAttributesCheckBoxConstraints.gridy = 3;
        advancedAttributesCheckBoxConstraints.weightx = 1.0;
        advancedAttributesCheckBoxConstraints.weighty = 1.0;
        advancedAttributesCheckBoxConstraints.gridheight = 1;
        advancedAttributesCheckBoxConstraints.gridwidth = 2;
        advancedAttributesCheckBoxConstraints.insets = new Insets(2, 5, 5, 5);

        this.includeAdvancedAttributesCheckBox.setHorizontalTextPosition(SwingConstants.LEFT);
        this.includeAdvancedAttributesCheckBox.setSelected(this.definition.getAutoResolveConflicts());
        this.includeAdvancedAttributesCheckBox.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                validateFormState();
            }
        });
        optionsPanel.add(this.includeAdvancedAttributesCheckBox, advancedAttributesCheckBoxConstraints);

        this.scanMappingsList.loadData();

        if (this.getMode() == AssuranceDialogMode.EDIT) {
            this.validateFormState();
        }

        this.initialized = true;
    }
}

From source file:com.game.ui.views.CharacterEditor.java

/**
 * This method draws up the gui on the panel.
 *///from w  ww.ja  v a 2  s. c  o m
public void doGui() {
    JPanel outerPane = new JPanel();
    outerPane.setLayout(new GridBagLayout());
    //        setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel noteLbl = new JLabel(lblContent);
    noteLbl.setAlignmentX(0);
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.NONE;
    c.insets = new Insets(5, 5, 5, 5);
    c.gridwidth = 4;
    c.gridy = 0;
    c.gridx = 0;
    outerPane.add(noteLbl, c);
    System.out.println(c.gridy);
    c.gridy++;
    System.out.println(c.gridy);
    c.gridx = 0;
    c.gridwidth = 1;
    comboBox = new JComboBox(model);
    comboBox.setSelectedIndex(-1);
    comboBox.setMaximumSize(new Dimension(100, 30));
    comboBox.setAlignmentX(0);
    comboBox.setActionCommand("dropDown");
    comboBox.addActionListener(this);
    outerPane.add(comboBox, c);
    c.gridy++;
    JLabel nameLbl = new JLabel("Name : ");
    outerPane.add(nameLbl, c);
    c.gridx++;
    name = new JTextField();
    name.setColumns(20);
    outerPane.add(name, c);
    c.gridx = 0;
    c.gridy++;
    JLabel imageLbl = new JLabel("Image Path : ");
    outerPane.add(imageLbl, c);
    c.gridx++;
    imgPath = new JTextField();
    imgPath.setColumns(20);
    outerPane.add(imgPath, c);
    c.gridx = 0;
    c.gridy++;
    JLabel hitPtsLbl = new JLabel("Hit Points : ");
    outerPane.add(hitPtsLbl, c);
    c.gridx++;
    hitPoints = new JTextField();
    hitPoints.setColumns(20);
    outerPane.add(hitPoints, c);
    c.gridx = 0;
    c.gridy++;
    JLabel lvl = new JLabel("Level : ");
    outerPane.add(lvl, c);
    c.gridx++;
    level = new JTextField();
    level.setColumns(20);
    /*if(!isEnemy){
    level.setText("1");
    level.setEnabled(false);
    }*/
    outerPane.add(level, c);
    c.gridx = 0;
    c.gridy++;
    JLabel mlWpn = new JLabel("Melee Weapon : ");
    outerPane.add(mlWpn, c);
    c.gridx++;
    model = new DefaultComboBoxModel();
    LinkedList<String> meleeWpnList = new LinkedList<String>();
    LinkedList<String> rngdWpnList = new LinkedList<String>();
    for (Item item : GameBean.weaponDetails) {
        Weapon wpn = (Weapon) item;
        if (wpn.getWeaponType().equalsIgnoreCase(Configuration.weaponTypes[0])) {
            meleeWpnList.add(wpn.getName());
        } else {
            rngdWpnList.add(wpn.getName());
        }
        weaponMap.put(wpn.getName(), wpn);
    }
    meleeWeapon = new JComboBox(new DefaultComboBoxModel(meleeWpnList.toArray()));
    meleeWeapon.setSelectedIndex(-1);
    meleeWeapon.setMaximumSize(new Dimension(100, 30));
    outerPane.add(meleeWeapon, c);
    c.gridx++;
    JLabel rngdWpn = new JLabel("Ranged Weapon : ");
    outerPane.add(rngdWpn, c);
    c.gridx++;
    rangedWeapon = new JComboBox(new DefaultComboBoxModel(rngdWpnList.toArray()));
    rangedWeapon.setSelectedIndex(-1);
    rangedWeapon.setMaximumSize(new Dimension(100, 30));
    outerPane.add(rangedWeapon, c);
    c.gridy++;
    c.gridx = 0;
    JLabel armourLbl = new JLabel("Armour : ");
    outerPane.add(armourLbl, c);
    c.gridx++;
    LinkedList<String> armourList = new LinkedList<String>();
    LinkedList<String> shildList = new LinkedList<String>();
    for (Item item : GameBean.armourDetails) {
        Armour temp = (Armour) item;
        if (temp.getArmourType() != null) {
            if (temp.getArmourType().equalsIgnoreCase(Configuration.armourTypes[1])) {
                armourList.add(temp.getName());
            } else {
                shildList.add(temp.getName());
            }
        } else {
            armourList.add(temp.getName());
            //            else if(temp.getArmourType().equalsIgnoreCase(Configuration.armourTypes[2]))
            shildList.add(temp.getName());
        }
        armorMap.put(temp.getName(), temp);
    }
    armour = new JComboBox(new DefaultComboBoxModel(armourList.toArray()));
    armour.setSelectedIndex(-1);
    armour.setMaximumSize(new Dimension(100, 30));
    outerPane.add(armour, c);
    c.gridx++;
    JLabel shieldLbl = new JLabel("Shield : ");
    outerPane.add(shieldLbl, c);
    c.gridx++;
    shield = new JComboBox(new DefaultComboBoxModel(shildList.toArray()));
    shield.setSelectedIndex(-1);
    shield.setMaximumSize(new Dimension(100, 30));
    outerPane.add(shield, c);
    ta = new JTextArea(10, 50);
    ta.setRows(40);
    ta.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
    JScrollPane scrollPane = new JScrollPane(ta);
    scrollPane.setPreferredSize(new Dimension(600, 250));
    c.gridx = 0;
    c.gridy++;
    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = 4;
    c.gridheight = 4;
    c.weightx = .5;
    c.weighty = 1;
    outerPane.add(scrollPane, c);
    c.gridy += 4;
    c.gridx = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    c.gridheight = 1;
    c.gridwidth = 1;
    JButton generate = new JButton("Generate");
    JButton submit = new JButton("Submit");
    outerPane.add(generate, c);
    submit.addActionListener(this);
    generate.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            ta.setText("");
            HashSet<Integer> set = new HashSet<Integer>();
            int strength = getUniqueVal(set);
            int constitution = getUniqueVal(set);
            int dext = getUniqueVal(set);
            int intel = getUniqueVal(set);
            int charisma = getUniqueVal(set);
            int wisdom = getUniqueVal(set);
            if (character == null) {
                builder = new CharacterBuilder(isEnemy);
            } else {
                builder = new CharacterBuilder(character);
            }
            builder.setStrength(strength);
            builder.setConstitution(constitution);
            builder.setDexterity(dext);
            builder.setIntelligence(intel);
            builder.setCharisma(charisma);
            builder.setWisdom(wisdom);
            int strModifier = GameUtils.calculateAbilityModifier(strength);
            int conModifier = GameUtils.calculateAbilityModifier(constitution);
            int dexModifier = GameUtils.calculateAbilityModifier(dext);
            int wisModifier = GameUtils.calculateAbilityModifier(wisdom);
            int intModifier = GameUtils.calculateAbilityModifier(intel);
            int chaModifier = GameUtils.calculateAbilityModifier(charisma);
            builder.setStrengthModifier(strModifier);
            builder.setConstitutionModifier(conModifier);
            builder.setCharismaModifier(chaModifier);
            builder.setWisdomModifier(wisModifier);
            builder.setIntelligenceModifier(intModifier);
            builder.setDexterityModifier(dexModifier);
            String type = null;
            if (constitution < strength && constitution > dext) {
                type = "Bully";
                builder.setType("Bully");
            } else if (dext > constitution && constitution > strength) {
                builder.setType("Nimble");
                type = "Nimble";
            } else {
                builder.setType("Tank");
                type = "Tank";
            }
            ta.append("Strength : " + strength);
            ta.append("\nDexterity : " + dexModifier);
            ta.append("\nConstitution : " + constitution);
            ta.append("\nIntelligence : " + intel);
            ta.append("\nCharisma: " + charisma);
            ta.append("\nWisdom : " + wisdom);
            ta.append("\nType :" + type);
            ta.append("\nStrength Modifier :" + strModifier);
            ta.append("\nConstitution Modifier :" + conModifier);
            ta.append("\nDexterity Modifier :" + dexModifier);
            generated = true;
            if (character != null) {
                character = builder.build();
            }
        }
    });
    c.gridx++;
    outerPane.add(submit, c);
    validationMess = new JLabel();
    validationMess.setForeground(Color.red);
    //        validationMess.setVisible(false);
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 4;
    outerPane.add(validationMess, c);
    JScrollPane outerScrollPane = new JScrollPane(outerPane);
    setLayout(new BorderLayout());
    add(outerScrollPane, BorderLayout.CENTER);
}

From source file:com.rapidminer.gui.new_plotter.gui.dialog.AddParallelLineDialog.java

/**
 * Setup the GUI.//  w w w.  j a va2 s.c o  m
 */
private void setupGUI() {
    JPanel mainPanel = new JPanel();
    this.setContentPane(mainPanel);

    // start layout
    mainPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 2, 5);
    horizontalLineRadiobutton = new JRadioButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.horizontal.label"));
    horizontalLineRadiobutton.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.horizontal.tip"));
    horizontalLineRadiobutton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setHorizontalLineSelected();
        }
    });
    horizontalLineRadiobutton.setSelected(true);
    this.add(horizontalLineRadiobutton, gbc);

    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.EAST;
    verticalLineRadiobutton = new JRadioButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.vertical.label"));
    verticalLineRadiobutton
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.vertical.tip"));
    verticalLineRadiobutton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setVerticalLineSelected();
        }
    });
    this.add(verticalLineRadiobutton, gbc);

    ButtonGroup group = new ButtonGroup();
    group.add(horizontalLineRadiobutton);
    group.add(verticalLineRadiobutton);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1;
    gbc.gridwidth = 2;
    gbc.anchor = GridBagConstraints.CENTER;
    rangeAxisSelectionCombobox = new JComboBox();
    rangeAxisSelectionCombobox.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.range_axis_combobox.tip"));
    rangeAxisSelectionCombobox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateYFieldValue();
        }
    });
    this.add(rangeAxisSelectionCombobox, gbc);

    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 2, 5);
    JLabel xLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.width.label"));
    this.add(xLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.insets = new Insets(2, 5, 2, 5);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    xField = new JTextField();
    xField.setText(String.valueOf(x));
    xField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyYInput(input);
        }
    });
    xField.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.width.tip"));
    xField.setEnabled(false);
    this.add(xField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.NONE;
    JLabel yLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.height.label"));
    this.add(yLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    yField = new JTextField();
    yField.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.height.tip"));
    yField.setText(String.valueOf(y));
    yField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyXInput(input);
        }
    });
    this.add(yField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets = new Insets(10, 5, 0, 5);
    modifyLineButton = new JButton();
    modifyLineButton.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.modify_line.tip"));
    modifyLineButton.setIcon(SwingTools.createIcon(
            "16/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.modify_line.icon")));
    modifyLineButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            modifyLine();
        }
    });
    this.add(modifyLineButton, gbc);

    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.gridwidth = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(15, 5, 5, 5);
    this.add(new JSeparator(), gbc);

    gbc.gridx = 0;
    gbc.gridy = 6;
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 5, 5);
    okButton = new JButton(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.label"));
    okButton.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.tip"));
    okButton.setIcon(SwingTools
            .createIcon("24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.icon")));
    okButton.setMnemonic(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.mne").toCharArray()[0]);
    okButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean successful = addSpecifiedLine();
            // don't dispose dialog if not successful
            if (!successful) {
                return;
            }

            AddParallelLineDialog.this.dispose();
        }
    });
    okButton.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                okButton.doClick();
            }
        }
    });
    this.add(okButton, gbc);

    gbc.gridx = 1;
    gbc.gridy = 6;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    cancelButton = new JButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.label"));
    cancelButton
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.tip"));
    cancelButton.setIcon(SwingTools.createIcon(
            "24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.icon")));
    cancelButton.setMnemonic(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.mne").toCharArray()[0]);
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // cancel requested, close dialog
            AddParallelLineDialog.this.dispose();
        }
    });
    this.add(cancelButton, gbc);

    // misc settings
    this.setMinimumSize(new Dimension(300, 250));
    // center dialog
    this.setLocationRelativeTo(null);
    this.setTitle(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.title.label"));
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.setModal(true);

    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowActivated(WindowEvent e) {
            okButton.requestFocusInWindow();
        }
    });
}

From source file:at.tuwien.ifs.somtoolbox.apps.viewer.controls.ClusteringControl.java

public ClusteringControl(String title, CommonSOMViewerStateData state, SOMPane mappane) {
    super(title, state, new GridBagLayout());
    this.mapPane = mappane;
    init();//from  w ww  .jav  a  2 s .  c o  m
    updateControlDisplay();
}