biskuteri-cafe-JKomasto2/PostComponent.java
2021-07-15 18:37:03 -04:00

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..";
}
}