Laid out replies component.

This commit is contained in:
Snowyfox 2021-07-17 05:37:00 -04:00
parent cda0891525
commit b6e3add6cd
2 changed files with 66 additions and 6 deletions

View File

@ -13,8 +13,10 @@ JKomasto {
// ---%-@-%---
public
JKomasto()
{
new PostWindow().setVisible(true);
new TimelineWindow().setVisible(true);
new ComposeWindow().setVisible(true);
}

View File

@ -67,7 +67,8 @@ PostWindow extends JFrame {
menuBar.add(displayMenu);
setJMenuBar(menuBar);
setContentPane(postDisplay);
//setContentPane(postDisplay);
setContentPane(repliesDisplay);
}
}
@ -187,23 +188,80 @@ RepliesComponent extends JPanel {
Box bottom = Box.createHorizontalBox();
bottom.add(Box.createGlue());
bottom.add(prevPage);
bottom.add(Box.createHorizontalStrut(8));
bottom.add(pageLabel);
bottom.add(Box.createHorizontalStrut(8));
bottom.add(nextPage);
JPanel centre = new JPanel();
centre.setOpaque(false);
centre.setLayout(new GridLayout(0, 1, 0, 2));
for (int n = 8; n > 0; --n) {
String label = "Eggplant -%- A short reply..";
JButton reply = new JButton(label);
// We likely need a custom class..
ReplyPreviewComponent reply = new ReplyPreviewComponent();
reply.setAuthor("Eggplant");
reply.setText("bobofish..");
centre.add(reply);
}
setLayout(new BorderLayout(4, 4));
setLayout(new BorderLayout(0, 8));
add(centre, BorderLayout.CENTER);
add(bottom, BorderLayout.SOUTH);
setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
}
}
class
ReplyPreviewComponent extends JButton {
private String
author;
private String
text;
// ---%-@-%---
@Override
public void
setText(String text)
{
assert text != null;
this.text = text;
setText();
}
public void
setAuthor(String author)
{
assert author != null;
this.author = author;
setText();
}
// - -%- -
private void
setText()
{
StringBuilder text = new StringBuilder();
text.append(this.author);
text.append(" @ ");
text.append(this.text);
super.setText(text.toString());
}
protected void
paintComponent(Graphics g)
{
g.drawString(getText(), 8, 2 * getHeight() / 3);
}
// ---%-@-%---
ReplyPreviewComponent() { }
}