mirror of
https://gitlab.com/biskuteri-cafe/JKomasto2.git
synced 2024-11-20 05:14:50 +01:00
Laid out timeline and compose windows.
Used GridBagLayout for the first time..!
This commit is contained in:
parent
7defacfb34
commit
cda0891525
@ -1,6 +1,12 @@
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BorderFactory;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
|
||||
class
|
||||
ComposeWindow extends JFrame {
|
||||
@ -25,4 +31,31 @@ ComposeWindow extends JFrame {
|
||||
|
||||
|
||||
class
|
||||
ComposeComponent extends JPanel { }
|
||||
ComposeComponent extends JPanel {
|
||||
|
||||
private JTextArea
|
||||
text;
|
||||
|
||||
private JButton
|
||||
submit;
|
||||
|
||||
// ---%-@-%---
|
||||
|
||||
ComposeComponent()
|
||||
{
|
||||
text = new JTextArea();
|
||||
|
||||
submit = new JButton("Submit");
|
||||
|
||||
Box bottom = Box.createHorizontalBox();
|
||||
bottom.add(Box.createGlue());
|
||||
bottom.add(submit);
|
||||
|
||||
setLayout(new BorderLayout(0, 8));
|
||||
add(text, BorderLayout.CENTER);
|
||||
add(bottom, BorderLayout.SOUTH);
|
||||
|
||||
setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ JKomasto {
|
||||
|
||||
JKomasto()
|
||||
{
|
||||
new PostWindow().setVisible(true);
|
||||
new TimelineWindow().setVisible(true);
|
||||
new ComposeWindow().setVisible(true);
|
||||
}
|
||||
|
||||
// - -%- -
|
||||
|
@ -2,11 +2,19 @@
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BorderFactory;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
class
|
||||
TimelineWindow extends JFrame {
|
||||
@ -27,8 +35,7 @@ TimelineWindow extends JFrame {
|
||||
pack();
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
|
||||
display = new TimelineComponent();
|
||||
setContentPane(display);
|
||||
setContentPane(display = new TimelineComponent());
|
||||
}
|
||||
|
||||
}
|
||||
@ -38,10 +45,52 @@ TimelineWindow extends JFrame {
|
||||
class
|
||||
TimelineComponent extends JPanel {
|
||||
|
||||
private JButton
|
||||
next, prev;
|
||||
|
||||
private JLabel
|
||||
pageLabel;
|
||||
|
||||
private final List<PreviewComponent>
|
||||
previews = new ArrayList<>();
|
||||
|
||||
// ---%-@-%---
|
||||
|
||||
TimelineComponent()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
add(new PreviewComponent());
|
||||
add(centre, BorderLayout.CENTER);
|
||||
add(bottom, BorderLayout.SOUTH);
|
||||
|
||||
setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user