| Revision 66,
1.1 KB
checked in by jdalbey, 9 years ago
(diff) |
|
Import Paramics Simulator.
|
| Rev | Line | |
|---|
| 1 | package paramsim.paramicssimulator.gui; |
|---|
| 2 | |
|---|
| 3 | import java.awt.Insets; |
|---|
| 4 | import java.text.SimpleDateFormat; |
|---|
| 5 | import java.util.Calendar; |
|---|
| 6 | |
|---|
| 7 | import javax.swing.JPanel; |
|---|
| 8 | import javax.swing.JScrollPane; |
|---|
| 9 | import javax.swing.JTextArea; |
|---|
| 10 | |
|---|
| 11 | /** |
|---|
| 12 | * A JPanel which records of a log of errors and messages written or recieved |
|---|
| 13 | * by the Paramics Simulator. |
|---|
| 14 | * |
|---|
| 15 | * @author Greg Eddington |
|---|
| 16 | **/ |
|---|
| 17 | @SuppressWarnings("serial") |
|---|
| 18 | public class ParamicsLogPanel extends JPanel |
|---|
| 19 | { |
|---|
| 20 | /** The timestamp format **/ |
|---|
| 21 | private static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); |
|---|
| 22 | |
|---|
| 23 | /** The log text area **/ |
|---|
| 24 | private JTextArea log; |
|---|
| 25 | |
|---|
| 26 | /** Constructor **/ |
|---|
| 27 | public ParamicsLogPanel() |
|---|
| 28 | { |
|---|
| 29 | log = new JTextArea(); |
|---|
| 30 | log.setColumns(35); |
|---|
| 31 | log.setLineWrap(true); |
|---|
| 32 | log.setRows(24); |
|---|
| 33 | log.setWrapStyleWord(true); |
|---|
| 34 | log.setEditable(false); |
|---|
| 35 | log.setText(""); |
|---|
| 36 | log.setMargin(new Insets(0, 10, 0, 10)); |
|---|
| 37 | JScrollPane logPane = new JScrollPane(log); |
|---|
| 38 | add(logPane); |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | /** |
|---|
| 42 | * Write a string appended to the end of the log. |
|---|
| 43 | * |
|---|
| 44 | * @param message |
|---|
| 45 | */ |
|---|
| 46 | public void write(String message) |
|---|
| 47 | { |
|---|
| 48 | log.setText(log.getText() + sdf.format(Calendar.getInstance().getTime()) + ":\n" + |
|---|
| 49 | message + "\n\n"); |
|---|
| 50 | } |
|---|
| 51 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.