mirror of
https://gitlab.com/biskuteri-cafe/JKomasto2.git
synced 2024-11-20 07:24:50 +01:00
56 lines
835 B
Java
56 lines
835 B
Java
|
|
import javax.swing.JPanel;
|
|
import java.awt.Graphics;
|
|
|
|
class
|
|
PostComponent extends JPanel {
|
|
|
|
private String
|
|
author, time, text;
|
|
|
|
// ---%-@-%---
|
|
|
|
public void
|
|
setAuthor(String author)
|
|
{
|
|
assert author != null;
|
|
this.author = author;
|
|
}
|
|
|
|
public void
|
|
setTime(String time)
|
|
{
|
|
assert time != null;
|
|
this.time = time;
|
|
}
|
|
|
|
public void
|
|
setText(String text)
|
|
{
|
|
assert text != null;
|
|
this.text = text;
|
|
}
|
|
|
|
// - -%- -
|
|
|
|
protected void
|
|
paintComponent(Graphics g)
|
|
{
|
|
int lineHeight = 24;
|
|
|
|
g.drawString(author, 0, lineHeight);
|
|
|
|
g.drawString(text, 0, 2 * lineHeight);
|
|
}
|
|
|
|
// ---%-@-%---
|
|
|
|
PostComponent()
|
|
{
|
|
author = "Author";
|
|
time = "Time";
|
|
text = "This is a soft post..";
|
|
}
|
|
|
|
}
|