package be.nikiroo.fanfix_swing.gui;
import java.awt.BorderLayout;
+import java.awt.Point;
+import javax.swing.JDialog;
import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
-import be.nikiroo.fanfix.Instance;
import be.nikiroo.fanfix.bundles.StringIdGui;
import be.nikiroo.fanfix.data.MetaData;
import be.nikiroo.fanfix.data.Story;
*
* @author niki
*/
-public class PropertiesFrame extends JFrame {
+public class PropertiesFrame extends JDialog {
private static final long serialVersionUID = 1L;
+ private JPanel desc;
/**
* Create a new {@link PropertiesFrame}.
* the meta to describe
*/
public PropertiesFrame(BasicLibrary lib, MetaData meta) {
- setTitle(Instance.getInstance().getTransGui().getString(
- StringIdGui.TITLE_STORY, meta.getLuid(), meta.getTitle()));
-
- PropertiesPanel desc = new PropertiesPanel(lib, meta);
- setSize(800, (int) desc.getPreferredSize().getHeight()
- + 2 * desc.getBorderThickness());
+ setTitle(MainFrame.trans(StringIdGui.TITLE_STORY, meta.getLuid(),
+ meta.getTitle()));
+ desc = new PropertiesPanel(lib, meta);
setLayout(new BorderLayout());
add(desc, BorderLayout.NORTH);
+
+ this.setSize(800, desc.getHeight() + 0);
+ }
+
+ @Override
+ public void setVisible(boolean b) {
+ super.setVisible(b);
+
+ int titleBarHeight = Math
+ .abs(getContentPane().getHeight() - getHeight());
+
+ this.setSize(800, desc.getHeight() + titleBarHeight);
}
}
import be.nikiroo.fanfix.reader.BasicReader;
import be.nikiroo.fanfix_swing.gui.book.BookInfo;
import be.nikiroo.fanfix_swing.gui.utils.CoverImager;
+import be.nikiroo.utils.ui.UIUtils;
/**
* A panel displaying properties and other information of a {@link Story}.
*/
public class PropertiesPanel extends JPanel {
private static final long serialVersionUID = 1L;
- private final int space = 10;
+ 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
/**
* Create a new {@link PropertiesPanel}.
.setLayout(new BoxLayout(mainPanelValues, BoxLayout.Y_AXIS));
mainPanel.add(mainPanelKeys, BorderLayout.WEST);
- mainPanel.add(mainPanelValues, BorderLayout.CENTER);
+ mainPanel.add(UIUtils.scroll(mainPanelValues, true, false),
+ BorderLayout.CENTER);
Map<String, String> desc = BasicReader.getMetaDesc(meta);
imgLabel.setVerticalAlignment(JLabel.TOP);
// Borders
- mainPanelKeys.setBorder(
- BorderFactory.createEmptyBorder(space, space, space, space));
- mainPanelValues.setBorder(
- BorderFactory.createEmptyBorder(space, space, space, space));
- imgLabel.setBorder(BorderFactory.createEmptyBorder(0, space, space, 0));
+ mainPanelKeys.setBorder(BorderFactory.createEmptyBorder(space, space,
+ space + hscroll, space));
+ mainPanelValues.setBorder(BorderFactory.createEmptyBorder(space, space,
+ space + hscroll, space));
+ imgLabel.setBorder(
+ BorderFactory.createEmptyBorder(0, space, space + hscroll, 0));
// Add all
add(imgLabel, BorderLayout.WEST);