Examples of LabelFieldGBC


Examples of org.apache.tools.ant.gui.util.LabelFieldGBC

    public DynamicCustomizer(Class type, boolean readOnly) {
        super(new GridBagLayout());
        _readOnly = readOnly;
        _type = type;
       
        LabelFieldGBC gbc = new LabelFieldGBC();
        try {
            BeanInfo info = Introspector.getBeanInfo(type);
            // Set up pretty display stuff.
            setBorder(BorderFactory.createTitledBorder(
                info.getBeanDescriptor().getDisplayName()));
            setToolTipText(info.getBeanDescriptor().getShortDescription());

            // Get the properties and sort them.
            PropertyDescriptor[] props = info.getPropertyDescriptors();
            Arrays.sort(props, new PropertyComparator());
            for(int i = 0; i < props.length; i++) {
                // Ignore the "class" property, if it is provided.
                if(props[i].getName().equals("class")) continue;
                // Create a label for the field.
                JLabel label = new JLabel(props[i].getDisplayName() + ":");
               
                // Lookup the editor.
                PropertyEditor editor = getEditorForProperty(props[i]);

                // Add a listener to the editor so we know when to update
                // the bean's fields.
                editor.addPropertyChangeListener(_eListener);
               
                // XXX What we need to do right here is provide a component
                // that makes use of the "paintable" capability of the editor.
                Component comp = editor.getCustomEditor();
                if(comp == null) {
                    comp = new JLabel("<No editor available.>");
                    ((JLabel)comp).setBorder(BorderFactory.createEtchedBorder());
                }
               
                // See if it is a read-only property. If so, then just
                // display it.
                if(_readOnly || props[i].getWriteMethod() == null) {
                    comp.setEnabled(false);
                }

                // Setup the accellerator key.
                label.setLabelFor(comp);
                label.setDisplayedMnemonic(label.getText().charAt(0));

                // Set the tool tip text, if any.
                String tip = props[i].getShortDescription();
                if(tip != null) {
                    label.setToolTipText(tip);
                    if(comp instanceof JComponent) {
                        ((JComponent)comp).setToolTipText(tip);
                    }
                }

                // Add the label and fields.
                add(label, gbc.forLabel());
                add(comp, gbc.forField());

                // Set the mappings between editor and property, etc. for
                // quick lookup later.
                _prop2Editor.put(props[i], editor);
                _editor2Prop.put(editor, props[i]);
            }
            // Filler...
            add(new JLabel(), gbc.forLastLabel());

        }
        catch(Exception ex) {
            ex.printStackTrace();
        }
View Full Code Here

Examples of org.apache.tools.ant.gui.util.LabelFieldGBC

     *
     */
    protected void init() {
        setLayout(new BorderLayout());

        LabelFieldGBC gbc = new LabelFieldGBC();
        JPanel p = new JPanel(new GridBagLayout());
        add(p, BorderLayout.NORTH);

        _fileEditor = new FilePropertyEditor();
        p.add(new JLabel(
            getResources().getString(getID() + ".fileLabel")), gbc.forLabel());
        p.add(_fileEditor.getCustomEditor(), gbc.forField());

        _name = new JTextField(10);
        p.add(new JLabel(
            getResources().getString(getID() + ".nameLabel")), gbc.forLabel());
        p.add(_name, gbc.forField());

        p = new JPanel(null);
        p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
        p.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(
View Full Code Here

Examples of org.apache.tools.ant.gui.util.LabelFieldGBC

    public DynamicCustomizer(Class type, boolean readOnly) {
        super(new GridBagLayout());
        _readOnly = readOnly;
        _type = type;
       
        LabelFieldGBC gbc = new LabelFieldGBC();
        try {
            BeanInfo info = Introspector.getBeanInfo(type);
            // Set up pretty display stuff.
            setBorder(BorderFactory.createTitledBorder(
                info.getBeanDescriptor().getDisplayName()));
            setToolTipText(info.getBeanDescriptor().getShortDescription());

            // Get the properties and sort them.
            PropertyDescriptor[] props = info.getPropertyDescriptors();
            Arrays.sort(props, new PropertyComparator());
            for(int i = 0; i < props.length; i++) {
                // Ignore the "class" property, if it is provided.
                if(props[i].getName().equals("class")) continue;
                // Create a label for the field.
                JLabel label = new JLabel(props[i].getDisplayName() + ":");
               
                // Lookup the editor.
                PropertyEditor editor = getEditorForProperty(props[i]);

                // Add a listener to the editor so we know when to update
                // the bean's fields.
                editor.addPropertyChangeListener(_eListener);
               
                // XXX What we need to do right here is provide a component
                // that makes use of the "paintable" capability of the editor.
                Component comp = editor.getCustomEditor();
                if(comp == null) {
                    comp = new JLabel("<No editor available.>");
                    ((JLabel)comp).setBorder(BorderFactory.createEtchedBorder());
                }
               
                // See if it is a read-only property. If so, then just
                // display it.
                if(_readOnly || props[i].getWriteMethod() == null) {
                    comp.setEnabled(false);
                }

                // Setup the accellerator key.
                label.setLabelFor(comp);
                label.setDisplayedMnemonic(label.getText().charAt(0));

                // Set the tool tip text, if any.
                String tip = props[i].getShortDescription();
                if(tip != null) {
                    label.setToolTipText(tip);
                    if(comp instanceof JComponent) {
                        ((JComponent)comp).setToolTipText(tip);
                    }
                }

                // Add the label and fields.
                add(label, gbc.forLabel());
                add(comp, gbc.forField());

                // Set the mappings between editor and property, etc. for
                // quick lookup later.
                _prop2Editor.put(props[i], editor);
                _editor2Prop.put(editor, props[i]);
            }
            // Filler...
            add(new JLabel(), gbc.forLastLabel());

        }
        catch(Exception ex) {
            ex.printStackTrace();
        }
View Full Code Here

Examples of org.apache.tools.ant.gui.util.LabelFieldGBC

     *
     */
    protected void init() {
        setLayout(new BorderLayout());

        LabelFieldGBC gbc = new LabelFieldGBC();
        JPanel p = new JPanel(new GridBagLayout());
        add(p, BorderLayout.NORTH);

        _fileEditor = new FilePropertyEditor();
        p.add(new JLabel(
            getResources().getString(getID() + ".fileLabel")), gbc.forLabel());
        p.add(_fileEditor.getCustomEditor(), gbc.forField());

        _name = new JTextField(10);
        p.add(new JLabel(
            getResources().getString(getID() + ".nameLabel")), gbc.forLabel());
        p.add(_name, gbc.forField());

        p = new JPanel(null);
        p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
        p.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.