Example usage for java.awt Insets Insets

List of usage examples for java.awt Insets Insets

Introduction

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

Prototype

public Insets(int top, int left, int bottom, int right) 

Source Link

Document

Creates and initializes a new Insets object with the specified top, left, bottom, and right insets.

Usage

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

protected void initializeComponent() {
    if (!this.initialized) {
        if (this.mappingDefinition == null) {
            this.mode = AssuranceDialogMode.ADD;
            this.dialogTitle = "Add New Path Mapping";
            this.mappingDefinition = new ScanMappingDefinition();
        } else {//  ww w  .j a v a2  s  .c om
            this.mode = AssuranceDialogMode.EDIT;
            this.dialogTitle = "Edit Path Mapping";
        }

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

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

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

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

        scanPathsPanel.setBorder(pathsPanelBorder);
        this.add(scanPathsPanel, scanPathsPanelConstraints);

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

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

        scanPathsPanel.add(this.sourcePathPickerField, sourcePathFieldConstraints);
        scanPathsPanel.add(this.targetPathPickerField, targetPathFieldConstraints);

        if (mappingDefinition != null) {
            File source = mappingDefinition.getSource();
            if (source != null) {
                this.sourcePathPickerField.setValue(source.getPath());
            } else {
                this.sourcePathPickerField.setValue("");
            }
            File target = mappingDefinition.getTarget();
            if (target != null) {
                this.targetPathPickerField.setValue(target.getPath());
            } else {
                this.targetPathPickerField.setValue("");
            }
        }

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

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

        JPanel existingExclusionsPanel = new JPanel();
        GridBagLayout panelGridbag = new GridBagLayout();
        existingExclusionsPanel.setLayout(panelGridbag);
        existingExclusionsPanel.setBorder(existingExclusionsPanelBorder);
        this.add(existingExclusionsPanel, existingExclusionsPanelConstraints);

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

        this.mappingDefinition = (ScanMappingDefinition) ModelUtils.initializeEntity(this.mappingDefinition,
                ScanMappingDefinition.EXCLUSIONS_PROPERTY);
        this.exclusionsPanel = new ListInputPanel<FileReference>(this.mappingDefinition, this);
        existingExclusionsPanel.add(this.exclusionsPanel, existingExclusionsListConstraints);

        this.initialized = true;
    }
}

From source file:lisong_mechlab.view.graphs.DamageGraph.java

/**
 * Creates and displays the {@link DamageGraph}.
 * /*from w  w  w.  ja v a 2  s . co m*/
 * @param aLoadout
 *            Which load out the diagram is for.
 * @param anXbar
 *            A {@link MessageXBar} to listen for changes to the loadout on.
 * @param aMaxSustainedDpsMetric
 *            A {@link MaxSustainedDPS} instance to use in calculation.
 */
public DamageGraph(LoadoutBase<?> aLoadout, MessageXBar anXbar, MaxSustainedDPS aMaxSustainedDpsMetric) {
    super("Max Sustained DPS over range for " + aLoadout);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    anXbar.attach(this);

    loadout = aLoadout;
    maxSustainedDPS = aMaxSustainedDpsMetric;
    chartPanel = new ChartPanel(makechart());
    setContentPane(chartPanel);
    chartPanel.getChart().getLegend().setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chartPanel.getChart().getLegend().setVerticalAlignment(VerticalAlignment.TOP);

    LegendTitle legendTitle = chartPanel.getChart().getLegend();
    XYTitleAnnotation titleAnnotation = new XYTitleAnnotation(0.98, 0.98, legendTitle,
            RectangleAnchor.TOP_RIGHT);
    titleAnnotation.setMaxWidth(0.4);
    ((XYPlot) (chartPanel.getChart().getPlot())).addAnnotation(titleAnnotation);
    chartPanel.getChart().removeLegend();

    chartPanel.setLayout(new OverlayLayout(chartPanel));
    JButton button = new JButton(
            new OpenHelp("What is this?", "Max-sustained-dps-graph", KeyStroke.getKeyStroke('w')));
    button.setMargin(new Insets(10, 10, 10, 10));
    button.setFocusable(false);
    button.setAlignmentX(Component.RIGHT_ALIGNMENT);
    button.setAlignmentY(Component.BOTTOM_ALIGNMENT);
    chartPanel.add(button);

    setIconImage(ProgramInit.programIcon);
    setSize(800, 600);
    setVisible(true);
}

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

/**
 * This method initializes this// w w w .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:logdruid.ui.DateEditor.java

/**
 * Create the panel./*  ww  w  . j a  v a2  s.  com*/
 */
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:DownloadDialog.java

/********************************************************************
 * Constructor: DownloadDialog/* w  w w  . j  a  v a2 s  . co 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:com.att.aro.ui.view.videotab.VideoTab.java

/**
 * Create the panel.// w ww .j  a  va2 s .  c  o m
 */
public VideoTab(MainFrame aroView, IARODiagnosticsOverviewRoute overviewRoute) {
    super();
    this.aroView = aroView;
    this.overviewRoute = overviewRoute;

    bpObservable = new AROModelObserver();

    container = new JPanel(new BorderLayout());

    String headerTitle = MessageFormat.format(ResourceBundleHelper.getMessageString("videoTab.title"),
            ApplicationConfig.getInstance().getAppBrandName(),
            ApplicationConfig.getInstance().getAppShortName());

    container.add(UIComponent.getInstance().getLogoHeader(headerTitle), BorderLayout.NORTH);

    // Summaries, Manifest, Requests
    ImagePanel panel = new ImagePanel(null);
    panel.setLayout(new GridBagLayout());
    panel.add(layoutDataPanel(), new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(10, 10, 0, 10), 0, 0));
    container.add(panel, BorderLayout.CENTER);

    setViewportView(container);
    getVerticalScrollBar().setUnitIncrement(10);
    getHorizontalScrollBar().setUnitIncrement(10);
}

From source file:com.intel.stl.ui.monitor.view.PSEventsPieChart.java

protected JPanel getLengendPanel() {
    JPanel panel = new JPanel();
    panel.setOpaque(false);//from   w  ww .ja  va2s  .c  om
    panel.setLayout(new GridBagLayout());
    GridBagConstraints gc = new GridBagConstraints();

    gc.fill = GridBagConstraints.BOTH;
    StateLongTypeViz[] states = StateLongTypeViz.values();
    stateLabels = new JLabel[states.length];
    for (int i = 0; i < states.length; i++) {
        StateLongTypeViz state = states[i];
        gc.insets = new Insets(2, 5, 2, 2);
        gc.weightx = 0;
        gc.gridwidth = 1;

        JLabel label = new JLabel(state.getName(),
                Util.generateImageIcon(state.getColor(), 8, new Insets(1, 1, 1, 1)), JLabel.LEFT);
        label.setFont(UIConstants.H5_FONT);
        label.setForeground(UIConstants.INTEL_DARK_GRAY);
        panel.add(label, gc);

        gc.gridwidth = GridBagConstraints.REMAINDER;
        gc.weightx = 0;
        stateLabels[i] = new JLabel();
        stateLabels[i].setForeground(UIConstants.INTEL_DARK_GRAY);
        stateLabels[i].setFont(UIConstants.H5_FONT);
        panel.add(stateLabels[i], gc);
    }
    return panel;
}

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);/* w w  w . j  av  a2 s  .c om*/
    revalidate();
}

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

/**
 * Create the panel./*from   ww w  .  j ava 2 s .c o m*/
 */
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:com.univocity.app.swing.DataAnalysisWindow.java

protected JPanel getStatusPanel() {
    if (statusPanel == null) {
        statusPanel = new JPanel();
        statusPanel.setLayout(new GridBagLayout());

        GridBagConstraints c = new GridBagConstraints();
        c.gridx = 0;/*from w ww . j a  v a 2  s.com*/
        c.gridy = 0;
        c.insets = new Insets(0, 5, 0, 5);
        statusPanel.add(getSearchLabel(), c);

        c.gridx++;
        c.ipadx = 350;
        statusPanel.add(getSearchField(), c);

        c.gridx++;
        c.ipadx = 0;
        statusPanel.add(getBtSearchNext(), c);

        c.gridx++;
        c.insets = new Insets(0, 5, 0, 20);
        statusPanel.add(getBtSearchPrevious(), c);

        c.gridx++;
        c.insets = new Insets(0, 5, 0, 5);
        statusPanel.add(getStatusLabel(), c);

        c.gridx++;
        statusPanel.add(getStatusInformation(), c);

        c.gridx++;
        c.weightx = 1.0;
        statusPanel.add(new JPanel(), c);

    }
    return statusPanel;
}