Search in sources :

Example 61 with JToggleButton

use of javax.swing.JToggleButton in project energy3d by concord-consortium.

the class MainPanel method getRoofButton.

private JToggleButton getRoofButton() {
    if (roofButton == null) {
        roofButton = new JToggleButton();
        roofButton.setIcon(new ImageIcon(getClass().getResource("icons/pyramid_roof.png")));
        roofButton.setToolTipText("Draw pyramid roof");
        roofButton.setFocusable(false);
        roofButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                SceneManager.getInstance().setOperation(roofCommand);
                ((Component) SceneManager.getInstance().getCanvas()).requestFocusInWindow();
            }
        });
        roofButton.addMouseListener(operationStickAndRefreshUponExit);
        addMouseOverEffect(roofButton);
    }
    return roofButton;
}
Also used : ImageIcon(javax.swing.ImageIcon) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 62 with JToggleButton

use of javax.swing.JToggleButton in project energy3d by concord-consortium.

the class MainPanel method getNoteButton.

public JToggleButton getNoteButton() {
    if (noteButton == null) {
        noteButton = new JToggleButton();
        noteButton.setToolTipText("Show note");
        noteButton.setIcon(new ImageIcon(MainPanel.class.getResource("icons/note.png")));
        noteButton.setFocusable(false);
        noteButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                MainPanel.getInstance().setNoteVisible(noteButton.isSelected());
                if (noteButton.isSelected()) {
                    getNoteTextArea().requestFocusInWindow();
                }
            }
        });
        addMouseOverEffect(noteButton);
    }
    return noteButton;
}
Also used : ImageIcon(javax.swing.ImageIcon) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent)

Example 63 with JToggleButton

use of javax.swing.JToggleButton in project Brino by BrinoOficial.

the class FileUtils method abrirFile.

public static void abrirFile(RSyntaxTextArea rSyntaxTextArea) {
    JFileChooser FC = new JFileChooser(BrinoDirectory);
    FC.addChoosableFileFilter(new FileFilter() {

        @Override
        public boolean accept(File file) {
            return file.getName().toUpperCase().contains(".BRPP") || file.isDirectory();
        }

        @Override
        public String getDescription() {
            return "Arquivos de Código Brino";
        }
    });
    for (Component i : FC.getComponents()) {
        try {
            boolean a = true;
            for (Component c : ((JPanel) i).getComponents()) {
                if (c.getClass().toString().equals("class javax.swing.plaf.metal.MetalFileChooserUI$1")) {
                    JComboBox jcom = (JComboBox) c;
                    jcom.setBackground(UIConstants.VERDE);
                    jcom.setForeground(Color.white);
                    jcom.setBorder(new BubbleBorder(UIConstants.VERDE));
                    for (int z = 0; z < jcom.getComponentCount(); z++) {
                        if (jcom.getComponent(z) instanceof JComponent) {
                            ((JComponent) jcom.getComponent(z)).setBorder(UIConstants.BORDAVAZIA);
                        }
                        if (jcom.getComponent(z) instanceof AbstractButton) {
                            ((AbstractButton) jcom.getComponent(z)).setBorderPainted(false);
                        }
                    }
                }
                if (c.getClass() == javax.swing.JLabel.class) {
                    c.setForeground(Color.WHITE);
                }
                if (c.getClass() == javax.swing.JPanel.class) {
                    for (Component d : ((JPanel) c).getComponents()) {
                        if (d.getClass() == javax.swing.JToggleButton.class) {
                            JToggleButton jtg = (JToggleButton) d;
                            if (jtg.getToolTipText().equals("List")) {
                                jtg.setIcon(list);
                                jtg.setSelectedIcon(listFocus);
                                jtg.setBackground(UIConstants.CINZA);
                                jtg.setBorder(UIConstants.BORDAVAZIA);
                                jtg.setRolloverIcon(listFocus);
                            } else {
                                jtg.setIcon(details);
                                jtg.setSelectedIcon(detailsFocus);
                                jtg.setBorder(UIConstants.BORDAVAZIA);
                                jtg.setBackground(UIConstants.CINZA);
                                jtg.setRolloverIcon(detailsFocus);
                            }
                        }
                        if (d.getClass() == javax.swing.JComboBox.class) {
                            JComboBox jcom = (JComboBox) d;
                            jcom.setBackground(UIConstants.VERDE);
                            jcom.setForeground(Color.white);
                            jcom.setBorder(new BubbleBorder(UIConstants.VERDE));
                            for (int z = 0; z < jcom.getComponentCount(); z++) {
                                if (jcom.getComponent(z) instanceof JComponent) {
                                    ((JComponent) jcom.getComponent(z)).setBorder(UIConstants.BORDAVAZIA);
                                }
                                if (jcom.getComponent(z) instanceof AbstractButton) {
                                    ((AbstractButton) jcom.getComponent(z)).setBorderPainted(false);
                                }
                            }
                        }
                        if (d.getClass() != javax.swing.JButton.class && d.getClass() != javax.swing.JComboBox.class)
                            d.setForeground(Color.WHITE);
                        else if (d.getClass() == javax.swing.JButton.class) {
                            // d.setBackground(UIConstants.VERDE);
                            JButton btn = (JButton) d;
                            if (btn.getText() != null) {
                                if (btn.getText().equals("Open")) {
                                    btn.setBorder(new BubbleBorder(UIConstants.VERDE));
                                    btn.setForeground(Color.white);
                                    btn.setText("Abrir");
                                    btn.setBackground(UIConstants.VERDE);
                                }
                                if (btn.getText().equals("Cancel")) {
                                    btn.setBorder(new BubbleBorder(UIConstants.CINZACLARO));
                                    btn.setForeground(Color.white);
                                    btn.setText("Cancelar");
                                    btn.setBackground(UIConstants.CINZACLARO);
                                }
                            }
                            if (btn.getActionCommand().equals("Go Up")) {
                                btn.setIcon(goup);
                                btn.setBorder(UIConstants.BORDAVAZIA);
                                btn.setBackground(UIConstants.CINZA);
                                btn.setRolloverIcon(goupFocus);
                            } else if (btn.getActionCommand().equals("New Folder")) {
                                btn.setIcon(newFolder);
                                btn.setBorder(UIConstants.BORDAVAZIA);
                                btn.setBackground(UIConstants.CINZA);
                                btn.setRolloverIcon(newFolderFocus);
                            } else if (btn.getToolTipText().equals("Home")) {
                                btn.setIcon(homeFolder);
                                btn.setBorder(UIConstants.BORDAVAZIA);
                                btn.setBackground(UIConstants.CINZA);
                                btn.setRolloverIcon(homeFolderFocus);
                            }
                        }
                        if (d.getClass() == javax.swing.JScrollPane.class) {
                            setScroll((JScrollPane) d);
                        }
                    }
                }
            }
        } catch (java.lang.ClassCastException e) {
            e.printStackTrace();
        }
    }
    FC.setAcceptAllFileFilterUsed(false);
    int res = FC.showOpenDialog(null);
    if (res == JFileChooser.APPROVE_OPTION) {
        rSyntaxTextArea.setText(null);
        setDiretorio(FC.getSelectedFile());
        try {
            String f = "";
            Scanner in = new Scanner(new File(getDiretorio().getAbsolutePath()));
            while (in.hasNext()) {
                String line = in.nextLine();
                // Highlight
                f += (line + "\n");
                System.out.println(line);
            }
            rSyntaxTextArea.setText(f);
            in.close();
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        }
    } else
        JOptionPane.showMessageDialog(null, "Voce nao selecionou nenhum diretorio.");
}
Also used : JPanel(javax.swing.JPanel) Scanner(java.util.Scanner) AbstractButton(javax.swing.AbstractButton) JComboBox(javax.swing.JComboBox) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) FileNotFoundException(java.io.FileNotFoundException) JFileChooser(javax.swing.JFileChooser) JToggleButton(javax.swing.JToggleButton) FileFilter(javax.swing.filechooser.FileFilter) JComponent(javax.swing.JComponent) Component(java.awt.Component) File(java.io.File) BubbleBorder(cc.brino.Brpp.IDEui.BubbleBorder)

Example 64 with JToggleButton

use of javax.swing.JToggleButton in project artisynth_core by artisynth.

the class GLViewerTest method createMenuButtons.

protected void createMenuButtons() {
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    JMenuBar menuBar = new JMenuBar();
    myQuitButton = new JButton("quit");
    myQuitButton.addActionListener(this);
    menuBar.add(myQuitButton);
    JMenu draggerMenu = new JMenu("dragger");
    myNoneItem = new JMenuItem("none");
    myNoneItem.addActionListener(this);
    draggerMenu.add(myNoneItem);
    myJackItem = new JMenuItem("jack");
    myJackItem.addActionListener(this);
    draggerMenu.add(myJackItem);
    myTranslatorItem = new JMenuItem("translator");
    myTranslatorItem.addActionListener(this);
    draggerMenu.add(myTranslatorItem);
    myRotatorItem = new JMenuItem("rotator");
    myRotatorItem.addActionListener(this);
    draggerMenu.add(myRotatorItem);
    menuBar.add(draggerMenu);
    myOrthoButton = new JToggleButton("ortho");
    myOrthoButton.setSelected(false);
    myOrthoButton.addActionListener(this);
    menuBar.add(myOrthoButton);
    setJMenuBar(menuBar);
}
Also used : JToggleButton(javax.swing.JToggleButton) JButton(javax.swing.JButton) JMenuItem(javax.swing.JMenuItem) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 65 with JToggleButton

use of javax.swing.JToggleButton in project chatty by chatty.

the class EmotesDialog method showPanel.

private void showPanel(EmotesPanel panel) {
    panel.update();
    cardLayout.show(emotesPanel, panel.label);
    for (JToggleButton button : buttons.keySet()) {
        if (buttons.get(button) == panel) {
            button.setSelected(true);
        }
    }
}
Also used : JToggleButton(javax.swing.JToggleButton)

Aggregations

JToggleButton (javax.swing.JToggleButton)179 ActionEvent (java.awt.event.ActionEvent)92 ActionListener (java.awt.event.ActionListener)90 ImageIcon (javax.swing.ImageIcon)76 Dimension (java.awt.Dimension)69 JPanel (javax.swing.JPanel)58 JButton (javax.swing.JButton)46 JLabel (javax.swing.JLabel)39 Point (java.awt.Point)29 JScrollPane (javax.swing.JScrollPane)19 BorderLayout (java.awt.BorderLayout)17 ChangeEvent (javax.swing.event.ChangeEvent)15 Insets (java.awt.Insets)14 ItemEvent (java.awt.event.ItemEvent)14 ChangeListener (javax.swing.event.ChangeListener)14 ItemListener (java.awt.event.ItemListener)13 Component (java.awt.Component)12 FlowLayout (java.awt.FlowLayout)12 BoxLayout (javax.swing.BoxLayout)12 JToolBar (javax.swing.JToolBar)12