Subversion Repositories svn.mios

Rev

Rev 753 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
290 rutgerv 1
package org.midibox.utils.gui;
2
 
628 adamjking 3
import java.awt.Component;
4
import java.awt.Insets;
5
import java.awt.event.ActionEvent;
6
import java.awt.event.ActionListener;
7
 
290 rutgerv 8
import javax.swing.ImageIcon;
9
import javax.swing.JButton;
10
import javax.swing.JPopupMenu;
11
import javax.swing.JToolBar;
12
 
13
public class SplitButton extends JToolBar implements ActionListener {
14
    private JButton button, splitButton;
15
    private JPopupMenu dropMenu;
628 adamjking 16
 
17
    public SplitButton(JButton button, JPopupMenu dropMenu) {
290 rutgerv 18
        this.button = button;
628 adamjking 19
        this.dropMenu = dropMenu;
290 rutgerv 20
        setFloatable(false);
628 adamjking 21
        this.setBorderPainted(false);
290 rutgerv 22
        ImageIcon icon = ImageLoader.getImageIcon("pulldown.png");
23
        splitButton = new JButton();
24
        splitButton.setIcon(icon);
628 adamjking 25
        splitButton.addActionListener(this);
290 rutgerv 26
        splitButton.setFocusPainted(false);
628 adamjking 27
        splitButton.setMargin(new Insets(2, 0, 2, 0));
753 adamjking 28
        setOpaque(false);
290 rutgerv 29
        add(button);
30
        add(splitButton);
31
    }
628 adamjking 32
 
33
    public void actionPerformed(ActionEvent e) {
34
        if (e.getSource() == splitButton) {
35
            Component c = (Component) button;
36
            dropMenu.show(c, 0, c.getHeight());
290 rutgerv 37
        }
628 adamjking 38
    }
290 rutgerv 39
}