38 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
39 |
import javax.swing.JSlider; |
import javax.swing.JSlider; |
40 |
import javax.swing.JToolBar; |
import javax.swing.JToolBar; |
|
import javax.swing.JToolTip; |
|
|
import javax.swing.Popup; |
|
|
import javax.swing.PopupFactory; |
|
41 |
|
|
42 |
import javax.swing.event.ChangeEvent; |
import javax.swing.event.ChangeEvent; |
43 |
import javax.swing.event.ChangeListener; |
import javax.swing.event.ChangeListener; |
47 |
import org.jsampler.event.SamplerAdapter; |
import org.jsampler.event.SamplerAdapter; |
48 |
import org.jsampler.event.SamplerEvent; |
import org.jsampler.event.SamplerEvent; |
49 |
|
|
50 |
|
import org.jsampler.view.std.StdUtils; |
51 |
|
|
52 |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
53 |
import static org.jsampler.view.classic.ClassicPrefs.preferences; |
import static org.jsampler.view.classic.ClassicPrefs.preferences; |
54 |
import static org.jsampler.view.std.StdPrefs.*; |
import static org.jsampler.view.std.StdPrefs.*; |
71 |
private final JButton btnTabMoveRight = new ToolbarButton(A4n.moveTab2Right); |
private final JButton btnTabMoveRight = new ToolbarButton(A4n.moveTab2Right); |
72 |
|
|
73 |
private final JLabel lVolume = new JLabel(Res.iconVolume22); |
private final JLabel lVolume = new JLabel(Res.iconVolume22); |
74 |
private final JSlider slVolume = new JSlider(0, 100); |
private final JSlider slVolume = StdUtils.createVolumeSlider(); |
|
private Popup popup = null; |
|
|
private final JToolTip tip = new JToolTip(); |
|
75 |
|
|
76 |
|
|
77 |
/** |
/** |
104 |
add(btnTabMoveLeft); |
add(btnTabMoveLeft); |
105 |
add(btnTabMoveRight); |
add(btnTabMoveRight); |
106 |
|
|
|
// Setting the tooltip size |
|
|
tip.setTipText(i18n.getLabel("ChannelsBar.volume", 1000)); |
|
|
tip.setMinimumSize(tip.getPreferredSize()); |
|
|
tip.setPreferredSize(tip.getPreferredSize()); // workaround for preserving that size |
|
|
tip.setComponent(slVolume); |
|
|
/////// |
|
|
|
|
107 |
int i = preferences().getIntProperty(MAXIMUM_MASTER_VOLUME); |
int i = preferences().getIntProperty(MAXIMUM_MASTER_VOLUME); |
108 |
slVolume.setMaximum(i); |
slVolume.setMaximum(i); |
109 |
String s = MAXIMUM_MASTER_VOLUME; |
String s = MAXIMUM_MASTER_VOLUME; |
126 |
}); |
}); |
127 |
|
|
128 |
updateVolume(); |
updateVolume(); |
|
|
|
|
slVolume.addMouseListener(new MouseAdapter() { |
|
|
public void |
|
|
mousePressed(MouseEvent e) { |
|
|
if(popup != null) { |
|
|
popup.hide(); |
|
|
popup = null; |
|
|
} |
|
|
|
|
|
Point p = slVolume.getLocationOnScreen(); |
|
|
PopupFactory pf = PopupFactory.getSharedInstance(); |
|
|
popup = pf.getPopup(slVolume, tip, p.x, p.y - 22); |
|
|
popup.show(); |
|
|
} |
|
|
|
|
|
public void |
|
|
mouseReleased(MouseEvent e) { |
|
|
if(popup != null) { |
|
|
popup.hide(); |
|
|
popup = null; |
|
|
} |
|
|
} |
|
|
}); |
|
129 |
} |
} |
130 |
|
|
131 |
private void |
private void |
132 |
setVolume() { |
setVolume() { |
133 |
int volume = slVolume.getValue(); |
int volume = slVolume.getValue(); |
134 |
String s = i18n.getLabel("ChannelsBar.volume", volume); |
String s = i18n.getLabel("ChannelsBar.volume", volume); |
|
slVolume.setToolTipText(s); |
|
|
lVolume.setToolTipText(s); |
|
|
tip.setTipText(s); |
|
|
tip.repaint(); |
|
135 |
|
|
136 |
if(slVolume.getValueIsAdjusting()) return; |
if(slVolume.getValueIsAdjusting()) return; |
137 |
|
|