mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-25 09:18:51 -05:00
* make it look better (e.g. window shadows) by forcing heavy-weight windows
This commit is contained in:
parent
015f997ba2
commit
2dd24e53a7
@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
package net.sourceforge.tuned.ui;
|
package net.sourceforge.tuned.ui;
|
||||||
|
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
@ -17,104 +15,95 @@ import javax.swing.JSeparator;
|
|||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
|
|
||||||
public class ActionPopup extends JPopupMenu {
|
public class ActionPopup extends JPopupMenu {
|
||||||
|
|
||||||
protected final JLabel headerLabel = new JLabel();
|
protected final JLabel headerLabel = new JLabel();
|
||||||
protected final JLabel descriptionLabel = new JLabel();
|
protected final JLabel descriptionLabel = new JLabel();
|
||||||
protected final JLabel statusLabel = new JLabel();
|
protected final JLabel statusLabel = new JLabel();
|
||||||
|
|
||||||
protected final JPanel actionPanel = new JPanel(new MigLayout("nogrid, insets 0, fill"));
|
protected final JPanel actionPanel = new JPanel(new MigLayout("nogrid, insets 0, fill"));
|
||||||
|
|
||||||
|
|
||||||
public ActionPopup(String label, Icon icon) {
|
public ActionPopup(String label, Icon icon) {
|
||||||
headerLabel.setText(label);
|
headerLabel.setText(label);
|
||||||
headerLabel.setIcon(icon);
|
headerLabel.setIcon(icon);
|
||||||
headerLabel.setIconTextGap(5);
|
headerLabel.setIconTextGap(5);
|
||||||
|
|
||||||
actionPanel.setOpaque(false);
|
actionPanel.setOpaque(false);
|
||||||
|
|
||||||
statusLabel.setFont(statusLabel.getFont().deriveFont(10f));
|
statusLabel.setFont(statusLabel.getFont().deriveFont(10f));
|
||||||
statusLabel.setForeground(Color.GRAY);
|
statusLabel.setForeground(Color.GRAY);
|
||||||
|
|
||||||
setLayout(new MigLayout("nogrid, fill, insets 0"));
|
setLayout(new MigLayout("nogrid, fill, insets 0"));
|
||||||
|
|
||||||
add(headerLabel, "gapx 5px 5px, gapy 3px 1px, wrap 3px");
|
add(headerLabel, "gapx 5px 5px, gapy 3px 1px, wrap 3px");
|
||||||
add(new JSeparator(), "growx, wrap 1px");
|
add(new JSeparator(), "growx, wrap 1px");
|
||||||
add(actionPanel, "growx, wrap 0px");
|
add(actionPanel, "growx, wrap 0px");
|
||||||
add(new JSeparator(), "growx, wrap 0px");
|
add(new JSeparator(), "growx, wrap 0px");
|
||||||
add(statusLabel, "growx, h 11px!, gapx 3px, wrap 1px");
|
add(statusLabel, "growx, h 11px!, gapx 3px, wrap 1px");
|
||||||
|
|
||||||
|
// make it look better (e.g. window shadows) by forcing heavy-weight windows
|
||||||
|
setLightWeightPopupEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addDescription(JComponent component) {
|
public void addDescription(JComponent component) {
|
||||||
actionPanel.add(component, "gapx 4px, wrap 3px");
|
actionPanel.add(component, "gapx 4px, wrap 3px");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addAction(JComponent component) {
|
public void addAction(JComponent component) {
|
||||||
actionPanel.add(component, "gapx 12px 12px, growx, wrap");
|
actionPanel.add(component, "gapx 12px 12px, growx, wrap");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addSeparator() {
|
public void addSeparator() {
|
||||||
actionPanel.add(new JSeparator(), "growx, wrap 1px");
|
actionPanel.add(new JSeparator(), "growx, wrap 1px");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JMenuItem add(Action a) {
|
public JMenuItem add(Action a) {
|
||||||
LinkButton link = new LinkButton(a);
|
LinkButton link = new LinkButton(a);
|
||||||
|
|
||||||
// underline text
|
// underline text
|
||||||
link.setText(String.format("<html><nobr><u>%s</u></nobr></html>", link.getText()));
|
link.setText(String.format("<html><nobr><u>%s</u></nobr></html>", link.getText()));
|
||||||
|
|
||||||
// use rollover color
|
// use rollover color
|
||||||
link.setRolloverEnabled(false);
|
link.setRolloverEnabled(false);
|
||||||
link.setColor(link.getRolloverColor());
|
link.setColor(link.getRolloverColor());
|
||||||
|
|
||||||
// close popup when action is triggered
|
// close popup when action is triggered
|
||||||
link.addActionListener(closeListener);
|
link.addActionListener(closeListener);
|
||||||
|
|
||||||
addAction(link);
|
addAction(link);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
actionPanel.removeAll();
|
actionPanel.removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLabel(String label) {
|
public void setLabel(String label) {
|
||||||
headerLabel.setText(label);
|
headerLabel.setText(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
return headerLabel.getText();
|
return headerLabel.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setStatus(String string) {
|
public void setStatus(String string) {
|
||||||
statusLabel.setText(string);
|
statusLabel.setText(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getStatus() {
|
public String getStatus() {
|
||||||
return statusLabel.getText();
|
return statusLabel.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private final ActionListener closeListener = new ActionListener() {
|
private final ActionListener closeListener = new ActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user