MCPcopy Index your code
hub / github.com/processing/processing / WebFrame

Method WebFrame

app/src/processing/app/ui/WebFrame.java:50–118  ·  view source on GitHub ↗
(File file, int width, Container panel)

Source from the content-addressed store, hash-verified

48
49
50 public WebFrame(File file, int width, Container panel) throws IOException {
51 // Need to use the URL version so that relative paths work for images
52 // https://github.com/processing/processing/issues/3494
53 URL fileUrl = file.toURI().toURL();
54 requestContentHeight(width, fileUrl);
55
56 editorPane = new JEditorPane();
57
58 // Title cannot be set until the page has loaded
59 editorPane.addPropertyChangeListener("page", new PropertyChangeListener() {
60 public void propertyChange(PropertyChangeEvent evt) {
61 Object title = editorPane.getDocument().getProperty("title");
62 if (title instanceof String) {
63 setTitle((String) title);
64 }
65 }
66 });
67
68 editorPane.setPage(fileUrl);
69 editorPane.setEditable(false);
70 // set height to something generic
71 editorPane.setPreferredSize(new Dimension(width, width));
72
73 //getContentPane().add(editorPane);
74 Container pain = getContentPane();
75 pain.setLayout(new BoxLayout(pain, BoxLayout.Y_AXIS));
76 pain.add(editorPane);
77 if (panel != null) {
78 pain.add(panel);
79 }
80
81 Toolkit.registerWindowCloseKeys(getRootPane(), new ActionListener() {
82 @Override
83 public void actionPerformed(ActionEvent e) {
84 handleClose();
85 }
86 });
87 Toolkit.setIcon(this);
88
89 editorKit = (HTMLEditorKit) editorPane.getEditorKit();
90 editorKit.setAutoFormSubmission(false);
91
92 editorPane.addHyperlinkListener(new HyperlinkListener() {
93 @Override
94 public void hyperlinkUpdate(HyperlinkEvent e) {
95 //System.out.println(e);
96 if (e instanceof FormSubmitEvent) {
97 String result = ((FormSubmitEvent) e).getData();
98 StringDict dict = new StringDict();
99 if (result.trim().length() != 0) {
100 String[] pairs = result.split("&");
101 for (String pair : pairs) {
102 //System.out.println("pair is " + pair);
103 String[] pieces = pair.split("=");
104 String attr = PApplet.urlDecode(pieces[0]);
105 String valu = PApplet.urlDecode(pieces[1]);
106 dict.set(attr, valu);
107 }

Callers

nothing calls this directly

Calls 6

requestContentHeightMethod · 0.95
setIconMethod · 0.95
setEditableMethod · 0.80
setLayoutMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected