01: /*
02: * (C) Copyright IBM Corp. 1998-2004. All Rights Reserved.
03: *
04: * The program is provided "as is" without any warranty express or
05: * implied, including the warranty of non-infringement and the implied
06: * warranties of merchantibility and fitness for a particular purpose.
07: * IBM will not be liable for any damages suffered by you as a result
08: * of using the Program. In no event will IBM be liable for any
09: * special, indirect or consequential damages or lost profits even if
10: * IBM has been advised of the possibility of their occurrence. IBM
11: * will not be liable for any third party claims against you.
12: */
13: package com.ibm.richtext.textapps;
14:
15: import com.ibm.richtext.styledtext.MConstText;
16: import com.ibm.richtext.styledtext.StyledText;
17: import com.ibm.richtext.textlayout.attributes.AttributeMap;
18: import com.ibm.richtext.awtui.TextFrame;
19:
20: import java.awt.Toolkit;
21:
22: import java.io.*;
23: import java.net.URL;
24: import java.util.ResourceBundle;
25:
26: public class BidiDemo {
27:
28: static final String COPYRIGHT = "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";
29: private static final AppCloser fgListener = new AppCloser();
30:
31: private static final String BUNDLE_NAME = "com.ibm.richtext.textapps.resources.Sample";
32:
33: public static void main(String[] args) {
34:
35: String docName;
36:
37: if (args.length == 0) {
38: docName = "default";
39: } else {
40: docName = args[0];
41: }
42:
43: openText(docName);
44: }
45:
46: private static void openText(String docName) {
47:
48: try {
49: ResourceBundle bundle = ResourceBundle
50: .getBundle(BUNDLE_NAME);
51:
52: Object document = bundle.getObject(docName + ".sample");
53: MConstText text;
54:
55: if (document instanceof String) {
56: text = new StyledText((String) document,
57: AttributeMap.EMPTY_ATTRIBUTE_MAP);
58: } else {
59: URL url = (URL) document;
60: ObjectInputStream in = new ObjectInputStream(url
61: .openStream());
62: text = (MConstText) in.readObject();
63: }
64:
65: String name = bundle.getString(docName + ".name");
66:
67: makeFrame(text, name);
68: } catch (Throwable t) {
69: t.printStackTrace();
70: }
71: }
72:
73: private static void makeFrame(MConstText text, String title) {
74:
75: TextFrame frame = new TextFrame(text, title, Toolkit
76: .getDefaultToolkit().getSystemClipboard());
77: frame.setSize(550, 700);
78: frame.show();
79: fgListener.listenToFrame(frame);
80: }
81: }
|