-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLogWindow.java
87 lines (75 loc) · 2.83 KB
/
LogWindow.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
/**
* Instance tridy {@code LogWindow} predstavuji zaznamove okno udalosti.
*
* @author kolovsky
* @author jmacura
* @version 1.00.000
*/
public class LogWindow extends JFrame implements Runnable
{
//== PROMeNNe ATRIBUTY INSTANCi ============================================
private final JTextArea ta;
//== KONSTRUKTORY A TOVaRNi METODY =========================================
/**
* Vytvori nove okno s textovym polem pro zaznamy a s posuvnikem.
*/
public LogWindow()
{
this.setTitle("PT_SP: Event logging");
//content = new JPanel(null);
//content.setSize(new Dimension(500,300));
//content.setBackground(new Color(250,250,250));
//JScrollPane jsp = new JScrollPane(editable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
//jsp.createVerticalScrollBar();
//content.add(editable);
//content.add(jsp);*/
ta = new JTextArea("EVENTS:");
ta.setBackground(new Color(250,250,250));
ta.setForeground(new Color(0,0,0));
ta.setFont(new Font("couriernew",0,10));
ta.setLineWrap(true);
ta.setAutoscrolls(true);
ta.setEnabled(true);
ta.setVisible(true);
//content.add(ta);
JScrollPane jsp = new JScrollPane(ta, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
//jsp.setPreferredSize(new Dimension(500,300));
this.add(jsp);
//this.add(content);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
//this.setLocation(new Point(200,-200));
//this.setLocationRelativeTo(Core.menu);
//this.setPreferredSize(new Dimension(500,400));
}
//== OSTATNi NESOUKROMe METODY INSTANCi ====================================
/**
* Pripoji zadany retezec na konec stavajiciho zapisu v okne.
* @param s Retezec, ktery se ma vypsat do okna.
*/
public synchronized void log(String s)
{
ta.append("\n" + s);
}
/**
* Nastavi velikost okna, vypocte pozici pro zobrazeni a vykresli okno na obrazovce.
*/
@Override
public synchronized void run()
{
this.setPreferredSize(new Dimension(500,500));
this.pack();
//Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
//Point newLoc = new Point((screenSize.width / 4) + 300, screenSize.height / 2);
Point mLoc = Core.menu.getLocationOnScreen();
Point newLoc = new Point (mLoc.x + 300, mLoc.y);
this.setLocation(newLoc);
this.setVisible(true);
}
}