Subversion Repositories svn.mios

Rev

Rev 290 | Rev 753 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 290 Rev 628
Line 1... Line 1...
1
package org.midibox.utils.gui;
1
package org.midibox.utils.gui;
-
 
2
-
 
3
import java.awt.Component;
-
 
4
import java.awt.Dimension;
-
 
5
import java.awt.Insets;
-
 
6
import java.awt.event.ActionEvent;
-
 
7
import java.awt.event.ActionListener;
2
8
3
import javax.swing.ImageIcon;
9
import javax.swing.ImageIcon;
4
import javax.swing.JButton;
10
import javax.swing.JButton;
5
import javax.swing.JPanel;
-
 
6
import javax.swing.JPopupMenu;
11
import javax.swing.JPopupMenu;
7
import javax.swing.JToolBar;
12
import javax.swing.JToolBar;
8
import java.awt.BorderLayout;
-
 
9
import java.awt.Dimension;
-
 
10
import java.awt.event.*;
-
 
11
import java.awt.Component;
-
 
12
import java.awt.Insets;
-
 
13
13
14
public class SplitButton extends JToolBar implements ActionListener {
14
public class SplitButton extends JToolBar implements ActionListener {
15
    private JButton button, splitButton;
15
    private JButton button, splitButton;
16
    private JPopupMenu dropMenu;
16
    private JPopupMenu dropMenu;
17
   
17
Line 23... Line 23...
23
        ImageIcon icon = ImageLoader.getImageIcon("pulldown.png");
23
        ImageIcon icon = ImageLoader.getImageIcon("pulldown.png");
24
        splitButton = new JButton();
24
        splitButton = new JButton();
25
        splitButton.setIcon(icon);
25
        splitButton.setIcon(icon);
26
        splitButton.addActionListener(this);   
26
        splitButton.addActionListener(this);
27
        splitButton.setFocusPainted(false);
27
        splitButton.setFocusPainted(false);
28
        splitButton.setPreferredSize(new Dimension(icon.getIconWidth(), splitButton.getPreferredSize().height));
28
        splitButton.setPreferredSize(new Dimension(icon.getIconWidth(),
-
 
29
                splitButton.getPreferredSize().height));
29
        splitButton.setMargin(new Insets(2,0,2,0));
30
        splitButton.setMargin(new Insets(2, 0, 2, 0));
30
        setMargin(new Insets(-1,-2,-3,-2));
31
        setMargin(new Insets(-1, -2, -3, -2));
31
        add(button);
32
        add(button);
32
        add(splitButton);
33
        add(splitButton);
33
    }
34
    }
-
 
35
34
    public void actionPerformed(ActionEvent e) {
36
    public void actionPerformed(ActionEvent e) {
35
        if (e.getSource()==splitButton) {
37
        if (e.getSource() == splitButton) {
36
            Component c = (Component)button;
38
            Component c = (Component) button;
37
            dropMenu.show(c, 0, c.getHeight());
39
            dropMenu.show(c, 0, c.getHeight());
38
        }
40
        }
39
    }
41
    }
40
}
42
}
41
-
 
42
-