Changeset 47 in tmcsimulator for trunk/src/tmcsim/paramicslog/gui
- Timestamp:
- 06/28/2016 02:25:42 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/paramicslog/gui/ParamicsLogGUI.java
r2 r47 1 1 package tmcsim.paramicslog.gui; 2 2 3 import javax.swing.*;4 3 import java.awt.event.WindowEvent; 5 4 import java.util.*; 5 import javax.swing.*; 6 6 7 7 /** 8 * The UI for ParamicsLog. 8 * The UI for ParamicsLog. 9 * 9 10 * @author Nathaniel Lehrer 10 11 * @version 11 12 */ 12 public class ParamicsLogGUI extends JFrame implements Observer { 13 public class ParamicsLogGUI extends JFrame implements Observer 14 { 13 15 14 /** The static instance */ 16 /** 17 * The static instance 18 */ 15 19 private static ParamicsLogGUI instance = new ParamicsLogGUI(); 20 /** 21 * The text area to display the log in 22 */ 23 private JTextArea textArea; 16 24 17 /** The text area to display the log in */18 private JTextArea textArea;19 20 /** Creates an instance of this class */21 public ParamicsLogGUI(){22 25 /** 26 * Creates an instance of this class 27 */ 28 public ParamicsLogGUI() 29 { 30 23 31 setupGUI(); 24 32 } 25 26 /** Creates the UI */ 33 34 /** 35 * Creates the UI 36 */ 27 37 private void setupGUI() 28 38 { 29 try { 39 try 40 { 30 41 UIManager.setLookAndFeel( 31 UIManager.getSystemLookAndFeelClassName()); 32 } catch (Exception e) { 42 UIManager.getSystemLookAndFeelClassName()); 43 } catch (Exception ex) 44 { 45 System.out.println(ex.getMessage()); 33 46 System.err.println("Couldn't use system look and feel."); 34 47 } 35 36 this.addWindowListener(new java.awt.event.WindowAdapter() {37 48 49 this.addWindowListener(new java.awt.event.WindowAdapter() 50 { 38 51 public void windowClosing(WindowEvent e) 39 52 { … … 41 54 } 42 55 }); 43 44 56 57 45 58 setTitle("Paramics Log"); 46 59 47 60 textArea = new JTextArea(); 48 61 textArea.setColumns(60); 49 62 textArea.setRows(30); 50 63 JScrollPane scrollPane = new JScrollPane(textArea); 51 64 52 65 getContentPane().add(scrollPane); 53 66 54 67 } 55 56 /** Shows the UI window */ 68 69 /** 70 * Shows the UI window 71 */ 57 72 public void display() 58 73 { … … 62 77 63 78 /** 64 * Updates the text area. If the observable class given is of type ParamicsLog then 65 * the log entries are displayed. 79 * Updates the text area. If the observable class given is of type 80 * ParamicsLog then the log entries are displayed. 81 * 66 82 * @param o The model for this viewer. 67 83 * @param arg An argument that is not used. … … 72 88 { 73 89 textArea.setText(((tmcsim.paramicslog.ParamicsLog) o).getLog()); 74 } 90 } 75 91 76 92 repaint(); 77 93 } 78 94 79 95 /** 80 96 * Accessor for the instance of ParamicsLogGUI. 97 * 81 98 * @return The instance of ParamicsLogGUI. 82 99 */ 83 public static ParamicsLogGUI getInstance() { 100 public static ParamicsLogGUI getInstance() 101 { 84 102 return instance; 85 103 } 86 87 104 }
Note: See TracChangeset
for help on using the changeset viewer.
