import java.awt.Component;
import java.awt.Dimension;
import java.awt.Image;
+import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
popup = new BookPopup(Instance.getInstance().getLibrary(), informer);
actions = new BooksPanelActions(this, informer);
final JList6<BookInfo> list = new JList6<BookInfo>();
- data = new ListModel<BookInfo>(list, popup);
+ data = new ListModel<BookInfo>(list, popup,
+ new ListModel.TooltipCreator<BookInfo>() {
+ @Override
+ public Window generateTooltip(BookInfo book,
+ boolean undecorated) {
+ if (book != null && book.getMeta() != null) {
+ PropertiesFrame tooltip = new PropertiesFrame(
+ Instance.getInstance().getLibrary(),
+ book.getMeta());
+ tooltip.setUndecorated(undecorated);
+ return tooltip;
+ }
+
+ return null;
+ }
+ });
list.addMouseListener(new MouseAdapter() {
@Override
package be.nikiroo.fanfix_swing.gui;
import java.awt.BorderLayout;
+import java.awt.event.MouseListener;
import javax.swing.JDialog;
import javax.swing.JPanel;
int titleBarHeight = Math
.abs(getContentPane().getHeight() - getHeight());
- this.setSize(800, desc.getHeight() + titleBarHeight);
+ this.setSize(600, desc.getHeight() + titleBarHeight);
+ }
+
+ @Override
+ public synchronized void addMouseListener(MouseListener l) {
+ super.addMouseListener(l);
+ desc.addMouseListener(l);
}
}
import java.awt.BorderLayout;
import java.awt.Color;
+import java.awt.Component;
import java.awt.Font;
+import java.awt.event.MouseListener;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import javax.swing.BorderFactory;
private final int space = 10; // empty space for visual correctness
private final int hscroll = 10; // we reserve space at the bottom for a
// potential HScroll
+ private List<Component> listenables;
/**
* Create a new {@link PropertiesPanel}.
* the meta to describe
*/
public PropertiesPanel(BasicLibrary lib, MetaData meta) {
+ listenables = new ArrayList<Component>();
+
// Image
ImageIcon img = new ImageIcon(CoverImager.generateCoverImage(lib,
BookInfo.fromMeta(lib, meta)));
jKey.setEditable(false);
jKey.setLineWrap(false);
jKey.setBackground(trans);
+ listenables.add(jKey);
mainPanelKeys.add(jKey);
final JTextArea jValue = new JTextArea(desc.get(key));
jValue.setEditable(false);
jValue.setLineWrap(false);
jValue.setBackground(base);
+ listenables.add(jValue);
mainPanelValues.add(jValue);
}
// Add all
add(imgLabel, BorderLayout.WEST);
add(mainPanel, BorderLayout.CENTER);
+
+ listenables.add(imgLabel);
+ listenables.add(mainPanel);
+ listenables.add(mainPanelKeys);
+ listenables.add(mainPanelValues);
}
- /**
- * The invisible border size (multiply by 2 if you need the total width or
- * the total height).
- *
- * @return the invisible border thickness
- */
- public int getBorderThickness() {
- return space;
+ @Override
+ public synchronized void addMouseListener(MouseListener l) {
+ super.addMouseListener(l);
+
+ for (Component comp : listenables) {
+ comp.addMouseListener(l);
+ }
}
}