2021-07-16 00:37:03 +02:00
|
|
|
|
2021-07-16 01:07:23 +02:00
|
|
|
import javax.swing.JFrame;
|
|
|
|
import javax.swing.JPanel;
|
2021-07-16 00:37:03 +02:00
|
|
|
import javax.swing.JComponent;
|
2021-07-17 11:06:50 +02:00
|
|
|
import javax.swing.JButton;
|
2021-07-16 00:37:03 +02:00
|
|
|
import javax.swing.JLabel;
|
|
|
|
import javax.swing.Box;
|
2021-07-17 11:06:50 +02:00
|
|
|
import javax.swing.BorderFactory;
|
2021-07-16 00:37:03 +02:00
|
|
|
import java.awt.BorderLayout;
|
2021-07-17 11:06:50 +02:00
|
|
|
import java.awt.GridBagLayout;
|
|
|
|
import java.awt.GridBagConstraints;
|
|
|
|
import java.awt.FlowLayout;
|
2021-07-16 00:37:03 +02:00
|
|
|
import java.awt.Font;
|
2021-07-16 11:46:17 +02:00
|
|
|
import java.awt.Dimension;
|
2021-07-17 11:06:50 +02:00
|
|
|
import java.awt.Insets;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.ArrayList;
|
2021-07-16 00:37:03 +02:00
|
|
|
|
2021-07-16 01:07:23 +02:00
|
|
|
class
|
|
|
|
TimelineWindow extends JFrame {
|
|
|
|
|
2021-07-16 11:46:17 +02:00
|
|
|
private Timeline
|
|
|
|
timeline;
|
|
|
|
|
|
|
|
// - -%- -
|
|
|
|
|
2021-07-16 01:07:23 +02:00
|
|
|
private TimelineComponent
|
|
|
|
display;
|
|
|
|
|
|
|
|
// ---%-@-%---
|
|
|
|
|
|
|
|
TimelineWindow()
|
|
|
|
{
|
2021-07-16 11:46:17 +02:00
|
|
|
getContentPane().setPreferredSize(new Dimension(300, 400));
|
|
|
|
pack();
|
|
|
|
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
|
|
|
|
2021-07-17 11:06:50 +02:00
|
|
|
setContentPane(display = new TimelineComponent());
|
2021-07-16 01:07:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class
|
|
|
|
TimelineComponent extends JPanel {
|
|
|
|
|
2021-07-17 11:06:50 +02:00
|
|
|
private JButton
|
|
|
|
next, prev;
|
|
|
|
|
|
|
|
private JLabel
|
|
|
|
pageLabel;
|
|
|
|
|
|
|
|
private final List<PreviewComponent>
|
|
|
|
previews = new ArrayList<>();
|
|
|
|
|
|
|
|
// ---%-@-%---
|
|
|
|
|
2021-07-16 01:07:23 +02:00
|
|
|
TimelineComponent()
|
|
|
|
{
|
2021-07-17 11:06:50 +02:00
|
|
|
prev = new JButton("<");
|
|
|
|
next = new JButton(">");
|
|
|
|
|
|
|
|
pageLabel = new JLabel("0 / 0");
|
|
|
|
|
|
|
|
Box bottom = Box.createHorizontalBox();
|
|
|
|
bottom.add(Box.createGlue());
|
|
|
|
bottom.add(prev);
|
|
|
|
bottom.add(Box.createHorizontalStrut(8));
|
|
|
|
bottom.add(pageLabel);
|
|
|
|
bottom.add(Box.createHorizontalStrut(8));
|
|
|
|
bottom.add(next);
|
|
|
|
|
|
|
|
JPanel centre = new JPanel();
|
|
|
|
centre.setOpaque(false);
|
|
|
|
centre.setLayout(new GridBagLayout());
|
|
|
|
GridBagConstraints constraints = new GridBagConstraints();
|
|
|
|
constraints.fill = GridBagConstraints.HORIZONTAL;
|
|
|
|
constraints.gridx = 0;
|
|
|
|
constraints.weightx = 1;
|
|
|
|
constraints.insets = new Insets(4, 0, 4, 0);
|
|
|
|
for (int n = 8; n > 0; --n)
|
|
|
|
{
|
|
|
|
PreviewComponent preview = new PreviewComponent();
|
|
|
|
centre.add(preview, constraints);
|
|
|
|
previews.add(preview);
|
|
|
|
}
|
|
|
|
|
2021-07-16 01:07:23 +02:00
|
|
|
setLayout(new BorderLayout());
|
2021-07-17 11:06:50 +02:00
|
|
|
add(centre, BorderLayout.CENTER);
|
|
|
|
add(bottom, BorderLayout.SOUTH);
|
|
|
|
|
|
|
|
setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
|
2021-07-16 01:07:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-07-16 00:37:03 +02:00
|
|
|
class
|
|
|
|
PreviewComponent extends JComponent {
|
|
|
|
|
|
|
|
private JLabel
|
|
|
|
topLeft, topRight, bottom;
|
|
|
|
|
|
|
|
// ---%-@-%---
|
|
|
|
|
|
|
|
public void
|
|
|
|
setTopLeft(String text) { topLeft.setText(text); }
|
|
|
|
|
|
|
|
public void
|
|
|
|
setTopRight(String text) { topRight.setText(text); }
|
|
|
|
|
|
|
|
public void
|
|
|
|
setBottom(String text) { bottom.setText(text); }
|
|
|
|
|
|
|
|
// ---%-@-%---
|
|
|
|
|
|
|
|
public
|
|
|
|
PreviewComponent()
|
|
|
|
{
|
|
|
|
Font font;
|
|
|
|
|
|
|
|
topLeft = new JLabel("Top left");
|
|
|
|
font = topLeft.getFont();
|
|
|
|
topLeft.setFont(font.deriveFont(Font.PLAIN, 12f));
|
|
|
|
setOpaque(false);
|
|
|
|
|
|
|
|
topRight = new JLabel("Top right");
|
|
|
|
topRight.setHorizontalAlignment(JLabel.RIGHT);
|
|
|
|
font = topRight.getFont();
|
|
|
|
topRight.setFont(font.deriveFont(Font.ITALIC, 12f));
|
|
|
|
setOpaque(false);
|
|
|
|
|
|
|
|
bottom = new JLabel("Bottom");
|
|
|
|
font = bottom.getFont();
|
|
|
|
bottom.setFont(font.deriveFont(Font.PLAIN, 16f));
|
|
|
|
bottom.setOpaque(false);
|
|
|
|
|
|
|
|
Box top = Box.createHorizontalBox();
|
|
|
|
top.add(topLeft);
|
|
|
|
top.add(Box.createGlue());
|
|
|
|
top.add(topRight);
|
|
|
|
|
|
|
|
setLayout(new BorderLayout());
|
|
|
|
add(top, BorderLayout.NORTH);
|
|
|
|
add(bottom, BorderLayout.SOUTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|