biskuteri-cafe-JKomasto2/ComposeWindow.java

87 lines
1.6 KiB
Java
Raw Normal View History

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 {
2021-07-17 11:46:27 +02:00
private Composition
composition;
// - -%- -
private ComposeComponent
display;
2021-07-17 13:17:14 +02:00
// - -%- -
private static final Composition
NULL_COMPOSITION = new Composition();
{
NULL_COMPOSITION.text = "This is a sample composition..!";
NULL_COMPOSITION.visibility = PostVisibility.PUBLIC;
NULL_COMPOSITION.replyToPostId = null;
}
2021-07-17 11:46:27 +02:00
// ---%-@-%---
public void
setComposition(Composition composition)
{
assert composition != null;
this.composition = composition;
}
// ---%-@-%---
ComposeWindow()
{
2021-07-16 11:46:17 +02:00
getContentPane().setPreferredSize(new Dimension(360, 270));
pack();
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
display = new ComposeComponent();
2021-07-17 12:03:59 +02:00
setContentPane(display);
}
}
class
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));
}
}