Examples of ButtonGroup


Examples of javax.swing.ButtonGroup

                } catch (NumberFormatException e) {
                }
            }
        };

        ButtonGroup group = new ButtonGroup();
        JRadioButtonMenuItem button = new JRadioButtonMenuItem(i18n.get(BasicStrokeEditorMenu.class, "Butt", "Butt"), endCaps == BasicStroke.CAP_BUTT);
        button.setActionCommand(String.valueOf(BasicStroke.CAP_BUTT));
        group.add(button);
        button.addActionListener(listener);
        capMenu.add(button);

        button = new JRadioButtonMenuItem(i18n.get(BasicStrokeEditorMenu.class, "Round", "Round"), endCaps == BasicStroke.CAP_ROUND);
        button.setActionCommand(String.valueOf(BasicStroke.CAP_ROUND));
        group.add(button);
        button.addActionListener(listener);
        capMenu.add(button);

        button = new JRadioButtonMenuItem(i18n.get(BasicStrokeEditorMenu.class, "Square", "Square"), endCaps == BasicStroke.CAP_SQUARE);
        button.setActionCommand(String.valueOf(BasicStroke.CAP_SQUARE));
        group.add(button);
        button.addActionListener(listener);
        capMenu.add(button);

        //////// Line Joins

        JMenu joinMenu = new JMenu(i18n.get(BasicStrokeEditorMenu.class, "Joint_Decoration", "Joint Decoration"));

        listener = new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                String command = ae.getActionCommand();
                try {
                    setLineJoins(Integer.parseInt(command));
                    resetStroke();
                } catch (NumberFormatException e) {
                }
            }
        };

        group = new ButtonGroup();
        button = new JRadioButtonMenuItem(i18n.get(BasicStrokeEditorMenu.class, "Miter", "Miter"), lineJoins == BasicStroke.JOIN_MITER);
        button.setActionCommand(String.valueOf(BasicStroke.JOIN_MITER));
        group.add(button);
        button.addActionListener(listener);
        joinMenu.add(button);

        button = new JRadioButtonMenuItem(i18n.get(BasicStrokeEditorMenu.class, "Round", "Round"), lineJoins == BasicStroke.JOIN_ROUND);
        button.setActionCommand(String.valueOf(BasicStroke.JOIN_ROUND));
        group.add(button);
        button.addActionListener(listener);
        joinMenu.add(button);

        button = new JRadioButtonMenuItem(i18n.get(BasicStrokeEditorMenu.class, "Bevel", "Bevel"), lineJoins == BasicStroke.JOIN_BEVEL);
        button.setActionCommand(String.valueOf(BasicStroke.JOIN_BEVEL));
        group.add(button);
        button.addActionListener(listener);
        joinMenu.add(button);

        //////// Line Width

        JMenu widthMenu = new JMenu(i18n.get(BasicStrokeEditorMenu.class, "Line_Width", "Line_Width"));

        listener = new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                String command = ae.getActionCommand();
                try {
                    setStrokeWidth((float) Integer.parseInt(command));
                    resetStroke();
                } catch (NumberFormatException e) {
                }
            }
        };

        group = new ButtonGroup();
        ImageIcon ii;
        int i;
        for (i = 1; i < 13; i++) {
            ii = createIcon(new BasicStroke(i), 50, 20, true);
            button = new JRadioButtonMenuItem(" ", ii, (int) width == i);//without the space as a parameter these instances look strange with some Look&Feel
            button.setActionCommand(String.valueOf(i));
            group.add(button);
            button.addActionListener(listener);
            button.setMargin( new java.awt.Insets(0,10,0,10));
            button.setPreferredSize(new java.awt.Dimension(70,20));
            widthMenu.add(button);
        }

        //////// Dash Pattern

        JMenu dashMenu = new JMenu(i18n.get(BasicStrokeEditorMenu.class, "Dash_Pattern", "Dash Pattern"));

        listener = new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                String command = ae.getActionCommand();
                try {
                    setDash(stringToDashArray(command));
                    resetStroke();
                } catch (NumberFormatException e) {
                }
            }
        };

        group = new ButtonGroup();

        String[] patterns = new String[] { NONE, "1.0 3.0", "3.0 3.0", "12.0 10.0",
                "12.0 10.0 6.0 10.0", "20.0 10.0", "20.0 10.0 6.0 10.0", "20.0 10.0 6.0 10.0 6.0 10.0" };

        String currentDash = dashArrayToString(getDash());
        for (i = 0; i < patterns.length; i++) {
            BasicStroke dashStroke = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, stringToDashArray(patterns[i]), 0.0f);
            ii = createIcon(dashStroke, 90, 10, true);

            button = new JRadioButtonMenuItem(" ", ii, currentDash.equals(patterns[i]));
            button.setActionCommand(patterns[i]);
            group.add(button);
            button.addActionListener(listener);
            button.setMargin( new java.awt.Insets(0,10,0,10));
            button.setPreferredSize(new java.awt.Dimension(110,20));
            dashMenu.add(button);
        }
View Full Code Here

Examples of javax.swing.ButtonGroup

            //          palette = new JPanel();
            //          palette.setLayout(new GridLayout(0, 1));

            // The Terrain Level selector
            JPanel modePanel = PaletteHelper.createPaletteJPanel("Tool Mode");
            ButtonGroup modes = new ButtonGroup();

            ActionListener al = new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    String ac = e.getActionCommand();
                    if (ac.equalsIgnoreCase(losCommand)) {
                        setMode(LOS);
                    } else {
                        setMode(PROFILE);
                    }
                }
            };

            JRadioButton profileModeButton = new JRadioButton("Profile");
            profileModeButton.addActionListener(al);
            profileModeButton.setActionCommand(profileCommand);
            JRadioButton losModeButton = new JRadioButton("LOS");
            losModeButton.addActionListener(al);
            losModeButton.setActionCommand(losCommand);

            modes.add(profileModeButton);
            modes.add(losModeButton);

            switch (mode) {
            case LOS:
                losModeButton.setSelected(true);
                break;
View Full Code Here

Examples of javax.swing.ButtonGroup

                currentDirection = ((OMAbstractLine) getGraphic()).getArrowHead().getArrowDirectionType();
            }
           
            int descDir = -1; // this description direction

            ButtonGroup group = new ButtonGroup();
            ImageIcon ii = createArrowIcon(new BasicStroke(1), 50, 20, descDir);
            JRadioButtonMenuItem button = new JRadioButtonMenuItem(ii, !doArrowHead);
            button.setActionCommand(String.valueOf(descDir));
            group.add(button);
            button.addActionListener(listener);
            arrowheadMenu.add(button);

            for (descDir = OMArrowHead.ARROWHEAD_DIRECTION_FORWARD; descDir <= OMArrowHead.ARROWHEAD_DIRECTION_BOTH; descDir++) {
                ii = createArrowIcon(new BasicStroke(1), 50, 20, descDir);
                button = new JRadioButtonMenuItem(ii, doArrowHead
                        && currentDirection == descDir);
                button.setActionCommand(String.valueOf(descDir));
                group.add(button);
                button.addActionListener(listener);
                arrowheadMenu.add(button);
            }
        }
        return arrowheadMenu;
View Full Code Here

Examples of javax.swing.ButtonGroup

            JToolBar faceTB = new GridBagToolBar();
//            int orientation = ((EditorLayer) getLayer()).getOrientation();
//            faceTB.setOrientation(orientation);

            if (bg == null) {
                bg = new ButtonGroup();
            }

            fillFaceToolBar(faceTB, bg);

            unpickBtn = new JToggleButton("", false);
View Full Code Here

Examples of javax.swing.ButtonGroup

    protected JComponent getToolWidgets() {
        JPanel iconBar = new JPanel();
        // this parameters should be read from properties!
        iconBar.setLayout(new GridLayout(2, 4));
        ButtonGroup bg = new ButtonGroup();
        JToggleButton btn = null;
        boolean setFirstButtonSelected = true;

        for (Iterator it = getLoaders(); it.hasNext();) {
            LoaderHolder lh = (LoaderHolder) it.next();
            String pName = lh.prettyName;
            EditToolLoader etl = lh.loader;
            ImageIcon icon = etl.getIcon(getEditableClassName(pName));
            btn = new JToggleButton(icon);
            btn.setMargin(new Insets(0, 0, 0, 0));
            btn.setToolTipText(pName);
            btn.setActionCommand(pName);
            btn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    setCurrentCreation(ae.getActionCommand());
                }
            });
            if (setFirstButtonSelected) {
                btn.setSelected(true);
                setCurrentCreation(pName);
                setFirstButtonSelected = false;
            }
            bg.add(btn);
            iconBar.add(btn);
        }
        return iconBar;
    }
View Full Code Here

Examples of javax.swing.ButtonGroup

        GridBagConstraints c = new GridBagConstraints();
        c.gridwidth = GridBagConstraints.REMAINDER;

        panel.setLayout(gridbag);

        ButtonGroup bg = new ButtonGroup();

        int toolbarCount = 0;
        boolean limitWidth = false;
        if (maxHorNumLoaderButtons >= 0) {
            limitWidth = true;
        }

        JToggleButton btn;
        JToolBar iconBar = null;
        boolean activeSet = false;
        for (Iterator it = getLoaders(); it.hasNext();) {

            if (toolbarCount == 0) {
                iconBar = new JToolBar();
                iconBar.setFloatable(false);
                gridbag.setConstraints(iconBar, c);
                panel.add(iconBar);
            }

            LoaderHolder lh = (LoaderHolder) it.next();
            String pName = lh.prettyName;
            EditToolLoader etl = lh.loader;
            ImageIcon icon = etl.getIcon(getEditableClassName(pName));

            btn = new JToggleButton(icon, !activeSet);
            btn.setToolTipText(pName);
            btn.setActionCommand(pName);
            btn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    setCurrentCreation(ae.getActionCommand());
                }
            });
            bg.add(btn);

            if (iconBar != null) {
                iconBar.add(btn);
            }
View Full Code Here

Examples of javax.swing.ButtonGroup

            ((GridBagLayout) panesPanel.getLayout()).invalidateLayout(panesPanel);
            panesPanel.removeAll();
        }

        if (bg == null) {
            bg = new ButtonGroup();
        }

        LinkedList panes = new LinkedList();
        LinkedList backgroundPanes = new LinkedList();
View Full Code Here

Examples of javax.swing.ButtonGroup

        //Create Backup Panel
        //**********************************************************
        JPanel panelModules = new JPanel();
        panelModules.setLayout(Layout.getGBL());
       
        final ButtonGroup buttonGroup = new ButtonGroup();
        class SelectModuleAction implements ItemListener {
            @Override
            public void itemStateChanged(ItemEvent ev) {
                String command = buttonGroup.getSelection().getActionCommand();
                selectedModule = Integer.parseInt(command);
            }
        }        
       
        DcLongTextField textHelp = ComponentFactory.getLongTextField();
        textHelp.setBorder(null);
        JScrollPane scroller = new JScrollPane(textHelp);
        scroller.setBorder(null);
        scroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
        textHelp.setEditable(false);
        textHelp.setText(help);
       
        int y = 0;
        int x = 0;
       
        for (DcModule module : modules) {
            ImageIcon icon = module.getIcon32() == null ? module.getIcon16() : module.getIcon32();
            icon = icon == null ? IconLibrary._icoModuleTypeProperty32 : icon;
            JRadioButton radioButton = ComponentFactory.getRadioButton(module.getLabel(), icon, "" + module.getIndex());
           
            radioButton.addActionListener(this);
            radioButton.addItemListener(new SelectModuleAction());
            buttonGroup.add(radioButton);
            panelModules.add(radioButton, Layout.getGBC( x, y++, 1, 1, 1.0, 1.0
                    ,GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
                     new Insets( 0, 5, 5, 5), 0, 0));
           
            if (y == 6) {
View Full Code Here

Examples of javax.swing.ButtonGroup

    }
   
    private void build() {
        setLayout(Layout.getGBL());
       
        final ButtonGroup bg = new ButtonGroup();
        class ModuleSelectionListener implements MouseListener {
            @Override
            public void mouseClicked(MouseEvent e) {}
            @Override
            public void mouseEntered(MouseEvent e) {}
            @Override
            public void mouseExited(MouseEvent e) {}
            @Override
            public void mousePressed(MouseEvent e) {}

            @Override
            public void mouseReleased(MouseEvent e) {
                String command = bg.getSelection().getActionCommand();
                module = Integer.parseInt(command);
                try {
                   
                    if (getWizard().isAtTheEnd())
                        getWizard().finish();
                    else
                        getWizard().next();
                   
                } catch (WizardException wi) {
                    DcSwingUtilities.displayWarningMessage(wi.getMessage());
                }
            }
        }

        int y = 0;
        int x = 0;
       
        for (DcModule module : DcModules.getModules()) {
            if (module.isSelectableInUI() && module.isTopModule()) {
                JRadioButton rb = ComponentFactory.getRadioButton(module.getLabel(), module.getIcon32(), "" + module.getIndex());
                rb.addMouseListener(new ModuleSelectionListener());
                bg.add(rb);
               
                components.put(module.getIndex(), rb);
               
                add(rb, Layout.getGBC( x, y++, 1, 1, 1.0, 1.0
                   ,GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
View Full Code Here

Examples of javax.swing.ButtonGroup

        return module;
    }
   
    private void build() {
        final ButtonGroup buttonGroup = new ButtonGroup();

        class ModuleTypeSelectionListener implements MouseListener {
            @Override
            public void mouseClicked(MouseEvent arg0) {}
            @Override
            public void mouseEntered(MouseEvent arg0) {}
            @Override
            public void mouseExited(MouseEvent arg0) {}
            @Override
            public void mousePressed(MouseEvent arg0) {}

            @Override
            public void mouseReleased(MouseEvent arg0) {
                String command = buttonGroup.getSelection().getActionCommand();
                type = Integer.parseInt(command);
                try {
                    getWizard().next();
                } catch (WizardException wi) {
                    DcSwingUtilities.displayWarningMessage(wi.getMessage());
                }           
            }
        }         
       
        setLayout(Layout.getGBL());
       
        JRadioButton rbPlainMod = ComponentFactory.getRadioButton(
                DcResources.getText("lblPlainModule"),  IconLibrary._icoModuleTypePlain, "" + _OTHERMODULE);
        JRadioButton rbMediaMod = ComponentFactory.getRadioButton(
                DcResources.getText("lblMediaModule"),  IconLibrary._icoModuleTypeMedia, "" + _MEDIAMODULE);
        JRadioButton rbPropertyMod = ComponentFactory.getRadioButton(
                DcResources.getText("lblPropertyModule"), IconLibrary._icoModuleTypeProperty32, "" + _PROPERTYMODULE);
        JRadioButton rbAssociateMod = ComponentFactory.getRadioButton(
                DcResources.getText("lblAssociateModule"), IconLibrary._icoModuleTypeAssociate, "" + _ASSOCIATEMODULE);
       
        rbPlainMod.addMouseListener(new ModuleTypeSelectionListener());
        rbMediaMod.addMouseListener(new ModuleTypeSelectionListener());
        rbPropertyMod.addMouseListener(new ModuleTypeSelectionListener());
        rbAssociateMod.addMouseListener(new ModuleTypeSelectionListener());
       
        buttonGroup.add(rbPlainMod);
        buttonGroup.add(rbMediaMod);
        buttonGroup.add(rbPropertyMod);
        buttonGroup.add(rbAssociateMod);

        add(rbPropertyMod,Layout.getGBC(0, 0, 1, 1, 1.0, 1.0
                ,GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
                 new Insets( 0, 5, 5, 5), 0, 0));       
        add(rbMediaMod, Layout.getGBC(0, 1, 1, 1, 1.0, 1.0
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.