Example usage for java.awt GridBagConstraints HORIZONTAL

List of usage examples for java.awt GridBagConstraints HORIZONTAL

Introduction

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

Prototype

int HORIZONTAL

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

Click Source Link

Document

Resize the component horizontally but not vertically.

Usage

From source file:org.apache.taverna.activities.xpath.ui.contextualview.XPathActivityMainContextualView.java

@Override
public JComponent getMainFrame() {
    jpMainPanel = new JPanel(new GridBagLayout());
    jpMainPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 2, 4, 2),
            BorderFactory.createEmptyBorder()));

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.weighty = 0;//from   w w w.j  ava  2  s  .  c  om

    // --- XPath Expression ---

    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(5, 5, 5, 5);
    JLabel jlXPathExpression = new JLabel("XPath Expression:");
    jlXPathExpression.setFont(jlXPathExpression.getFont().deriveFont(Font.BOLD));
    jpMainPanel.add(jlXPathExpression, c);

    c.gridx++;
    c.weightx = 1.0;
    tfXPathExpression = new JTextField();
    tfXPathExpression.setEditable(false);
    jpMainPanel.add(tfXPathExpression, c);

    // --- Label to Show/Hide Mapping Table ---

    final JLabel jlShowHideNamespaceMappings = new JLabel("Show namespace mappings...");
    jlShowHideNamespaceMappings.setForeground(Color.BLUE);
    jlShowHideNamespaceMappings.setCursor(new Cursor(Cursor.HAND_CURSOR));
    jlShowHideNamespaceMappings.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            spXPathNamespaceMappings.setVisible(!spXPathNamespaceMappings.isVisible());
            jlShowHideNamespaceMappings.setText(
                    (spXPathNamespaceMappings.isVisible() ? "Hide" : "Show") + " namespace mappings...");
            thisContextualView.revalidate();
        }
    });

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    jpMainPanel.add(jlShowHideNamespaceMappings, c);

    // --- Namespace Mapping Table ---

    xpathNamespaceMappingsTableModel = new DefaultTableModel() {
        /**
         * No cells should be editable
         */
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return (false);
        }
    };
    xpathNamespaceMappingsTableModel.addColumn("Namespace Prefix");
    xpathNamespaceMappingsTableModel.addColumn("Namespace URI");

    jtXPathNamespaceMappings = new JTable();
    jtXPathNamespaceMappings.setModel(xpathNamespaceMappingsTableModel);
    jtXPathNamespaceMappings.setPreferredScrollableViewportSize(new Dimension(200, 90));
    // TODO - next line is to be enabled when Taverna is migrated to Java
    // 1.6; for now it's fine to run without this
    // jtXPathNamespaceMappings.setFillsViewportHeight(true); // makes sure
    // that when the dedicated area is larger than the table, the latter is
    // stretched vertically to fill the empty space

    jtXPathNamespaceMappings.getColumnModel().getColumn(0).setPreferredWidth(20); // set
    // relative
    // sizes of
    // columns
    jtXPathNamespaceMappings.getColumnModel().getColumn(1).setPreferredWidth(300);

    c.gridy++;
    spXPathNamespaceMappings = new JScrollPane(jtXPathNamespaceMappings);
    spXPathNamespaceMappings.setVisible(false);
    jpMainPanel.add(spXPathNamespaceMappings, c);

    // populate the view with values
    refreshView();

    return jpMainPanel;
}

From source file:io.github.tavernaextras.biocatalogue.integration.config.BioCataloguePluginConfigurationPanel.java

private void initialiseUI() {
    this.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.weightx = 1.0;/*  www. j a va 2  s . c om*/

    c.gridx = 0;
    c.gridy = 0;
    JTextArea taDescription = new JTextArea("Configure the Service Catalogue integration functionality");
    taDescription.setFont(taDescription.getFont().deriveFont(Font.PLAIN, 11));
    taDescription.setLineWrap(true);
    taDescription.setWrapStyleWord(true);
    taDescription.setEditable(false);
    taDescription.setFocusable(false);
    taDescription.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    this.add(taDescription, c);

    c.gridy++;
    c.insets = new Insets(20, 0, 0, 0);
    JLabel jlBioCatalogueAPIBaseURL = new JLabel("Base URL of the Service Catalogue instance to connect to:");
    this.add(jlBioCatalogueAPIBaseURL, c);

    c.gridy++;
    c.insets = new Insets(0, 0, 0, 0);
    tfBioCatalogueAPIBaseURL = new JTextField();
    this.add(tfBioCatalogueAPIBaseURL, c);

    c.gridy++;
    c.insets = new Insets(30, 0, 0, 0);
    // We are not removing BioCatalogue services from its config panel any more - 
    // they are being handled by the Taverna's Service Registry
    //    JButton bForgetStoredServices = new JButton("Forget services added to Service Panel by BioCatalogue Plugin");
    //    bForgetStoredServices.addActionListener(new ActionListener() {
    //      public void actionPerformed(ActionEvent e)
    //      {
    //        int response = JOptionPane.showConfirmDialog(null, // no way T2ConfigurationFrame instance can be obtained to be used as a parent...
    //                                       "Are you sure you want to clear all SOAP operations and REST methods\n" +
    //                                       "that were added to the Service Panel by the BioCatalogue Plugin?\n\n" +
    //                                       "This action is permanent is cannot be undone.\n\n" +
    //                                       "Do you want to proceed?", "BioCatalogue Plugin", JOptionPane.YES_NO_OPTION);
    //        
    //        if (response == JOptionPane.YES_OPTION)
    //        {
    //          BioCatalogueServiceProvider.clearRegisteredServices();
    //          JOptionPane.showMessageDialog(null,  // no way T2ConfigurationFrame instance can be obtained to be used as a parent...
    //                          "Stored services have been successfully cleared, but will remain\n" +
    //                          "being shown in Service Panel during this session.\n\n" +
    //                          "They will not appear in the Service Panel after you restart Taverna.",
    //                          "BioCatalogue Plugin", JOptionPane.INFORMATION_MESSAGE);
    //        }
    //      }
    //    });
    //    this.add(bForgetStoredServices, c);

    JButton bLoadDefaults = new JButton("Load Defaults");
    bLoadDefaults.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            loadDefaults();
        }
    });

    JButton bReset = new JButton("Reset");
    bReset.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            resetFields();
        }
    });

    JButton bApply = new JButton("Apply");
    bApply.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            applyChanges();
        }
    });

    JPanel jpActionButtons = new JPanel();
    jpActionButtons.add(bLoadDefaults);
    jpActionButtons.add(bReset);
    jpActionButtons.add(bApply);
    c.insets = new Insets(30, 0, 0, 0);
    c.gridy++;
    c.weighty = 1.0;
    this.add(jpActionButtons, c);
}

From source file:com.github.boogey.progressview.swing.JProgressPanel.java

/**
 * This protected method set the location of the components ({@link JLabel} and {@link JProgressBar}) on the
 * {@link JPanel}. The layout is set in the {@link #initObjects()}-method. This {@link JPanel} will use an
 * {@link GridBagLayout}./*from  w  ww. j av  a2  s . co  m*/
 */
protected void positionElements() {
    GridBagConstraints constraints = new GridBagConstraints();

    constraints.insets = new Insets(5, 5, 5, 5);
    constraints.anchor = GridBagConstraints.FIRST_LINE_START;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1.0;
    constraints.weighty = 0.0;

    constraints.gridx = 0;
    constraints.gridy = 0;
    positionMessage(constraints);

    constraints.anchor = GridBagConstraints.FIRST_LINE_START;
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    constraints.gridy = 1;
    positionProgressBar(constraints);
}

From source file:com.github.cmisbox.ui.BaseFrame.java

public BaseFrame() {
    super(AWTUtilitiesWrapper.isTranslucencyCapable(BaseFrame.gc) ? BaseFrame.gc : null);
    this.log = LogFactory.getLog(this.getClass());

    this.gradient = false;
    this.setUndecorated(true);
    this.mainPanel = new JPanel(new GridBagLayout()) {

        private static final long serialVersionUID = 1035974033526970010L;

        protected void paintComponent(Graphics g) {
            if ((g instanceof Graphics2D) && BaseFrame.this.gradient) {
                final int R = 0;
                final int G = 0;
                final int B = 0;

                Paint p = new GradientPaint(0.0f, 0.0f, new Color(R, G, B, 192), this.getWidth(),
                        this.getHeight(), new Color(R, G, B, 255), true);
                Graphics2D g2d = (Graphics2D) g;
                g2d.setPaint(p);//ww w.  ja va  2 s.  co  m
                g2d.fillRect(0, 0, this.getWidth(), this.getHeight());
            } else {
                super.paintComponent(g);
            }
        }
    };

    this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

    GridBagConstraints gbc = new GridBagConstraints();

    this.mainPanel.setDoubleBuffered(false);
    this.mainPanel.setOpaque(false);
    this.mainPanel.setBorder(BorderFactory.createLineBorder(Color.white));

    JLabel title = new JLabel(this.getWindowTitle(), SwingConstants.CENTER);
    title.setForeground(Color.white);

    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weightx = 100;

    this.mainPanel.add(title, gbc);

    Image closeImg = this.getImage("images/application-exit.png", 32, 32);
    JLabel close = new JLabel(new ImageIcon(closeImg), SwingConstants.RIGHT);

    gbc.fill = GridBagConstraints.NONE;
    gbc.gridx = 2;
    gbc.weightx = 0;

    this.mainPanel.add(close, gbc);

    close.addMouseListener(this.closeAdapter);

    this.getContentPane().add(this.mainPanel, BorderLayout.CENTER);

    this.initComponents();

    this.pack();

    this.mainPanel.setOpaque(!this.gradient);
    if (!this.gradient) {
        this.mainPanel.setBackground(new Color(0, 0, 0, 208));
    }

    this.setLocationRelativeTo(null);
    AWTUtilitiesWrapper.setWindowOpaque(this, false);
    this.setVisible(true);
    this.setAlwaysOnTop(true);

}

From source file:edu.harvard.mcz.imagecapture.ChangePasswordDialog.java

/**
 * This method initializes jContentPane/*w  ww  .  j  a v a 2 s  .c o  m*/
 * 
 * @return javax.swing.JPanel
 */
private JPanel getJContentPane() {
    if (jContentPane == null) {
        GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
        gridBagConstraints10.gridx = 0;
        gridBagConstraints10.weightx = 0.0;
        gridBagConstraints10.weighty = 1.0;
        gridBagConstraints10.gridy = 6;
        GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
        gridBagConstraints9.gridx = 0;
        gridBagConstraints9.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints9.gridwidth = 2;
        gridBagConstraints9.gridy = 4;
        jLabelResponse = new JLabel();
        jLabelResponse.setText("");
        GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
        gridBagConstraints8.fill = GridBagConstraints.BOTH;
        gridBagConstraints8.gridy = 3;
        gridBagConstraints8.weightx = 1.0;
        gridBagConstraints8.anchor = GridBagConstraints.WEST;
        gridBagConstraints8.gridx = 1;
        GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
        gridBagConstraints7.fill = GridBagConstraints.BOTH;
        gridBagConstraints7.gridy = 2;
        gridBagConstraints7.weightx = 1.0;
        gridBagConstraints7.anchor = GridBagConstraints.WEST;
        gridBagConstraints7.gridx = 1;
        GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
        gridBagConstraints6.fill = GridBagConstraints.BOTH;
        gridBagConstraints6.gridy = 1;
        gridBagConstraints6.weightx = 1.0;
        gridBagConstraints6.anchor = GridBagConstraints.WEST;
        gridBagConstraints6.gridx = 1;
        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
        gridBagConstraints5.gridx = 0;
        gridBagConstraints5.anchor = GridBagConstraints.EAST;
        gridBagConstraints5.gridy = 5;
        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
        gridBagConstraints4.gridx = 1;
        gridBagConstraints4.anchor = GridBagConstraints.CENTER;
        gridBagConstraints4.gridy = 5;
        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.gridx = 0;
        gridBagConstraints3.anchor = GridBagConstraints.EAST;
        gridBagConstraints3.gridy = 3;
        jLabel3 = new JLabel();
        jLabel3.setText("New Password Again");
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.gridx = 0;
        gridBagConstraints2.anchor = GridBagConstraints.EAST;
        gridBagConstraints2.gridy = 2;
        jLabel2 = new JLabel();
        jLabel2.setText("New Password");
        GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
        gridBagConstraints11.gridx = 0;
        gridBagConstraints11.anchor = GridBagConstraints.EAST;
        gridBagConstraints11.gridy = 1;
        jLabel1 = new JLabel();
        jLabel1.setText("Old Password");
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.fill = GridBagConstraints.BOTH;
        gridBagConstraints1.gridy = 0;
        gridBagConstraints1.weightx = 1.0;
        gridBagConstraints1.anchor = GridBagConstraints.WEST;
        gridBagConstraints1.gridx = 1;
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.anchor = GridBagConstraints.EAST;
        gridBagConstraints.gridy = 0;
        jLabel = new JLabel();
        jLabel.setText("Change Password For:");
        jContentPane = new JPanel();
        jContentPane.setLayout(new GridBagLayout());
        jContentPane.add(jLabel, gridBagConstraints);
        jContentPane.add(getJTextField(), gridBagConstraints1);
        jContentPane.add(jLabel1, gridBagConstraints11);
        jContentPane.add(jLabel2, gridBagConstraints2);
        jContentPane.add(jLabel3, gridBagConstraints3);
        jContentPane.add(getJButton(), gridBagConstraints4);
        jContentPane.add(getJButton1(), gridBagConstraints5);
        jContentPane.add(getJPasswordFieldOld(), gridBagConstraints6);
        jContentPane.add(getJPasswordField1(), gridBagConstraints7);
        jContentPane.add(getJPasswordField2(), gridBagConstraints8);
        jContentPane.add(jLabelResponse, gridBagConstraints9);
        jContentPane.add(getJPanel(), gridBagConstraints10);
    }
    return jContentPane;
}

From source file:gdt.jgui.entity.contact.JContactEditor.java

public JContactEditor() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 100, 0, 0 };
    gridBagLayout.rowHeights = new int[] { 0, 0, 0 };
    gridBagLayout.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0 };
    setLayout(gridBagLayout);//w w w . j  a  v a  2  s . c  o  m
    JLabel lblTitle = new JLabel("Label");

    GridBagConstraints gbc_lblTitle = new GridBagConstraints();
    gbc_lblTitle.insets = new Insets(5, 5, 5, 5);
    gbc_lblTitle.gridx = 0;
    gbc_lblTitle.gridy = 0;
    gbc_lblTitle.anchor = GridBagConstraints.NORTHWEST;
    add(lblTitle, gbc_lblTitle);
    title = new JTextField();

    GridBagConstraints gbc_title = new GridBagConstraints();
    gbc_title.insets = new Insets(5, 0, 5, 5);
    gbc_title.fill = GridBagConstraints.HORIZONTAL;
    gbc_title.gridx = 1;
    gbc_title.gridy = 0;
    add(title, gbc_title);
    title.setColumns(10);

    JLabel lblPhone = new JLabel("Phone");
    GridBagConstraints gbc_lblphone = new GridBagConstraints();
    gbc_lblphone.insets = new Insets(5, 5, 5, 5);
    gbc_lblphone.gridx = 0;
    gbc_lblphone.gridy = 1;
    gbc_lblphone.anchor = GridBagConstraints.NORTHWEST;
    add(lblPhone, gbc_lblphone);

    phone = new JTextField();
    GridBagConstraints gbc_phone = new GridBagConstraints();
    gbc_phone.insets = new Insets(5, 0, 5, 5);
    gbc_phone.fill = GridBagConstraints.HORIZONTAL;
    gbc_phone.gridx = 1;
    gbc_phone.gridy = 1;
    add(phone, gbc_phone);
    phone.setColumns(10);

    JLabel lblEmail = new JLabel("Email");
    GridBagConstraints gbc_lblEmail = new GridBagConstraints();
    gbc_lblEmail.insets = new Insets(5, 5, 5, 5);
    gbc_lblEmail.gridx = 0;
    gbc_lblEmail.gridy = 2;
    gbc_lblEmail.anchor = GridBagConstraints.NORTHWEST;
    add(lblEmail, gbc_lblEmail);

    email = new JTextField();
    GridBagConstraints gbc_email = new GridBagConstraints();
    gbc_phone.insets = new Insets(5, 0, 5, 5);
    gbc_email.fill = GridBagConstraints.HORIZONTAL;
    gbc_email.gridx = 1;
    gbc_email.gridy = 2;
    add(email, gbc_email);
    email.setColumns(10);
    JPanel panel = new JPanel();
    GridBagConstraints gbc_panel = new GridBagConstraints();
    gbc_panel.weighty = 1.0;
    gbc_panel.insets = new Insets(5, 0, 5, 5);
    gbc_panel.fill = GridBagConstraints.BOTH;
    gbc_panel.gridx = 0;
    gbc_panel.gridy = 3;
    add(panel, gbc_panel);
    panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
}

From source file:EditorPaneExample19.java

public EditorPaneExample19() {
    super("JEditorPane Example 19");

    pane = new JEditorPane();
    pane.setEditable(true); // Editable
    getContentPane().add(new JScrollPane(pane), "Center");

    // Add a menu bar
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);/* w  w w .  j av  a  2s .c o m*/

    // Populate it
    createMenuBar();

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridy = 5;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    editableBox = new JCheckBox("Editable JEditorPane");
    panel.add(editableBox, c);
    editableBox.setSelected(true);
    editableBox.setForeground(typeLabel.getForeground());

    c.gridy = 6;
    c.weightx = 0.0;
    JButton saveButton = new JButton("Save");
    panel.add(saveButton, c);
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            EditorKit kit = pane.getEditorKit();
            try {
                if (kit instanceof RTFEditorKit) {
                    kit.write(System.out, pane.getDocument(), 0, pane.getDocument().getLength());
                    System.out.flush();
                } else {
                    if (writer == null) {
                        writer = new OutputStreamWriter(System.out);
                        pane.write(writer);
                        writer.flush();
                    }
                    kit.write(writer, pane.getDocument(), 0, pane.getDocument().getLength());
                    writer.flush();
                }
            } catch (Exception e) {
                System.out.println("Write failed");
            }
        }
    });

    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    urlCombo = new JComboBox();
    panel.add(urlCombo, c);
    urlCombo.setEditable(true);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Register a custom EditorKit for HTML
    ClassLoader loader = getClass().getClassLoader();
    if (loader != null) {
        // Java 2
        JEditorPane.registerEditorKitForContentType("text/html", "AdvancedSwing.Chapter4.EnhancedHTMLEditorKit",
                loader);
    } else {
        // JDK 1.1
        JEditorPane.registerEditorKitForContentType("text/html",
                "AdvancedSwing.Chapter4.EnhancedHTMLEditorKit");
    }

    // Allocate the empty tree model
    DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty");
    emptyModel = new DefaultTreeModel(emptyRootNode);

    // Create and place the heading tree
    tree = new JTree(emptyModel);
    tree.setPreferredSize(new Dimension(200, 200));
    getContentPane().add(new JScrollPane(tree), "East");

    // Change page based on combo selection
    urlCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (populatingCombo == true) {
                return;
            }
            Object selection = urlCombo.getSelectedItem();
            loadNewPage(selection);
        }
    });

    // Change editability based on the checkbox
    editableBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pane.setEditable(editableBox.isSelected());
            pane.revalidate();
            pane.repaint();
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
                populateCombo(findLinks(pane.getDocument(), null));
                TreeNode node = buildHeadingTree(pane.getDocument());
                tree.setModel(new DefaultTreeModel(node));

                createMenuBar();
                enableMenuBar(true);
                getRootPane().revalidate();

                enableInput();
                loadingPage = false;
            }
        }
    });

    // Listener for tree selection
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent evt) {
            TreePath path = evt.getNewLeadSelectionPath();
            if (path != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                Object userObject = node.getUserObject();
                if (userObject instanceof Heading) {
                    Heading heading = (Heading) userObject;
                    try {
                        Rectangle textRect = pane.modelToView(heading.getOffset());
                        textRect.y += 3 * textRect.height;
                        pane.scrollRectToVisible(textRect);
                    } catch (BadLocationException e) {
                    }
                }
            }
        }
    });

    // Listener for hypertext events
    pane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            // Ignore hyperlink events if the frame is busy
            if (loadingPage == true) {
                return;
            }
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                JEditorPane sp = (JEditorPane) evt.getSource();
                if (evt instanceof HTMLFrameHyperlinkEvent) {
                    HTMLDocument doc = (HTMLDocument) sp.getDocument();
                    doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt);
                } else {
                    loadNewPage(evt.getURL());
                }
            } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                pane.setCursor(handCursor);
            } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) {
                pane.setCursor(defaultCursor);
            }
        }
    });
}

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 {//from w ww  .ja v  a 2  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:com.intuit.tank.tools.debugger.FindReplaceDialog.java

/**
 * Constructs a new find dialog according to the specified type of dialog requested. The dialog can be either a FIND
 * dialog, either a REPLACE dialog. In both cases, components displayed remain the sames, but the ones specific to
 * replace feature are grayed out.//from ww  w.  ja va2s.  c  o  m
 * 
 * @param parent
 *            The window holder
 * @param type
 *            The type of the dialog: FindReplace.FIND or FindReplace.REPLACE
 * @param modal
 *            Displays dialog as a modal window if true
 */

public FindReplaceDialog(AgentDebuggerFrame parent, DialogType type) {
    super(parent, type == DialogType.REPLACE ? "Replace" : "Find", true);
    this.parent = parent;

    cbSearch = new JComboBox();
    cbSearch.setEditable(true);
    cbReplace = new JComboBox();
    cbReplace.setEditable(true);
    KeyHandler handler = new KeyHandler();
    tfSearchEditor = (JTextField) cbSearch.getEditor().getEditorComponent();
    tfSearchEditor.addKeyListener(handler);
    tfReplaceEditor = (JTextField) cbReplace.getEditor().getEditorComponent();
    tfReplaceEditor.addKeyListener(handler);

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints constraints = new GridBagConstraints();
    getContentPane().setLayout(gridbag);
    ((JPanel) getContentPane()).setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    int gridX = 0;
    int gridY = 0;
    JLabel findLabel = new JLabel("Find");
    buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0);
    constraints.anchor = GridBagConstraints.WEST;
    gridbag.setConstraints(findLabel, constraints);
    getContentPane().add(findLabel);
    gridX++;

    buildConstraints(constraints, gridX, gridY, 1, 1, 100, 0);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.anchor = GridBagConstraints.CENTER;
    gridbag.setConstraints(cbSearch, constraints);
    getContentPane().add(cbSearch);
    gridX++;

    btnFind = new JButton("Find");
    btnFind.setToolTipText("Find text in scripts");
    btnFind.setMnemonic('F');
    btnFind.addActionListener(this);
    buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0);
    constraints.anchor = GridBagConstraints.CENTER;
    gridbag.setConstraints(btnFind, constraints);
    getContentPane().add(btnFind);
    getRootPane().setDefaultButton(btnFind);
    gridX++;

    btnCancel = new JButton("Cancel");
    btnCancel.setMnemonic('C');
    btnCancel.addActionListener(this);
    buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0);
    constraints.anchor = GridBagConstraints.CENTER;
    gridbag.setConstraints(btnCancel, constraints);
    getContentPane().add(btnCancel);
    gridY++;
    gridX = 0;
    if (type == DialogType.REPLACE) {
        JLabel replaceLabel = new JLabel("Replace");
        buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0);
        constraints.anchor = GridBagConstraints.WEST;
        gridbag.setConstraints(replaceLabel, constraints);
        getContentPane().add(replaceLabel);
        gridX++;

        buildConstraints(constraints, gridX, gridY, 1, 1, 100, 0);
        constraints.fill = GridBagConstraints.HORIZONTAL;
        constraints.anchor = GridBagConstraints.CENTER;
        gridbag.setConstraints(cbReplace, constraints);
        getContentPane().add(cbReplace);
        gridX++;

        btnReplace = new JButton("Replace");
        btnReplace.setToolTipText("REplace in script");
        btnReplace.setMnemonic('R');
        btnReplace.addActionListener(this);
        buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0);
        constraints.anchor = GridBagConstraints.CENTER;
        gridbag.setConstraints(btnReplace, constraints);
        getContentPane().add(btnReplace);
        gridX++;

        btnReplaceAll = new JButton("Replace All");
        btnReplaceAll.addActionListener(this);
        buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0);
        constraints.anchor = GridBagConstraints.CENTER;
        gridbag.setConstraints(btnReplaceAll, constraints);
        getContentPane().add(btnReplaceAll);
        btnReplace.addKeyListener(handler);
        btnReplaceAll.addKeyListener(handler);
        gridY++;
        gridX = 0;
    }

    TitledBorder border = new TitledBorder("Options");
    JPanel panel = new JPanel(new GridLayout(1, 4));
    panel.setBorder(border);
    checkboxWrap = new JCheckBox("Wrap Search");
    panel.add(checkboxWrap);

    checkboxMatchCase = new JCheckBox("Case sensitive");
    panel.add(checkboxMatchCase);

    checkboxRegexp = new JCheckBox("Regular expressions");
    panel.add(checkboxRegexp);

    buildConstraints(constraints, gridX, gridY, 4, 1, 100, 100);
    constraints.anchor = GridBagConstraints.WEST;
    gridbag.setConstraints(panel, constraints);
    getContentPane().add(panel);

    FontMetrics fm = getFontMetrics(getFont());
    cbSearch.setPreferredSize(new Dimension(18 * fm.charWidth('m'), (int) cbSearch.getPreferredSize().height));
    cbReplace
            .setPreferredSize(new Dimension(18 * fm.charWidth('m'), (int) cbReplace.getPreferredSize().height));

    pack();
    // setResizable(false);
    WindowUtil.centerOnParent(this);

    // patch by MJB 8/1/2002
    btnFind.addKeyListener(handler);

    btnCancel.addKeyListener(handler);
    checkboxMatchCase.addKeyListener(handler);
    checkboxRegexp.addKeyListener(handler);

}

From source file:org.openconcerto.erp.core.finance.accounting.ui.CloturePanel.java

public CloturePanel() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.gridx = 0;/*  ww w  .j av  a 2 s  .  c  o m*/
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 1;
    c.weightx = 0;
    c.weighty = 0;

    JLabel rappel = new JLabelBold("Oprations  effectuer avant de continuer: ");
    JLabel label = new JLabel("- report des charges et produits constats d'avance");
    JLabel label2 = new JLabel("- report des charges  payer et produits  recevoir");
    JLabel label3 = new JLabel("- impression du bilan, compte de rsultat, grand livre, journaux et balance");
    JLabel label5 = new JLabel("- gnration les critures comptables des payes");
    JLabel label4 = new JLabel("Il est prfrable de raliser une sauvegarde avant de continuer.");

    JLabel op = new JLabelBold("Oprations qui vont etre effectues: ");
    JLabel labelValid = new JLabel(
            "- validation de toutes les critures concernant la priode de l'exercice.");
    JLabel labelSoldeGestion = new JLabel("- soldes de tous les comptes de gestions 6* et 7*");
    JLabel labelSoldeBilan = new JLabel("- soldes de tous les comptes de bilan");
    JLabel labelAN = new JLabel("- report des  nouveaux");

    c.gridy = GridBagConstraints.RELATIVE;
    c.gridx = 0;

    // Date de l'ancien exercice
    Calendar dDebut = this.rowExercice.getDate("DATE_DEB");
    Calendar dFin = this.rowExercice.getDate("DATE_FIN");
    JLabel labelAncienExercice = new JLabel("Clture de l'exercice du " + dateFormat.format(dDebut.getTime())
            + " au " + dateFormat.format(dFin.getTime()));
    this.add(labelAncienExercice, c);
    c.insets = new Insets(10, 2, 1, 2);
    this.add(rappel, c);
    this.add(label, c);
    this.add(label2, c);
    this.add(label3, c);
    this.add(label5, c);
    this.add(label4, c);

    c.insets = new Insets(15, 2, 1, 2);
    this.add(op, c);

    c.insets = new Insets(10, 2, 1, 2);
    this.add(labelValid, c);
    this.add(labelSoldeGestion, c);
    this.add(labelSoldeBilan, c);
    this.add(labelAN, c);

    // Date du prochain exercice
    c.gridwidth = 1;
    c.gridy = GridBagConstraints.RELATIVE;
    c.gridx = 0;
    c.gridx = GridBagConstraints.RELATIVE;
    c.fill = GridBagConstraints.NONE;

    this.add(new JLabel("Date du nouvel exercice du "), c);

    dDebut.set(Calendar.YEAR, dDebut.get(Calendar.YEAR) + 1);
    this.dateOuv.setValue(dDebut.getTime());
    this.add(this.dateOuv, c);
    this.add(new JLabel("au"), c);
    dFin.set(Calendar.YEAR, dFin.get(Calendar.YEAR) + 1);
    this.dateFerm.setValue(dFin.getTime());
    this.add(this.dateFerm, c);

    c.gridx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = 2;
    c.weightx = 1;
    this.add(this.opEnCours, c);

    c.gridwidth = 4;
    c.gridx = 0;
    c.weightx = 1;
    this.add(this.bar, c);

    //
    this.add(this.boxValid, c);

    // Button
    final JPanel buttonBar = new JPanel();
    buttonBar.add(this.valider);
    buttonBar.add(this.annul);

    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;
    c.gridx = 0;
    this.add(buttonBar, c);

    final PropertyChangeListener listener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            CloturePanel.this.valider.setEnabled(isDateValid());
        }
    };
    this.dateFerm.addValueListener(listener);
    this.dateOuv.addValueListener(listener);

    // TODO afficher le deroulement de etapes apres validation

    this.valider.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            try {
                clotureExercice();
                // show OK works fine
                Component comp = SwingUtilities.getRoot(CloturePanel.this);
                JOptionPane.showMessageDialog(CloturePanel.this, "Exercice cltur", "Fin de la clture",
                        JOptionPane.INFORMATION_MESSAGE);
                ((JFrame) comp).dispose();
            } catch (Exception ex) {
                ExceptionHandler.handle("Erreur lors de la clture", ex);
            }
        }
    });

    this.valider.setEnabled(isDateValid());

    this.boxValid.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            CloturePanel.this.valider.setEnabled(isDateValid());
        }
    });

    this.annul.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            ((JFrame) SwingUtilities.getRoot(CloturePanel.this)).dispose();
        }
    });
}