Subversion Repositories svn.mios

Rev

Rev 628 | Go to most recent revision | 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.Dimension;
5
import java.awt.Insets;
6
import java.awt.event.ActionEvent;
7
import java.awt.event.ActionListener;
8
 
290 rutgerv 9
import javax.swing.ImageIcon;
10
import javax.swing.JButton;
11
import javax.swing.JPopupMenu;
12
import javax.swing.JToolBar;
13
 
14
public class SplitButton extends JToolBar implements ActionListener {
15
    private JButton button, splitButton;
16
    private JPopupMenu dropMenu;
628 adamjking 17
 
18
    public SplitButton(JButton button, JPopupMenu dropMenu) {
290 rutgerv 19
        this.button = button;
628 adamjking 20
        this.dropMenu = dropMenu;
290 rutgerv 21
        setFloatable(false);
628 adamjking 22
        this.setBorderPainted(false);
290 rutgerv 23
        ImageIcon icon = ImageLoader.getImageIcon("pulldown.png");
24
        splitButton = new JButton();
25
        splitButton.setIcon(icon);
628 adamjking 26
        splitButton.addActionListener(this);
290 rutgerv 27
        splitButton.setFocusPainted(false);
628 adamjking 28
        splitButton.setMargin(new Insets(2, 0, 2, 0));
753 adamjking 29
        setOpaque(false);
290 rutgerv 30
        add(button);
31
        add(splitButton);
32
    }
628 adamjking 33
 
34
    public void actionPerformed(ActionEvent e) {
35
        if (e.getSource() == splitButton) {
36
            Component c = (Component) button;
37
            dropMenu.show(c, 0, c.getHeight());
290 rutgerv 38
        }
628 adamjking 39
    }
290 rutgerv 40
}