Example usage for java.awt GridBagConstraints GridBagConstraints

List of usage examples for java.awt GridBagConstraints GridBagConstraints

Introduction

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

Prototype

public GridBagConstraints() 

Source Link

Document

Creates a GridBagConstraint object with all of its fields set to their default value.

Usage

From source file:marytts.tools.voiceimport.DatabaseImportMain.java

protected void setupGUI() {
    // A scroll pane containing one labelled checkbox per component,
    // and a "run selected components" button below.
    GridBagLayout gridBagLayout = new GridBagLayout();
    GridBagConstraints gridC = new GridBagConstraints();
    getContentPane().setLayout(gridBagLayout);

    JPanel checkboxPane = new JPanel();
    checkboxPane.setLayout(new BoxLayout(checkboxPane, BoxLayout.Y_AXIS));
    //checkboxPane.setPreferredSize(new Dimension(300, 300));
    int compIndex = 0;
    for (int j = 0; j < groups2Comps.length; j++) {
        String[] nextGroup = groups2Comps[j];
        JPanel groupPane = new JPanel();
        groupPane.setLayout(new BoxLayout(groupPane, BoxLayout.Y_AXIS));
        groupPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(nextGroup[0]),
                BorderFactory.createEmptyBorder(1, 1, 1, 1)));
        for (int i = 1; i < nextGroup.length; i++) {
            JButton configButton = new JButton();
            Icon configIcon = new ImageIcon(DatabaseImportMain.class.getResource("configure.png"), "Configure");
            configButton.setIcon(configIcon);
            configButton.setPreferredSize(new Dimension(configIcon.getIconWidth(), configIcon.getIconHeight()));
            configButton.addActionListener(new ConfigButtonActionListener(nextGroup[i]));
            configButton.setBorderPainted(false);
            //System.out.println("Adding checkbox for "+components[i].getClass().getName());
            checkboxes[compIndex] = new JCheckBox(nextGroup[i]);
            checkboxes[compIndex].setFocusable(true);
            //checkboxes[i].setPreferredSize(new Dimension(200, 30));
            JPanel line = new JPanel();
            line.setLayout(new BorderLayout(5, 0));
            line.add(configButton, BorderLayout.WEST);
            line.add(checkboxes[compIndex], BorderLayout.CENTER);
            groupPane.add(line);/*from   ww  w .  ja v  a 2s .c o  m*/
            compIndex++;
        }
        checkboxPane.add(groupPane);
    }
    gridC.gridx = 0;
    gridC.gridy = 0;
    gridC.fill = GridBagConstraints.BOTH;
    JScrollPane scrollPane = new JScrollPane(checkboxPane);
    scrollPane.setPreferredSize(new Dimension(450, 300));
    gridBagLayout.setConstraints(scrollPane, gridC);
    getContentPane().add(scrollPane);

    JButton helpButton = new JButton("Help");
    helpButton.setMnemonic(KeyEvent.VK_H);
    helpButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            displayHelpGUI();
        }
    });
    JButton settingsButton = new JButton("Settings");
    settingsButton.setMnemonic(KeyEvent.VK_S);
    settingsButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            currentComponent = "Global properties";
            displaySettingsGUI();
        }
    });
    runButton = new JButton("Run");
    runButton.setMnemonic(KeyEvent.VK_R);
    runButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            runSelectedComponents();
        }
    });

    JButton quitAndSaveButton = new JButton("Quit");
    quitAndSaveButton.setMnemonic(KeyEvent.VK_Q);
    quitAndSaveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            try {
                askIfSave();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
            System.exit(0);
        }
    });

    gridC.gridy = 1;
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout());
    //buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS));
    //runButton.setAlignmentX(JButton.LEFT_ALIGNMENT);
    buttonPanel.add(runButton);
    //helpButton.setAlignmentX(JButton.LEFT_ALIGNMENT);
    buttonPanel.add(helpButton);
    //settingsButton.setAlignmentX(JButton.LEFT_ALIGNMENT);
    buttonPanel.add(settingsButton);
    //buttonPanel.add(Box.createHorizontalGlue());
    //quitAndSaveButton.setAlignmentX(JButton.RIGHT_ALIGNMENT);
    buttonPanel.add(quitAndSaveButton);
    gridBagLayout.setConstraints(buttonPanel, gridC);
    getContentPane().add(buttonPanel);

    //getContentPane().setPreferredSize(new Dimension(300, 300));
    // End program when closing window:
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            try {
                askIfSave();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
            System.exit(0);
        }
    });
}

From source file:com.pos.spatobiz.app.view.karyawan.MenuKaryawan.java

/** This method is called from within the constructor to
 * initialize the form.//from www .j  a  va  2 s  . c  om
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    buttonDataKaryawan = new BigButton();
    buttonTambahKaryawan = new BigButton();
    buttonEditKaryawan = new BigButton();
    buttonHapusKaryawan = new BigButton();

    setLayout(new GridBagLayout());

    buttonDataKaryawan.setIcon(new ImageIcon(
            getClass().getResource("/com/pos/spatobiz/app/resource/image/karyawan/karyawan.png"))); // NOI18N
    buttonDataKaryawan.setText("Data Karyawan");
    add(buttonDataKaryawan, new GridBagConstraints());

    buttonTambahKaryawan.setIcon(
            new ImageIcon(getClass().getResource("/com/pos/spatobiz/app/resource/image/karyawan/tambah.png"))); // NOI18N
    buttonTambahKaryawan.setText("Tambah Karyawan");
    add(buttonTambahKaryawan, new GridBagConstraints());

    buttonEditKaryawan.setIcon(new ImageIcon(
            getClass().getResource("/com/pos/spatobiz/app/resource/image/karyawan/karyawan.png"))); // NOI18N
    buttonEditKaryawan.setText("Ubah Karyawan");
    add(buttonEditKaryawan, new GridBagConstraints());

    buttonHapusKaryawan.setText("Hapus Karyawan");
    add(buttonHapusKaryawan, new GridBagConstraints());
}

From source file:com.moss.appprocs.swing.ProgressMonitorPanel.java

private void addComponent(JComponent c) {
    int compNo = monitorsPanel.getComponents().length + 1;
    GridBagConstraints gc = new GridBagConstraints();
    gc.fill = GridBagConstraints.BOTH;
    gc.gridx = 0;/* w  w w . j  a  va 2 s. c  o m*/
    gc.gridy = compNo;
    gc.weightx = 1;

    monitorsPanel.add(c, gc);
    monitorsPanel.invalidate();
    monitorsPanel.getParent().validate();
    monitorsPanel.repaint();
}

From source file:Data.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.//from   w  w w .  j  av  a2  s .c  o m
 * @throws ClassNotFoundException 
 * @throws IOException 
 * @throws SQLException 
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
private void initComponents() throws ClassNotFoundException, IOException, SQLException {
    Connection dataFridge = getDbConnection();
    Statement stmt = dataFridge.createStatement();

    GridBagConstraints gridBagConstraints;

    panelPrincipal = new JPanel();
    panelCenter = new JPanel();
    panelHeader = new JPanel();
    btnHome = new JButton();
    dataList = new JComboBox();
    btnOk = new JButton();
    panelData = new JScrollPane();
    panelRealTime = new JPanel();
    tempRealTime = new JLabel();
    humRealTime = new JLabel();

    // Set unit temperature
    switch (param.tempUnitList.getSelectedIndex()) {
    case 0:
        tempUnit = "C";
        break;

    case 1:
        tempUnit = "F";
        break;

    default:
        break;
    }

    setPreferredSize(new Dimension(512, 400));
    setLayout(null);

    panelPrincipal.setPreferredSize(new Dimension(512, 400));
    panelPrincipal.setLayout(new BorderLayout());

    panelHeader.setPreferredSize(new Dimension(512, 40));
    panelHeader.setLayout(new GridBagLayout());

    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    InputStream input = classLoader.getResourceAsStream("home.png");
    Image iconeHome = ImageIO.read(input);

    btnHome.setIcon(new ImageIcon(iconeHome));
    btnHome.setPreferredSize(new Dimension(40, 40));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.anchor = GridBagConstraints.LINE_START;
    gridBagConstraints.insets = new Insets(0, 0, 0, 50);
    panelHeader.add(btnHome, gridBagConstraints);

    dataList.setModel(
            new DefaultComboBoxModel(new String[] { "Donnes en temps rel", "Graphique des temperatures" }));
    dataList.setPreferredSize(new Dimension(250, 40));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.anchor = GridBagConstraints.LINE_END;
    gridBagConstraints.insets = new Insets(0, 0, 0, 10);
    panelHeader.add(dataList, gridBagConstraints);

    btnOk.setFont(new Font("Tahoma", 0, 10)); // NOI18N
    btnOk.setText("OK");
    btnOk.setPreferredSize(new Dimension(60, 40));
    btnOk.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            btnOKActionPerformed(evt);
        }
    });
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.anchor = GridBagConstraints.LINE_START;
    gridBagConstraints.insets = new Insets(0, 5, 0, 70);
    panelHeader.add(btnOk, gridBagConstraints);

    panelPrincipal.add(panelHeader, BorderLayout.NORTH);
    panelCenter.setLayout(new BorderLayout());

    JFreeChart chart = createChart(createDataset(stmt));
    panelChart = new ChartPanel(chart);
    panelChart.setVisible(true);

    panelData = new JScrollPane(getTbleData(stmt));

    tempRealTime.setFont(new java.awt.Font("Meiryo UI", 1, 18)); // NOI18N
    humRealTime.setFont(new java.awt.Font("Meiryo UI", 1, 18)); // NOI18N

    panelRealTime.setLayout(new GridBagLayout());
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.insets = new Insets(18, 0, 0, 0);
    gridBagConstraints.anchor = GridBagConstraints.LINE_START;
    panelRealTime.add(tempRealTime, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.insets = new Insets(0, 0, 10, 0);
    gridBagConstraints.anchor = GridBagConstraints.LINE_START;
    panelRealTime.add(humRealTime, gridBagConstraints);

    panelCenter.add(panelRealTime, BorderLayout.NORTH);
    panelCenter.add(panelData, BorderLayout.CENTER);

    panelPrincipal.add(panelCenter, BorderLayout.CENTER);

    add(panelPrincipal);
    panelPrincipal.setBounds(0, 0, 512, 340);

    stmt.close();
    dataFridge.close();
}

From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectAdd.java

/**
 * This method initializes this/*from w  ww .j  a  v a  2 s .  co m*/
 * 
 * @return void
 */
private void initialize() {
    GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
    gridBagConstraints10.gridx = 1;
    gridBagConstraints10.anchor = GridBagConstraints.NORTH;
    gridBagConstraints10.insets = new Insets(10, 0, 0, 0);
    gridBagConstraints10.fill = GridBagConstraints.NONE;
    gridBagConstraints10.gridy = 0;
    GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
    gridBagConstraints9.gridx = 0;
    gridBagConstraints9.insets = new Insets(10, 10, 10, 0);
    gridBagConstraints9.fill = GridBagConstraints.BOTH;
    gridBagConstraints9.weightx = 0.1;
    gridBagConstraints9.weighty = 0.1;
    gridBagConstraints9.gridheight = 1;
    gridBagConstraints9.gridy = 0;

    JPanel p = new JPanel();
    p.setSize(600, 300);
    p.setLayout(new GridBagLayout());
    p.add(getJPanelPjtList(), gridBagConstraints9);
    p.add(getJPanelButton(), gridBagConstraints10);

    getContentPane().add(p);
}

From source file:at.ac.tuwien.ibk.biqini.pep.gui.PEPGUI.java

public PEPGUI(String arg0, Vector<IBandwidthTracer> qosRules) {
    super(arg0);//w w w.  j  a va 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:com.sec.ose.osi.ui.frm.main.report.JPanExportReport.java

private JPanel getJPanMain() {
    if (jPanMain == null) {
        jPanMain = new JPanel();

        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints1.gridx = 0;//from   w w  w.  j a v  a  2 s . c om
        gridBagConstraints1.gridy = 0;
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints2.gridx = 0;
        gridBagConstraints2.gridy = 1;
        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints3.gridx = 0;
        gridBagConstraints3.gridy = 2;
        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
        gridBagConstraints4.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints4.gridx = 0;
        gridBagConstraints4.gridy = 3;

        jPanMain.add(getJPanelForCreatorInfo(), gridBagConstraints1);
        jPanMain.add(getJPanelForDocumentExportInfo(), gridBagConstraints2);
        jPanMain.add(getJPanelForReportTypeInfo(), gridBagConstraints3);
        jPanMain.add(getJButtonPanel(), gridBagConstraints4);
    }

    return jPanMain;
}

From source file:logdruid.ui.DateEditor.java

/**
 * Create the panel.//from ww  w  .  jav a2 s .  co m
 */
public DateEditor(Repository rep) {
    repository = rep;
    model = new MyTableModel2(data, header);

    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 15, 550, 15 };
    gridBagLayout.rowHeights = new int[] { 152, 300 };
    gridBagLayout.columnWeights = new double[] { 0.0, 1.0, 0.0 };
    gridBagLayout.rowWeights = new double[] { 0.0, 1.0 };
    setLayout(gridBagLayout);

    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;
    add(panel_1, gbc_panel_1);
    panel_1.setLayout(new BorderLayout(0, 0));

    table = new JTable(model);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setBorder(UIManager.getBorder("TextPane.border"));
    table.setPreferredScrollableViewportSize(new Dimension(0, 0));
    table.setFillsViewportHeight(true);

    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            // ((table.getSelectedRow()!=-1)?table.convertRowIndexToModel(table.getSelectedRow()):-1)
            // persist repository
            // display selected row

            if (((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow())
                    : -1) >= 0) {
                /*
                 * recEditor = new RecordingEditor(repository
                 * .getRecordings().get(((table.getSelectedRow()!=-1)?table.
                 * convertRowIndexToModel(table.getSelectedRow()):-1)),
                 * repository); jPanelDetail.removeAll();
                 */
                // jPanelDetail.add(recEditor, gbc_jPanelDetail);
                DateFormat df = repository.getDateFormat(
                        ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow())
                                : -1));
                if (df != null) {
                    textFieldName.setText((String) df.getName());
                    textFieldPattern.setText((String) df.getPattern());
                    textField.setText((String) df.getDateFormat());
                }
                // jPanelDetail.revalidate();
                // jPanelDetail.repaint();
                // jPanelDetail.setVisible(true);
                // reloadTable(); those 2 ********
                // jPanelDetail.revalidate();
            }
        }
    });

    JScrollPane scrollPane = new JScrollPane(table);
    panel_1.add(scrollPane, BorderLayout.CENTER);
    // Set up column sizes.
    initColumnSizes(table);

    JPanel panel = new JPanel();
    FlowLayout flowLayout = (FlowLayout) panel.getLayout();
    flowLayout.setAlignment(FlowLayout.LEFT);
    flowLayout.setVgap(2);
    flowLayout.setHgap(2);
    panel_1.add(panel, BorderLayout.SOUTH);

    JButton btnNew = new JButton("New");
    panel.add(btnNew);
    btnNew.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            DateFormat df = new DateFormat("name", "\\w{3}\\s[0-9]{1}/[0-9]{2}/[0-9]{2}\\s\\d\\d:\\d\\d:\\d\\d",
                    "EEE. MM/dd/yy HH:mm:ss");
            repository.addDateFormat(df);
            data.add(new Object[] { df.getName(), df.getPattern(), df.getDateFormat() });
            table.repaint();
        }
    });

    JButton btnDuplicate = new JButton("Duplicate");
    btnDuplicate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow())
                    : -1) >= 0) {
                DateFormat df = repository.getDateFormat(
                        ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow())
                                : -1));
                repository.addDateFormat(df);
                reloadTable();
                // data.add(new Object[] { table.getRowCount()+1,
                // df.getName(),df.getDateFormat()});
                table.repaint();
            }
        }
    });
    panel.add(btnDuplicate);

    JButton btnDelete = new JButton("Delete");
    btnDelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int selectedRow = ((table.getSelectedRow() != -1)
                    ? table.convertRowIndexToModel(table.getSelectedRow())
                    : -1);
            if (selectedRow >= 0) {
                repository.deleteDateFormat(
                        ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow())
                                : -1));
                data.remove(
                        ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow())
                                : -1));
                reloadTable();
                table.setRowSelectionInterval(selectedRow, selectedRow);
                table.repaint();
            }
        }
    });
    panel.add(btnDelete);

    jPanelDetail = new JPanel();
    gbc_jPanelDetail = new GridBagConstraints();
    gbc_jPanelDetail.anchor = GridBagConstraints.NORTH;
    gbc_jPanelDetail.fill = GridBagConstraints.HORIZONTAL;
    gbc_jPanelDetail.gridx = 1;
    gbc_jPanelDetail.gridy = 1;
    add(jPanelDetail, gbc_jPanelDetail);
    GridBagLayout gbl_jPanelDetail = new GridBagLayout();
    gbl_jPanelDetail.columnWidths = new int[] { 169 };
    gbl_jPanelDetail.rowHeights = new int[] { 0, 0, 0, 0, 150, 0 };
    gbl_jPanelDetail.columnWeights = new double[] { 1.0, 0.0 };
    gbl_jPanelDetail.rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0, 1.0, 0.0 };
    jPanelDetail.setLayout(gbl_jPanelDetail);

    JPanel panel_2 = new JPanel();
    panel_2.setBorder(null);
    GridBagConstraints gbc_panel_2 = new GridBagConstraints();
    gbc_panel_2.gridwidth = 2;
    gbc_panel_2.anchor = GridBagConstraints.NORTHWEST;
    gbc_panel_2.insets = new Insets(0, 0, 5, 0);
    gbc_panel_2.gridx = 0;
    gbc_panel_2.gridy = 0;
    jPanelDetail.add(panel_2, gbc_panel_2);
    panel_2.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));

    JLabel label = new JLabel("Name");
    panel_2.add(label);

    textFieldName = new JTextField();
    textFieldName.setColumns(20);
    panel_2.add(textFieldName);

    JPanel panel_3 = new JPanel();
    FlowLayout flowLayout_1 = (FlowLayout) panel_3.getLayout();
    flowLayout_1.setAlignment(FlowLayout.LEFT);
    panel_3.setBorder(null);
    GridBagConstraints gbc_panel_3 = new GridBagConstraints();
    gbc_panel_3.insets = new Insets(0, 0, 5, 0);
    gbc_panel_3.gridwidth = 2;
    gbc_panel_3.anchor = GridBagConstraints.NORTHWEST;
    gbc_panel_3.gridx = 0;
    gbc_panel_3.gridy = 1;
    jPanelDetail.add(panel_3, gbc_panel_3);

    labelPattern = new JLabel("Pattern");
    panel_3.add(labelPattern);

    textFieldPattern = new JTextField();
    textFieldPattern.setColumns(40);
    panel_3.add(textFieldPattern);

    JButton btnSave = new JButton("Save");
    btnSave.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DateFormat df1 = repository.getDateFormat(
                    ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow())
                            : -1));
            df1.update(textFieldName.getText(), textFieldPattern.getText(), textField.getText());
            reloadTable();
        }
    });

    JPanel panel_4 = new JPanel();
    FlowLayout flowLayout_2 = (FlowLayout) panel_4.getLayout();
    flowLayout_2.setAlignment(FlowLayout.LEFT);
    GridBagConstraints gbc_panel_4 = new GridBagConstraints();
    gbc_panel_4.anchor = GridBagConstraints.WEST;
    gbc_panel_4.insets = new Insets(0, 0, 5, 5);
    gbc_panel_4.gridx = 0;
    gbc_panel_4.gridy = 2;
    jPanelDetail.add(panel_4, gbc_panel_4);

    JLabel lblFastDateFormat = new JLabel("FastDateFormat");
    panel_4.add(lblFastDateFormat);

    textField = new JTextField();
    panel_4.add(textField);
    textField.setColumns(30);

    JPanel panel_5 = new JPanel();
    FlowLayout flowLayout_3 = (FlowLayout) panel_5.getLayout();
    flowLayout_3.setAlignment(FlowLayout.LEFT);
    GridBagConstraints gbc_panel_5 = new GridBagConstraints();
    gbc_panel_5.insets = new Insets(0, 0, 5, 5);
    gbc_panel_5.fill = GridBagConstraints.BOTH;
    gbc_panel_5.gridx = 0;
    gbc_panel_5.gridy = 3;
    jPanelDetail.add(panel_5, gbc_panel_5);

    JLabel lblSampleLabel = new JLabel("Sample");
    panel_5.add(lblSampleLabel);

    JPanel panel_6 = new JPanel();
    panel_6.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    GridBagConstraints gbc_panel_6 = new GridBagConstraints();
    gbc_panel_6.ipady = 1;
    gbc_panel_6.ipadx = 1;
    gbc_panel_6.insets = new Insets(0, 0, 5, 5);
    gbc_panel_6.fill = GridBagConstraints.BOTH;
    gbc_panel_6.gridx = 0;
    gbc_panel_6.gridy = 4;
    jPanelDetail.add(panel_6, gbc_panel_6);
    panel_6.setLayout(new BorderLayout(0, 0));

    JTextPane textPane = new JTextPane();
    textPane.setBackground(UIManager.getColor("windowBorder"));
    panel_6.add(textPane);
    GridBagConstraints gbc_btnSave = new GridBagConstraints();
    gbc_btnSave.anchor = GridBagConstraints.WEST;
    gbc_btnSave.insets = new Insets(0, 0, 0, 5);
    gbc_btnSave.gridx = 0;
    gbc_btnSave.gridy = 5;
    jPanelDetail.add(btnSave, gbc_btnSave);
    reloadTable();
}

From source file:biomine.bmvis2.pipeline.BestPathHiderOperation.java

public JComponent getSettingsComponent(final SettingsChangeCallback settingsChangeCallback,
        final VisualGraph graph) {
    long nodeCount = graph.getAllNodes().size();

    if (oldCount != 0) {
        long newTarget = (target * nodeCount) / oldCount;
        this.target = Math.max(newTarget, target);
    } else/* w w w. j a v a 2  s.co m*/
        this.target = nodeCount;

    this.oldCount = nodeCount;

    JPanel ret = new JPanel();

    // if int overflows, we're fucked
    final JSlider sl = new JSlider(0, (int) nodeCount, (int) Math.min(target, nodeCount));
    sl.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            if (target == sl.getValue())
                return;
            target = sl.getValue();
            settingsChangeCallback.settingsChanged(false);
        }
    });

    ret.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    //c.gridwidth=2;

    ret.add(sl, c);
    c.gridy++;

    int choices = graph.getNodesOfInterest().size() + 1;

    Object[] items = new Object[choices];
    items[0] = "All PoIs";

    for (int i = 1; i < choices; i++) {
        items[i] = i + " nearest";
    }
    final JComboBox pathTypeBox = new JComboBox(items);
    pathTypeBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            int i = pathTypeBox.getSelectedIndex();
            grader.setPathK(i);
            settingsChangeCallback.settingsChanged(false);
        }
    });

    ret.add(new JLabel("hide by best path quality to:"), c);
    c.gridy++;
    ret.add(pathTypeBox, c);
    c.gridy++;

    System.out.println("new confpane nodeCount = " + nodeCount);

    final JCheckBox useMatchingColoring = new JCheckBox();
    ret.add(useMatchingColoring, c);

    useMatchingColoring.setAction(new AbstractAction("Use matching coloring") {
        public void actionPerformed(ActionEvent arg0) {
            matchColoring = useMatchingColoring.isSelected();
            settingsChangeCallback.settingsChanged(false);
        }
    });

    useMatchingColoring.setAlignmentX(JComponent.CENTER_ALIGNMENT);

    c.gridy++;

    final JCheckBox labelsBox = new JCheckBox();
    ret.add(labelsBox, c);

    labelsBox.setAction(new AbstractAction("Show goodness in node labels") {
        public void actionPerformed(ActionEvent arg0) {
            showLabel = labelsBox.isSelected();
            settingsChangeCallback.settingsChanged(false);
        }
    });

    return ret;
}

From source file:DownloadDialog.java

/********************************************************************
 * Constructor: DownloadDialog//from ww  w. j a  va2  s.  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);

}