1
2 package org.xrn.gui;
3
4 import java.awt.Color;
5 import java.awt.FlowLayout;
6 import java.awt.Font;
7 import java.awt.event.ActionEvent;
8 import java.awt.event.ActionListener;
9
10 import javax.swing.JButton;
11 import javax.swing.JComponent;
12 import javax.swing.JPanel;
13 import javax.swing.JScrollPane;
14 import javax.swing.JTextPane;
15 import javax.swing.border.TitledBorder;
16
17 /***
18 *
19 * The panel to show the help messages
20 * @author Carsten Maneg
21 * Date Nov 16, 2004
22 * Time 10:37:17 PM
23 */
24 public class HelpPanel extends JPanel implements ActionListener{
25 private Font schriftTyp;
26
27 private JTextPane helpTextPane;
28 private JScrollPane scrollPane;
29
30 private JButton radierenAS;
31
32 private String output = "";
33 private final String trades = "Sending trades needs time !" + '\n' + "Wait a moment after start button was pushed." + '\n' + '\n';
34 private final String helpText = "In the future the help will be shown here !";
35
36 private final String aboutText = "This tool was made by Edouard Mercier & Carsten Maneg !";
37
38 /***
39 *
40 * @param eigentuemer
41 * @param topic
42 */
43 public HelpPanel( JPanel eigentuemer, String topic ){
44 super( new FlowLayout( FlowLayout.LEFT ) );
45 setBorder( new TitledBorder( "" ) );
46 setLayout( null );
47
48 helpTextPane = new JTextPane();
49 helpTextPane.setEditable( false );
50
51 if( eigentuemer instanceof HelpWindow ){
52 schriftTyp = new Font( "Arial", Font.PLAIN, 12 );
53 setFont( schriftTyp );
54 helpTextPane.setFont( schriftTyp );
55 resetInputFields();
56 if( topic.equals( "showHelp" ) ){
57 helpTextPane.setText( helpText );
58 }
59 if( topic.equals( "aboutTool" ) ){
60 helpTextPane.setText( aboutText );
61 }
62 setOutput_Size( 2 );
63 }
64 }
65
66 /***
67 * Add the component to the panel.
68 * @param c
69 * @param x0
70 * @param y0
71 * @param breite
72 * @param hoehe
73 */
74 public void dlgObjHinzufuegen( JComponent c, int x0, int y0, int breite, int hoehe ){
75 c.setBounds( x0, y0, breite, hoehe );
76 c.setForeground( Color.black );
77 add(c);
78 }
79
80 /***
81 * Handle the button event
82 */
83 public void actionPerformed( ActionEvent e ){
84
85 if ( e.getSource() == radierenAS ){
86
87 resetInputFields();
88 }
89 }
90
91 /***
92 * Reset (clear) the field
93 *
94 */
95 public void resetInputFields( ){
96
97 output = "";
98 helpTextPane.setText( "" );
99 }
100
101 /***
102 *
103 * @param i
104 */
105 public void setOutput_Size( int i ){
106
107 if( i==1 ){
108 scrollPane = new JScrollPane( helpTextPane );
109 dlgObjHinzufuegen( scrollPane, 25, 25, 350, 400 );
110 }
111 if( i==2 ){
112 scrollPane = new JScrollPane( helpTextPane );
113 dlgObjHinzufuegen( scrollPane, 25, 25, 650, 450 );
114 }
115 }
116
117 /***
118 * Write the text to the textPane
119 * @param text
120 */
121 public void writeText( String text ){
122
123 output = output + text;
124 helpTextPane.setText( output );
125 }
126 }