2 * (C) Copyright IBM Corp. 1998-2007. All Rights Reserved.
\r
4 * The program is provided "as is" without any warranty express or
\r
5 * implied, including the warranty of non-infringement and the implied
\r
6 * warranties of merchantibility and fitness for a particular purpose.
\r
7 * IBM will not be liable for any damages suffered by you as a result
\r
8 * of using the Program. In no event will IBM be liable for any
\r
9 * special, indirect or consequential damages or lost profits even if
\r
10 * IBM has been advised of the possibility of their occurrence. IBM
\r
11 * will not be liable for any third party claims against you.
\r
13 package com.ibm.richtext.awtui;
\r
15 import com.ibm.richtext.textpanel.MTextPanel;
\r
16 import com.ibm.richtext.textpanel.TextPanel;
\r
17 import com.ibm.richtext.styledtext.MConstText;
\r
19 import java.awt.BorderLayout;
\r
20 import java.awt.Frame;
\r
21 import java.awt.MenuBar;
\r
22 import java.awt.Toolkit;
\r
24 import java.awt.datatransfer.Clipboard;
\r
26 import java.awt.event.WindowAdapter;
\r
27 import java.awt.event.WindowEvent;
\r
30 * TextFrame is a Frame containing an editable TextPanel, a set of standard
\r
31 * menus, and a TabRuler. This class can be used as-is, but is
\r
32 * primarily intended to be a simple example of how to use the other classes
\r
34 * @see com.ibm.richtext.textpanel.TextPanel
\r
35 * @see AwtMenuBuilder
\r
38 public final class TextFrame extends Frame {
\r
43 private static final long serialVersionUID = 8436822743736641732L;
\r
44 //static final String COPYRIGHT =
\r
45 // "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
\r
46 private TextPanel fTextPanel;
\r
49 * Create a new TextFrame with no text and no title.
\r
51 public TextFrame() {
\r
54 init(null, Toolkit.getDefaultToolkit().getSystemClipboard());
\r
58 * Create a new TextFrame with no text and the given title.
\r
59 * @param title the title of this Frame
\r
61 public TextFrame(String title) {
\r
64 init(null, Toolkit.getDefaultToolkit().getSystemClipboard());
\r
68 * Create a new TextFrame with the given text and title, whose
\r
69 * TextPanel will use the given clipboard.
\r
70 * @param text the initial text in the TextPanel. If null the
\r
71 * TextPanel will initially be empty
\r
72 * @param title the title of this Frame
\r
73 * @param clipboard the Clipboard which the TextPanel will use.
\r
74 * If null the TextPanel will use a private Clipboard
\r
76 public TextFrame(MConstText text,
\r
78 Clipboard clipboard) {
\r
81 init(text, clipboard);
\r
84 private void init(MConstText text, Clipboard clipboard) {
\r
86 fTextPanel = new TextPanel(text, clipboard);
\r
88 TabRuler tabRuler = new TabRuler(14, 10, fTextPanel);
\r
92 setLayout(new BorderLayout());
\r
93 add(fTextPanel, "Center");
\r
94 add(tabRuler, "North");
\r
98 private void createMenus() {
\r
100 MenuBar menuBar = new MenuBar();
\r
102 AwtMenuBuilder.getInstance().createMenus(menuBar, fTextPanel, this);
\r
104 setMenuBar(menuBar);
\r
108 * Return the MTextPanel in this frame.
\r
110 public MTextPanel getTextPanel() {
\r
115 public static void main(String[] args) {
\r
117 TextFrame frame = new TextFrame();
\r
118 frame.addWindowListener(new WindowAdapter() {
\r
119 public void windowClosing(WindowEvent e) {
\r
123 frame.setSize(550, 700);
\r