Example usage for java.awt GridBagConstraints BOTH

List of usage examples for java.awt GridBagConstraints BOTH

Introduction

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

Prototype

int BOTH

To view the source code for java.awt GridBagConstraints BOTH.

Click Source Link

Document

Resize the component both horizontally and vertically.

Usage

From source file:com.sec.ose.osi.ui.dialog.setting.JPanProjectAnalysisSetting.java

/**
 * This method initializes this//from w  w w  .j  av  a  2s  .c om
 * 
 * @return void
 */
private void initialize() {
    GridBagConstraints gridBagConstraints71 = new GridBagConstraints();
    gridBagConstraints71.anchor = GridBagConstraints.NORTHWEST;
    gridBagConstraints71.weightx = 1.0;
    gridBagConstraints71.weighty = 1.0;
    gridBagConstraints71.insets = new Insets(0, 0, 0, 0);
    gridBagConstraints71.fill = GridBagConstraints.BOTH;
    GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
    gridBagConstraints14.gridx = -1;
    gridBagConstraints14.anchor = GridBagConstraints.NORTH;
    gridBagConstraints14.insets = new Insets(10, 10, 0, 10);
    gridBagConstraints14.gridy = -1;
    this.setLayout(new GridBagLayout());
    this.add(getJIntMainPanel(), gridBagConstraints71);
    this.add(getJPanel(), gridBagConstraints14);
}

From source file:DownloadDialog.java

/********************************************************************
 * Constructor: DownloadDialog//w w w  .  jav 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:at.ac.tuwien.ibk.biqini.pep.gui.PEPGUI.java

public PEPGUI(String arg0, Vector<IBandwidthTracer> qosRules) {
    super(arg0);// w  ww  .  j  av  a  2 s .  c om

    // initiate all collections
    tsc = new TimeSeriesCollection[MAXCHARTS];
    charts = new JFreeChart[MAXCHARTS];
    positions = new Vector<Integer>();
    chartPosition = new Hashtable<String, Integer>();
    for (int i = 0; i < MAXCHARTS; i++)
        positions.add(i);
    allSessions = new Hashtable<String, IBandwidthTracer>();

    // fill the BandwidthGenerator with the ongoing QoSRules
    bandwidthGenerator = new BandwidthGenerator();
    Enumeration<IBandwidthTracer> enbandwidth = qosRules.elements();
    while (enbandwidth.hasMoreElements()) {
        IBandwidthTracer b = enbandwidth.nextElement();
        allSessions.put(b.getName(), b);
        bandwidthGenerator.add(b);
    }

    gridBagLayout = new GridBagLayout();

    //insert the list with all QoS rules
    GridBagConstraints c = new GridBagConstraints();
    c.weighty = 9;
    c.weightx = 2.0;
    c.gridheight = MAXCHARTS;
    c.fill = GridBagConstraints.BOTH;
    content = new JPanel(gridBagLayout);
    qoSRuleList = new JList(allSessions.keySet().toArray());
    qoSRuleList.setPreferredSize(new java.awt.Dimension(200, 600));
    qoSRuleList.setBorder(BorderFactory.createRaisedBevelBorder());

    // set a MouseListner on the List
    MouseListener mouseListener = new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {

            if (e.getButton() == MouseEvent.BUTTON1) {
                int index = qoSRuleList.locationToIndex(e.getPoint());
                addStream(allSessions.get(allSessions.keySet().toArray()[index]));
            }
            if (e.getButton() == MouseEvent.BUTTON3) {
                int index = qoSRuleList.locationToIndex(e.getPoint());
                removeStream(allSessions.get(allSessions.keySet().toArray()[index]));
            }
        }
    };
    qoSRuleList.addMouseListener(mouseListener);

    // place all parts at the content pane
    gridBagLayout.setConstraints(qoSRuleList, c);
    content.add(qoSRuleList);
    setContentPane(content);
    content.setSize(1000, 800);

    //create all GUI aspects for our Charts
    insertAllCharts();

    //Start the thread that fills up our time series
    periodicBandwidthReader = new Thread(bandwidthGenerator);
    periodicBandwidthReader.setName("data-collector");
    periodicBandwidthReader.start();
}

From source file:net.datacrow.console.windows.charts.ChartPanel.java

private void install() {
    add(chartPanel, Layout.getGBC(0, 1, 2, 1, 40.0, 40.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5), 0, 0));

    setEnabled(true);//from   w w  w.  j a va 2s .  c om
    revalidate();
}

From source file:logdruid.ui.mainpanel.EventRecordingSelectorPanel.java

/**
 * Create the panel.//from w  w  w. j  av  a2  s.c  om
 */
public EventRecordingSelectorPanel(final Repository rep, Source src) {
    repository = rep;
    source = src;
    records = rep.getRecordings(EventRecording.class);
    // Collections.sort(records);
    Iterator it = records.iterator();
    while (it.hasNext()) {
        Recording record = (Recording) it.next();
        data.add(new Object[] { record.getName(), record.getRegexp(), record.getType(),
                src.isActiveRecordingOnSource(record) });
    }

    model = new logdruid.ui.mainpanel.EventRecordingSelectorPanel.MyTableModel(data, header);
    logger.info("source is " + ((source == null) ? "null" : src.getSourceName()));
    JPanel panel_1 = new JPanel();
    GridBagConstraints gbc_panel_1 = new GridBagConstraints();
    gbc_panel_1.fill = GridBagConstraints.BOTH;
    gbc_panel_1.insets = new Insets(5, 0, 5, 5);
    gbc_panel_1.gridx = 1;
    gbc_panel_1.gridy = 0;
    panel_1.setLayout(new BorderLayout(0, 0));

    table = new JTable(model);
    JScrollPane scrollPane = new JScrollPane(table);
    panel_1.add(scrollPane, BorderLayout.CENTER);

    table.setPreferredScrollableViewportSize(new Dimension(0, 150));
    table.setFillsViewportHeight(true);
    table.setAutoCreateRowSorter(true);

    // Set up column sizes.
    initColumnSizes(table);

    setLayout(new BorderLayout(0, 0));

    JSplitPane splitPane = new JSplitPane();
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    add(splitPane);
    jPanelDetail = new JPanel();
    splitPane.setBottomComponent(jPanelDetail);
    splitPane.setTopComponent(panel_1);

    GridBagConstraints gbc_jPanelDetail = new GridBagConstraints();
    gbc_jPanelDetail.insets = new Insets(0, 0, 0, 5);
    gbc_jPanelDetail.fill = GridBagConstraints.BOTH;
    gbc_jPanelDetail.gridx = 1;
    gbc_jPanelDetail.gridy = 3;
    jPanelDetail.setLayout(new BorderLayout(0, 0));
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            int selectedRow = ((table.getSelectedRow() != -1)
                    ? table.convertRowIndexToModel(table.getSelectedRow())
                    : -1);
            logger.info("ListSelectionListener - selectedRow: " + selectedRow);
            if (selectedRow >= 0) {
                if (jPanelDetail != null) {
                    logger.debug("ListSelectionListener - valueChanged");
                    jPanelDetail.removeAll();
                    recEditor = getEditor(repository.getRecording(EventRecording.class, selectedRow));
                    if (recEditor != null) {
                        jPanelDetail.add(recEditor, BorderLayout.CENTER);
                    }
                    jPanelDetail.revalidate();
                }
            }
        }
    });
    if (repository.getRecordings(EventRecording.class).size() > 0) {
        recEditor = getEditor(repository.getRecording(EventRecording.class, 0));
        jPanelDetail.add(recEditor, BorderLayout.CENTER);
        table.setRowSelectionInterval(0, 0);
    }
    if (model.getRowCount() > 0) {
        table.getRowSorter().toggleSortOrder(0);
        table.setRowSelectionInterval(0, 0);
    }
}

From source file:rhinova.gui.dataentry.link.LinkDataEntryPanel.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner non-commercial license
    vSpacer5 = new JPanel(null);
    label2 = new JLabel();
    hSpacer1 = new JPanel(null);
    label1 = new JLabel();
    txtName = new JTextField();
    vSpacer4 = new JPanel(null);
    label6 = new JLabel();
    txtCap = new JTextField();
    vSpacer3 = new JPanel(null);
    label7 = new JLabel();
    txtSur = new JTextField();
    hSpacer2 = new JPanel(null);
    vSpacer2 = new JPanel(null);
    label8 = new JLabel();
    res1 = new JComboBox();
    vSpacer1 = new JPanel(null);
    label9 = new JLabel();
    res2 = new JComboBox();
    vSpacer6 = new JPanel(null);
    btnCreate = new JButton();
    hSpacer3 = new JPanel(null);

    //======== this ========
    setLayout(new GridBagLayout());
    ((GridBagLayout) getLayout()).columnWidths = new int[] { 0, 65, 145, 0, 0 };
    ((GridBagLayout) getLayout()).rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    ((GridBagLayout) getLayout()).columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 1.0E-4 };
    ((GridBagLayout) getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            0.0, 0.0, 0.0, 0.0, 1.0E-4 };
    add(vSpacer5, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

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

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

    //---- label6 ----
    label6.setText("capacity");
    add(label6, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtCap, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer3, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label7 ----
    label7.setText("survival rate");
    add(label7, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtSur, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(hSpacer2, new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0));
    add(vSpacer2, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label8 ----
    label8.setText("reserve1");
    add(label8, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(res1, new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer1, new GridBagConstraints(1, 9, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label9 ----
    label9.setText("reserve2");
    add(label9, new GridBagConstraints(1, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(res2, new GridBagConstraints(2, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer6, new GridBagConstraints(1, 11, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- btnCreate ----
    btnCreate.setText("Create Link");
    btnCreate.addActionListener(new ActionListener() {
        @Override/*from ww  w .  j  a  v  a2s  .  c om*/
        public void actionPerformed(ActionEvent e) {
            btnCreateActionPerformed(e);
        }
    });
    add(btnCreate, new GridBagConstraints(2, 12, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(hSpacer3, new GridBagConstraints(2, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:captureplugin.drivers.DeviceCreatorDialog.java

/**
 * Create the GUI//w  w  w. j  a v  a2s  .c o m
 */
private void createGUI() {
    UiUtilities.registerForClosing(this);

    DriverIf[] drivers = DriverFactory.getInstance().getDrivers();

    mDriverCombo = new JComboBox(drivers);
    mDriverCombo.setRenderer(new DefaultListCellRenderer() {
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {

            if (value instanceof DriverIf) {
                value = ((DriverIf) value).getDriverName();
            }

            return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        }
    });

    JPanel panel = (JPanel) getContentPane();

    panel.setLayout(new GridBagLayout());

    GridBagConstraints label = new GridBagConstraints();

    label.insets = new Insets(5, 5, 5, 5);
    label.anchor = GridBagConstraints.NORTHWEST;

    GridBagConstraints input = new GridBagConstraints();

    input.fill = GridBagConstraints.HORIZONTAL;
    input.weightx = 1.0;
    input.gridwidth = GridBagConstraints.REMAINDER;
    input.insets = new Insets(5, 5, 5, 5);

    panel.add(new JLabel(mLocalizer.msg("Name", "Name")), label);

    mName = new JTextField();
    panel.add(mName, input);

    panel.add(new JLabel(mLocalizer.msg("Driver", "Driver")), label);
    panel.add(mDriverCombo, input);

    mDesc = UiUtilities.createHtmlHelpTextArea("");
    mDesc.setEditable(false);

    panel.add(new JLabel(mLocalizer.msg("Description", "Description")), input);

    GridBagConstraints descC = new GridBagConstraints();
    descC.weightx = 1.0;
    descC.weighty = 1.0;
    descC.fill = GridBagConstraints.BOTH;
    descC.gridwidth = GridBagConstraints.REMAINDER;
    descC.insets = new Insets(5, 5, 5, 5);

    panel.add(new JScrollPane(mDesc, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER), descC);

    final Font font = new JLabel().getFont();

    String desc = ((DriverIf) mDriverCombo.getSelectedItem()).getDriverDesc();
    desc = "<html><div style=\"color:#000000;font-family:" + font.getName() + "; font-size:" + font.getSize()
            + ";\">" + desc + "</div></html>";
    mDesc.setText(desc);
    mDesc.setFont(font);

    mDriverCombo.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            String description = ((DriverIf) mDriverCombo.getSelectedItem()).getDriverDesc();
            description = "<html><div style=\"color:#000000;font-family:" + font.getName() + "; font-size:"
                    + font.getSize() + ";\">" + description + "</div></html>";
            mDesc.setText(description);
            mDesc.setFont(font);
        }

    });

    final JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK));
    ok.setEnabled(false);
    final JButton cancel = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL));
    ok.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            okPressed();
        }
    });

    cancel.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            setVisible(false);
        }
    });

    mName.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void removeUpdate(DocumentEvent e) {
            updateButtons();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            updateButtons();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            updateButtons();
        }

        private void updateButtons() {
            ok.setEnabled(!mName.getText().trim().isEmpty());
        }
    });

    ButtonBarBuilder2 builder = new ButtonBarBuilder2();
    builder.addGlue();
    builder.addButton(new JButton[] { ok, cancel });

    getRootPane().setDefaultButton(ok);

    input.insets = new Insets(5, 5, 5, 5);

    panel.add(builder.getPanel(), input);

    setSize(400, 300);

}

From source file:de.codesourcery.jasm16.ide.ui.views.HexDumpView.java

protected JPanel createPanel() {
    textArea.setEditable(false);/* w  w w  . j  a v  a  2 s. c om*/
    setColors(textArea);
    textArea.setFont(getMonospacedFont());
    textArea.setEditable(false);

    // dump panel
    final JPanel dumpPanel = new JPanel();
    setColors(dumpPanel);
    dumpPanel.setLayout(new GridBagLayout());
    GridBagConstraints cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH);
    dumpPanel.add(textArea, cnstrs);

    // toolbar panel
    final JPanel toolbarPanel = new JPanel();
    setColors(toolbarPanel);
    toolbarPanel.setLayout(new GridBagLayout());

    cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE);
    toolbarPanel.add(new JLabel("Goto"), cnstrs);

    final JTextField gotoTextfield = new JTextField();
    gotoTextfield.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final String val = gotoTextfield.getText();
            Address adr;
            if (StringUtils.isBlank(val)) {
                gotoTextfield.setText("0000");
                adr = Address.wordAddress(0);
            } else {
                try {
                    adr = Address.wordAddress(Misc.parseHexString(val));
                } catch (NumberFormatException e1) {
                    gotoTextfield.setText("0000");
                    adr = Address.wordAddress(0);
                }
            }
            dumpStartAddress = adr;
            refreshDisplay();
        }
    });

    cnstrs = constraints(0, 1, true, true, GridBagConstraints.HORIZONTAL);
    toolbarPanel.add(gotoTextfield, cnstrs);

    // create result panel
    final JPanel result = new JPanel();
    setColors(result);
    result.setLayout(new GridBagLayout());
    cnstrs = constraints(0, 0, false, true, GridBagConstraints.BOTH);
    result.add(dumpPanel, cnstrs);
    cnstrs = constraints(1, 0, true, true, GridBagConstraints.VERTICAL);
    result.add(toolbarPanel, cnstrs);

    textArea.addKeyListener(new PagingKeyAdapter() {

        @Override
        protected void onePageUp() {
            HexDumpView.this.onePageUp();
        }

        @Override
        protected void onePageDown() {
            HexDumpView.this.onePageDown();
        }

        @Override
        protected void oneLineUp() {
            HexDumpView.this.oneLineUp();
        }

        @Override
        protected void oneLineDown() {
            HexDumpView.this.oneLineDown();
        }
    });

    result.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            refreshDisplay();
        }
    });

    return result;
}

From source file:analysers.FilterValidatedDialog.java

/**
 * Create the dialog./* w ww  .  j a v  a2 s.  c o m*/
 */
public FilterValidatedDialog() {
    setTitle("Validated Lineages: Export Filter");
    setBounds(100, 100, 632, 348);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    GridBagLayout gbl_contentPanel = new GridBagLayout();
    gbl_contentPanel.columnWidths = new int[] { 160, 440, 0 };
    gbl_contentPanel.rowHeights = new int[] { 1, 28, 28, 28, 0, 0 };
    gbl_contentPanel.columnWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE };
    gbl_contentPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE };
    contentPanel.setLayout(gbl_contentPanel);
    {
        JLabel lblCriterion = new JLabel("Lineage Criterion");
        lblCriterion.setFont(new Font("Lucida Grande", Font.BOLD, 13));
        GridBagConstraints gbc_lblCriterion = new GridBagConstraints();
        gbc_lblCriterion.insets = new Insets(0, 0, 5, 5);
        gbc_lblCriterion.gridx = 0;
        gbc_lblCriterion.gridy = 0;
        contentPanel.add(lblCriterion, gbc_lblCriterion);
    }
    {
        JLabel lblValue = new JLabel("Value");
        lblValue.setFont(new Font("Lucida Grande", Font.BOLD, 13));
        GridBagConstraints gbc_lblValue = new GridBagConstraints();
        gbc_lblValue.insets = new Insets(0, 0, 5, 0);
        gbc_lblValue.gridx = 1;
        gbc_lblValue.gridy = 0;
        contentPanel.add(lblValue, gbc_lblValue);
    }
    {
        lblMinLineageLength = new JLabel("Min. Length (frames)");
        GridBagConstraints gbc_lblMinLineageLength = new GridBagConstraints();
        gbc_lblMinLineageLength.fill = GridBagConstraints.BOTH;
        gbc_lblMinLineageLength.insets = new Insets(0, 0, 5, 5);
        gbc_lblMinLineageLength.gridx = 0;
        gbc_lblMinLineageLength.gridy = 1;
        contentPanel.add(lblMinLineageLength, gbc_lblMinLineageLength);
    }
    {
        minLinLen = new JTextField();
        GridBagConstraints gbc_minLinLen = new GridBagConstraints();
        gbc_minLinLen.anchor = GridBagConstraints.NORTH;
        gbc_minLinLen.fill = GridBagConstraints.HORIZONTAL;
        gbc_minLinLen.insets = new Insets(0, 0, 5, 0);
        gbc_minLinLen.gridx = 1;
        gbc_minLinLen.gridy = 1;
        contentPanel.add(minLinLen, gbc_minLinLen);
        minLinLen.setText("1");
        minLinLen.setColumns(3);
    }
    {
        lblStartFrameOf = new JLabel("Max. Start Frame");
        GridBagConstraints gbc_lblStartFrameOf = new GridBagConstraints();
        gbc_lblStartFrameOf.fill = GridBagConstraints.HORIZONTAL;
        gbc_lblStartFrameOf.insets = new Insets(0, 0, 5, 5);
        gbc_lblStartFrameOf.gridx = 0;
        gbc_lblStartFrameOf.gridy = 2;
        contentPanel.add(lblStartFrameOf, gbc_lblStartFrameOf);
    }
    {
        startLin = new JTextField();
        GridBagConstraints gbc_startLin = new GridBagConstraints();
        gbc_startLin.insets = new Insets(0, 0, 5, 0);
        gbc_startLin.fill = GridBagConstraints.HORIZONTAL;
        gbc_startLin.gridx = 1;
        gbc_startLin.gridy = 2;
        contentPanel.add(startLin, gbc_startLin);
        startLin.setText("-1");
        startLin.setColumns(3);
    }
    {
        JButton btnPreview = new JButton("Preview");
        btnPreview.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                preview.setText(makePreview());
            }
        });
        GridBagConstraints gbc_btnPreview = new GridBagConstraints();
        gbc_btnPreview.insets = new Insets(0, 0, 5, 5);
        gbc_btnPreview.gridx = 0;
        gbc_btnPreview.gridy = 3;
        contentPanel.add(btnPreview, gbc_btnPreview);
    }
    {
        JScrollPane scrollPane = new JScrollPane();
        GridBagConstraints gbc_scrollPane = new GridBagConstraints();
        gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
        gbc_scrollPane.fill = GridBagConstraints.BOTH;
        gbc_scrollPane.gridx = 1;
        gbc_scrollPane.gridy = 3;
        contentPanel.add(scrollPane, gbc_scrollPane);
        {
            preview = new JTextArea();
            scrollPane.setViewportView(preview);
            preview.setEditable(false);
            preview.setColumns(10);
            preview.setTabSize(4);
        }
    }
    {
        JLabel lblOptions = new JLabel("Options");
        GridBagConstraints gbc_lblOptions = new GridBagConstraints();
        gbc_lblOptions.insets = new Insets(0, 0, 0, 5);
        gbc_lblOptions.gridx = 0;
        gbc_lblOptions.gridy = 4;
        contentPanel.add(lblOptions, gbc_lblOptions);
    }
    {
        JPanel panel = new JPanel();
        GridBagConstraints gbc_panel = new GridBagConstraints();
        gbc_panel.anchor = GridBagConstraints.NORTH;
        gbc_panel.fill = GridBagConstraints.HORIZONTAL;
        gbc_panel.gridx = 1;
        gbc_panel.gridy = 4;
        contentPanel.add(panel, gbc_panel);
        GridBagLayout gbl_panel = new GridBagLayout();
        gbl_panel.columnWidths = new int[] { 69, 169, 162, 0 };
        gbl_panel.rowHeights = new int[] { 23, 23, 0 };
        gbl_panel.columnWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE };
        gbl_panel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
        panel.setLayout(gbl_panel);
        {
            rdbtnExportMeanIntensity = new JRadioButton("Export Mean Intensity");
            rdbtnExportMeanIntensity.setSelected(true);
            buttonGroup.add(rdbtnExportMeanIntensity);
            GridBagConstraints gbc_rdbtnExportMeanIntensity = new GridBagConstraints();
            gbc_rdbtnExportMeanIntensity.anchor = GridBagConstraints.NORTHWEST;
            gbc_rdbtnExportMeanIntensity.insets = new Insets(0, 0, 5, 5);
            gbc_rdbtnExportMeanIntensity.gridx = 1;
            gbc_rdbtnExportMeanIntensity.gridy = 0;
            panel.add(rdbtnExportMeanIntensity, gbc_rdbtnExportMeanIntensity);
        }
        {
            rdbtnExportMaxIntensity = new JRadioButton("Export Max Intensity");
            buttonGroup.add(rdbtnExportMaxIntensity);
            GridBagConstraints gbc_rdbtnExportMaxIntensity = new GridBagConstraints();
            gbc_rdbtnExportMaxIntensity.anchor = GridBagConstraints.NORTHWEST;
            gbc_rdbtnExportMaxIntensity.insets = new Insets(0, 0, 5, 0);
            gbc_rdbtnExportMaxIntensity.gridx = 2;
            gbc_rdbtnExportMaxIntensity.gridy = 0;
            panel.add(rdbtnExportMaxIntensity, gbc_rdbtnExportMaxIntensity);
        }
        {
            chckbxExportPositions = new JCheckBox("Export Cell Positions and Areas in CSV");
            GridBagConstraints gbc_chckbxExportPositions = new GridBagConstraints();
            gbc_chckbxExportPositions.anchor = GridBagConstraints.NORTH;
            gbc_chckbxExportPositions.gridwidth = 2;
            gbc_chckbxExportPositions.gridx = 1;
            gbc_chckbxExportPositions.gridy = 1;
            panel.add(chckbxExportPositions, gbc_chckbxExportPositions);
        }
    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton okButton = new JButton("OK");
            okButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg0) {
                    if (validateFields()) {
                        Prefs.set("TrackApp.FilterValidatedDialog.startLin", valStartLin);
                        Prefs.set("TrackApp.FilterValidatedDialog.minLinLen", valMinLinLen);
                        Prefs.set("TrackApp.FilterValidatedDialog.exportMean", doExportMean);
                        Prefs.set("TrackApp.FilterValidatedDialog.exportPositions", doExportPositions);
                        Prefs.savePreferences();
                        dispose();
                    }
                }
            });
            okButton.setActionCommand("OK");
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    dispose();
                }
            });
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }
    }
}

From source file:org.n52.oxf.ui.swing.ReducedChartDialog.java

/**
 * initializes (or updates) the OXFChartPanel.
 * // w  ww .j a  va  2  s. com
 * @param parameters
 * @param selectedfeatures
 */
private void initOXFChartPanel(OXFFeatureCollection observations, ParameterContainer paramCon) {

    // String[] foiIdArray = (String[])
    // paramCon.getParameterShellWithServiceSidedName("featureOfInterest").getSpecifiedValueArray();

    OXFChartPanel chartPanel = new OXFChartPanel();

    MyGridBagLayout mainLayout = (MyGridBagLayout) getContentPane().getLayout();

    if (getContentPane().getComponentCount() > 2) {
        getContentPane().remove(2);
    }

    mainLayout.addComponent(0, chartPanel, 0, 0, 1, 1, 100, 100, GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH, new Insets(9, 9, 9, 9));

    // TODO what's about AnimatedVisualization ??
    StaticVisualization visualization = (StaticVisualization) chartRenderer.renderChart(observations, paramCon,
            chartWidth, chartHeight);

    chartPanel.setChartImage(visualization.getRendering());

    getContentPane().validate();
}