View Javadoc

1   /*
2    * This file is part of NetPisteur.
3    * 
4    * Copyright 2001-2002 : Olivier CORNEC, David BOUANCHEAU, Loic LOPEZ,
5    *                       Gaetan BOUDARD, Mael LE LANNOU, Julien ROBINEAU
6    * 
7    * Copyright 2002-2003 : Olivier BRIENS, Simon DEZE, Florence FRIGOULT,
8    *                       Olivier JOURNEAULT, Francois MARTINIER, Damien RAUDE-MORVAN
9    * 
10   * Copyright 2004-2007 : Damien RAUDE-MORVAN
11   * 
12   * NetPisteur is free software; you can redistribute it and/or modify
13   * it under the terms of the GNU General Public License as published by
14   * the Free Software Foundation; either version 2 of the License, or
15   * (at your option) any later version.
16   *
17   * NetPisteur is distributed in the hope that it will be useful,
18   * but WITHOUT ANY WARRANTY; without even the implied warranty of
19   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20   * GNU General Public License for more details.
21   *
22   * You should have received a copy of the GNU General Public License
23   * along with NetPisteur; if not, write to the Free Software
24   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
25   *
26   */
27  package com.drazzib.netpisteur.ui;
28  
29  import javax.swing.JEditorPane;
30  import javax.swing.JFrame;
31  import javax.swing.JScrollPane;
32  
33  /**
34   * Class that allows to print the source in a popup
35   * 
36   * @author NetPisteur Team
37   */
38  public class SourceViewFrame extends JFrame {
39  
40  	/**
41  	 * 
42  	 */
43  	private static final long serialVersionUID = -7597760378091264491L;
44  
45  	/**
46  	 * sourcePanel : panel of print of the source
47  	 */
48  	private JEditorPane viewer;
49  
50  	private JScrollPane sourcePanel;
51  
52  	/**
53  	 * contructor that initialise the title of the popup
54  	 * 
55  	 * @param s
56  	 */
57  	public SourceViewFrame(String s) {
58  		super(s);
59  		this.sourcePanel = new JScrollPane();
60  	} // Source()
61  
62  	/**
63  	 * method that allows to print in the popup the String in parameter
64  	 * 
65  	 * @param source :
66  	 *            String that will be print in the popup
67  	 */
68  	public void setText(String source) {
69  		this.viewer = new JEditorPane();
70  		this.sourcePanel = new JScrollPane(this.viewer);
71  		getContentPane().add(this.sourcePanel);
72  		this.viewer.setContentType("text/plain");
73  		this.viewer.setText(source);
74  		this.setLocationRelativeTo(null);
75  	} // setText()
76  } // class Source