Java Code Examples for javax.swing.text.StyledEditorKit

The following examples show how to use javax.swing.text.StyledEditorKit. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: openAGV   Source File: ButtonFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static JButton createFontStyleBoldButton(DrawingEditor editor) {
  JButton button = new JButton();
  button.setIcon(ImageDirectory.getImageIcon("/toolbar/attributeFontBold.png"));
  button.setText(null);
  button.setToolTipText(BUNDLE.getString("buttonFactory.button_fontStyleBold.tooltipText"));
  button.setFocusable(false);

  AbstractAction action
      = new AttributeToggler<>(editor,
                               AttributeKeys.FONT_BOLD,
                               Boolean.TRUE,
                               Boolean.FALSE,
                               new StyledEditorKit.BoldAction());
  action.putValue(ActionUtil.UNDO_PRESENTATION_NAME_KEY,
                  BUNDLE.getString("buttonFactory.action_fontStyleBold.undo.presentationName"));
  button.addActionListener(action);

  return button;
}
 
Example 2
Source Project: openAGV   Source File: ButtonFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static JButton createFontStyleItalicButton(DrawingEditor editor) {
  JButton button = new JButton();
  button.setIcon(ImageDirectory.getImageIcon("/toolbar/attributeFontItalic.png"));
  button.setText(null);
  button.setToolTipText(BUNDLE.getString("buttonFactory.button_fontStyleItalic.tooltipText"));
  button.setFocusable(false);

  AbstractAction action
      = new AttributeToggler<>(editor,
                               AttributeKeys.FONT_ITALIC,
                               Boolean.TRUE,
                               Boolean.FALSE,
                               new StyledEditorKit.BoldAction());
  action.putValue(ActionUtil.UNDO_PRESENTATION_NAME_KEY,
                  BUNDLE.getString("buttonFactory.action_fontStyleItalic.undo.presentationName"));
  button.addActionListener(action);

  return button;
}
 
Example 3
Source Project: openAGV   Source File: ButtonFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static JButton createFontStyleUnderlineButton(DrawingEditor editor) {
  JButton button = new JButton();
  button.setIcon(ImageDirectory.getImageIcon("/toolbar/attributeFontUnderline.png"));
  button.setText(null);
  button.setToolTipText(BUNDLE.getString("buttonFactory.button_fontStyleUnderline.tooltipText"));
  button.setFocusable(false);

  AbstractAction action
      = new AttributeToggler<>(editor,
                               AttributeKeys.FONT_UNDERLINE,
                               Boolean.TRUE,
                               Boolean.FALSE,
                               new StyledEditorKit.BoldAction());
  action.putValue(ActionUtil.UNDO_PRESENTATION_NAME_KEY,
                  BUNDLE.getString("buttonFactory.action_fontStyleUnderline.undo.presentationName"));
  button.addActionListener(action);

  return button;
}
 
Example 4
Source Project: CodenameOne   Source File: HTMLEditor.java    License: GNU General Public License v2.0 6 votes vote down vote up
/** Creates new form HTMLEditor */
public HTMLEditor(EditableResources res, String htmlText) {
    initComponents();
    this.res = res;
    htmlComponent = new com.codename1.ui.html.HTMLComponent();
    htmlComponent.setBodyText(htmlText, "UTF-8");
    final CodenameOneComponentWrapper wrapper = new CodenameOneComponentWrapper(htmlComponent);
    uiPreview.add(java.awt.BorderLayout.CENTER, wrapper);
    wysiwyg.setText(htmlText);
    source.setText(htmlText);
    Listener l = new Listener();
    wysiwyg.getDocument().addDocumentListener(l);
    source.getDocument().addDocumentListener(l);
    JButton b = jToolBar1.add(new StyledEditorKit.BoldAction());
    b.setText("<html><body><b>B</b></body></html>");
    JButton i = jToolBar1.add(new StyledEditorKit.ItalicAction());
    i.setText("<html><body><i>I</i></body></html>");
    JButton u = jToolBar1.add(new StyledEditorKit.UnderlineAction());
    u.setText("<html><body><u>U</u></body></html>");
    jToolBar1.add(new InsertImageAction());
}
 
Example 5
Source Project: netbeans   Source File: DetailsPanel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void removeNotify () {
    setEditorKit (new StyledEditorKit ());
    if (hyperlinkListener != null) {
        removeHyperlinkListener (hyperlinkListener);
    }
    scrollPane = null;
    super.removeNotify ();
}
 
Example 6
public void actionPerformed(ActionEvent ae) {
	JEditorPane editor = getEditor(ae);
	if (editor != null) {
		StyledEditorKit kit = getStyledEditorKit(editor);
		MutableAttributeSet attr = kit.getInputAttributes();
		boolean subscript = (StyleConstants.isSubscript(attr)) ? false
				: true;
		SimpleAttributeSet sas = new SimpleAttributeSet();
		StyleConstants.setSubscript(sas, subscript);
		setCharacterAttributes(editor, sas, false);
	}
}
 
Example 7
public void actionPerformed(ActionEvent ae) {
	JEditorPane editor = getEditor(ae);
	if (editor != null) {
		StyledEditorKit kit = getStyledEditorKit(editor);
		MutableAttributeSet attr = kit.getInputAttributes();
		boolean superscript = (StyleConstants.isSuperscript(attr)) ? false
				: true;
		SimpleAttributeSet sas = new SimpleAttributeSet();
		StyleConstants.setSuperscript(sas, superscript);
		setCharacterAttributes(editor, sas, false);
	}
}
 
Example 8
public void actionPerformed(ActionEvent ae) {
	JEditorPane editor = getEditor(ae);
	if (editor != null) {
		StyledEditorKit kit = getStyledEditorKit(editor);
		MutableAttributeSet attr = kit.getInputAttributes();
		boolean strikeThrough = (StyleConstants.isStrikeThrough(attr)) ? false
				: true;
		SimpleAttributeSet sas = new SimpleAttributeSet();
		StyleConstants.setStrikeThrough(sas, strikeThrough);
		setCharacterAttributes(editor, sas, false);
	}
}
 
Example 9
Source Project: dragonwell8_jdk   Source File: bug4242228.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] argv) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame("4242228 Test");

            JScrollPane sourcePane = new JScrollPane();
            final JTextPane htmlEditor = new JTextPane();
            final JTextPane sourceEditor = new JTextPane();
            final JScrollPane editorPane = new JScrollPane();

            tabPane = new JTabbedPane();
            htmlEditor.setText(" ");
            htmlEditor.setEditorKit(new HTMLEditorKit());

            sourceEditor.setText(" ");
            sourceEditor.setEditorKit(new StyledEditorKit());

            frame.setLayout(new BorderLayout());

            editorPane.getViewport().add(htmlEditor);

            tabPane.addTab("Editor", editorPane);
            tabPane.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    if (tabPane.getSelectedComponent() == editorPane) {
                        htmlEditor.setText(sourceEditor.getText());
                    } else {
                        sourceEditor.setText(htmlEditor.getText());
                    }
                }
            });

            sourcePane.getViewport().add(sourceEditor);
            tabPane.addTab("Source", sourcePane);
            tabPane.setTabPlacement(SwingConstants.BOTTOM);
            htmlEditor.setDocument(new HTMLDocument());

            frame.add(tabPane);
            frame.setSize(400, 300);
            frame.setVisible(true);
        }
    });

    ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < 50; i++) {
                tabPane.setSelectedIndex(i % 2);
            }

            frame.dispose();
        }
    });
}
 
Example 10
Source Project: TencentKona-8   Source File: bug4242228.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] argv) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame("4242228 Test");

            JScrollPane sourcePane = new JScrollPane();
            final JTextPane htmlEditor = new JTextPane();
            final JTextPane sourceEditor = new JTextPane();
            final JScrollPane editorPane = new JScrollPane();

            tabPane = new JTabbedPane();
            htmlEditor.setText(" ");
            htmlEditor.setEditorKit(new HTMLEditorKit());

            sourceEditor.setText(" ");
            sourceEditor.setEditorKit(new StyledEditorKit());

            frame.setLayout(new BorderLayout());

            editorPane.getViewport().add(htmlEditor);

            tabPane.addTab("Editor", editorPane);
            tabPane.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    if (tabPane.getSelectedComponent() == editorPane) {
                        htmlEditor.setText(sourceEditor.getText());
                    } else {
                        sourceEditor.setText(htmlEditor.getText());
                    }
                }
            });

            sourcePane.getViewport().add(sourceEditor);
            tabPane.addTab("Source", sourcePane);
            tabPane.setTabPlacement(SwingConstants.BOTTOM);
            htmlEditor.setDocument(new HTMLDocument());

            frame.add(tabPane);
            frame.setSize(400, 300);
            frame.setVisible(true);
        }
    });

    ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < 50; i++) {
                tabPane.setSelectedIndex(i % 2);
            }

            frame.dispose();
        }
    });
}
 
Example 11
Source Project: jdk8u60   Source File: bug4242228.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] argv) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame("4242228 Test");

            JScrollPane sourcePane = new JScrollPane();
            final JTextPane htmlEditor = new JTextPane();
            final JTextPane sourceEditor = new JTextPane();
            final JScrollPane editorPane = new JScrollPane();

            tabPane = new JTabbedPane();
            htmlEditor.setText(" ");
            htmlEditor.setEditorKit(new HTMLEditorKit());

            sourceEditor.setText(" ");
            sourceEditor.setEditorKit(new StyledEditorKit());

            frame.setLayout(new BorderLayout());

            editorPane.getViewport().add(htmlEditor);

            tabPane.addTab("Editor", editorPane);
            tabPane.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    if (tabPane.getSelectedComponent() == editorPane) {
                        htmlEditor.setText(sourceEditor.getText());
                    } else {
                        sourceEditor.setText(htmlEditor.getText());
                    }
                }
            });

            sourcePane.getViewport().add(sourceEditor);
            tabPane.addTab("Source", sourcePane);
            tabPane.setTabPlacement(SwingConstants.BOTTOM);
            htmlEditor.setDocument(new HTMLDocument());

            frame.add(tabPane);
            frame.setSize(400, 300);
            frame.setVisible(true);
        }
    });

    ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < 50; i++) {
                tabPane.setSelectedIndex(i % 2);
            }

            frame.dispose();
        }
    });
}
 
Example 12
Source Project: openjdk-jdk8u   Source File: bug4242228.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] argv) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame("4242228 Test");

            JScrollPane sourcePane = new JScrollPane();
            final JTextPane htmlEditor = new JTextPane();
            final JTextPane sourceEditor = new JTextPane();
            final JScrollPane editorPane = new JScrollPane();

            tabPane = new JTabbedPane();
            htmlEditor.setText(" ");
            htmlEditor.setEditorKit(new HTMLEditorKit());

            sourceEditor.setText(" ");
            sourceEditor.setEditorKit(new StyledEditorKit());

            frame.setLayout(new BorderLayout());

            editorPane.getViewport().add(htmlEditor);

            tabPane.addTab("Editor", editorPane);
            tabPane.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    if (tabPane.getSelectedComponent() == editorPane) {
                        htmlEditor.setText(sourceEditor.getText());
                    } else {
                        sourceEditor.setText(htmlEditor.getText());
                    }
                }
            });

            sourcePane.getViewport().add(sourceEditor);
            tabPane.addTab("Source", sourcePane);
            tabPane.setTabPlacement(SwingConstants.BOTTOM);
            htmlEditor.setDocument(new HTMLDocument());

            frame.add(tabPane);
            frame.setSize(400, 300);
            frame.setVisible(true);
        }
    });

    ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < 50; i++) {
                tabPane.setSelectedIndex(i % 2);
            }

            frame.dispose();
        }
    });
}
 
Example 13
public static void main(String[] argv) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame("4242228 Test");

            JScrollPane sourcePane = new JScrollPane();
            final JTextPane htmlEditor = new JTextPane();
            final JTextPane sourceEditor = new JTextPane();
            final JScrollPane editorPane = new JScrollPane();

            tabPane = new JTabbedPane();
            htmlEditor.setText(" ");
            htmlEditor.setEditorKit(new HTMLEditorKit());

            sourceEditor.setText(" ");
            sourceEditor.setEditorKit(new StyledEditorKit());

            frame.setLayout(new BorderLayout());

            editorPane.getViewport().add(htmlEditor);

            tabPane.addTab("Editor", editorPane);
            tabPane.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    if (tabPane.getSelectedComponent() == editorPane) {
                        htmlEditor.setText(sourceEditor.getText());
                    } else {
                        sourceEditor.setText(htmlEditor.getText());
                    }
                }
            });

            sourcePane.getViewport().add(sourceEditor);
            tabPane.addTab("Source", sourcePane);
            tabPane.setTabPlacement(SwingConstants.BOTTOM);
            htmlEditor.setDocument(new HTMLDocument());

            frame.add(tabPane);
            frame.setSize(400, 300);
            frame.setVisible(true);
        }
    });

    ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < 50; i++) {
                tabPane.setSelectedIndex(i % 2);
            }

            frame.dispose();
        }
    });
}
 
Example 14
Source Project: openjdk-jdk9   Source File: bug4242228.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] argv) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame("4242228 Test");

            JScrollPane sourcePane = new JScrollPane();
            final JTextPane htmlEditor = new JTextPane();
            final JTextPane sourceEditor = new JTextPane();
            final JScrollPane editorPane = new JScrollPane();

            tabPane = new JTabbedPane();
            htmlEditor.setText(" ");
            htmlEditor.setEditorKit(new HTMLEditorKit());

            sourceEditor.setText(" ");
            sourceEditor.setEditorKit(new StyledEditorKit());

            frame.setLayout(new BorderLayout());

            editorPane.getViewport().add(htmlEditor);

            tabPane.addTab("Editor", editorPane);
            tabPane.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    if (tabPane.getSelectedComponent() == editorPane) {
                        htmlEditor.setText(sourceEditor.getText());
                    } else {
                        sourceEditor.setText(htmlEditor.getText());
                    }
                }
            });

            sourcePane.getViewport().add(sourceEditor);
            tabPane.addTab("Source", sourcePane);
            tabPane.setTabPlacement(SwingConstants.BOTTOM);
            htmlEditor.setDocument(new HTMLDocument());

            frame.add(tabPane);
            frame.setSize(400, 300);
            frame.setVisible(true);
        }
    });

    Robot robot = new Robot();
    robot.waitForIdle();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < 50; i++) {
                tabPane.setSelectedIndex(i % 2);
            }

            frame.dispose();
        }
    });
}
 
Example 15
Source Project: jdk8u-jdk   Source File: bug4242228.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] argv) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame("4242228 Test");

            JScrollPane sourcePane = new JScrollPane();
            final JTextPane htmlEditor = new JTextPane();
            final JTextPane sourceEditor = new JTextPane();
            final JScrollPane editorPane = new JScrollPane();

            tabPane = new JTabbedPane();
            htmlEditor.setText(" ");
            htmlEditor.setEditorKit(new HTMLEditorKit());

            sourceEditor.setText(" ");
            sourceEditor.setEditorKit(new StyledEditorKit());

            frame.setLayout(new BorderLayout());

            editorPane.getViewport().add(htmlEditor);

            tabPane.addTab("Editor", editorPane);
            tabPane.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    if (tabPane.getSelectedComponent() == editorPane) {
                        htmlEditor.setText(sourceEditor.getText());
                    } else {
                        sourceEditor.setText(htmlEditor.getText());
                    }
                }
            });

            sourcePane.getViewport().add(sourceEditor);
            tabPane.addTab("Source", sourcePane);
            tabPane.setTabPlacement(SwingConstants.BOTTOM);
            htmlEditor.setDocument(new HTMLDocument());

            frame.add(tabPane);
            frame.setSize(400, 300);
            frame.setVisible(true);
        }
    });

    ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < 50; i++) {
                tabPane.setSelectedIndex(i % 2);
            }

            frame.dispose();
        }
    });
}
 
Example 16
Source Project: hottub   Source File: bug4242228.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] argv) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame("4242228 Test");

            JScrollPane sourcePane = new JScrollPane();
            final JTextPane htmlEditor = new JTextPane();
            final JTextPane sourceEditor = new JTextPane();
            final JScrollPane editorPane = new JScrollPane();

            tabPane = new JTabbedPane();
            htmlEditor.setText(" ");
            htmlEditor.setEditorKit(new HTMLEditorKit());

            sourceEditor.setText(" ");
            sourceEditor.setEditorKit(new StyledEditorKit());

            frame.setLayout(new BorderLayout());

            editorPane.getViewport().add(htmlEditor);

            tabPane.addTab("Editor", editorPane);
            tabPane.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    if (tabPane.getSelectedComponent() == editorPane) {
                        htmlEditor.setText(sourceEditor.getText());
                    } else {
                        sourceEditor.setText(htmlEditor.getText());
                    }
                }
            });

            sourcePane.getViewport().add(sourceEditor);
            tabPane.addTab("Source", sourcePane);
            tabPane.setTabPlacement(SwingConstants.BOTTOM);
            htmlEditor.setDocument(new HTMLDocument());

            frame.add(tabPane);
            frame.setSize(400, 300);
            frame.setVisible(true);
        }
    });

    ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < 50; i++) {
                tabPane.setSelectedIndex(i % 2);
            }

            frame.dispose();
        }
    });
}
 
Example 17
Source Project: openjdk-8-source   Source File: bug4242228.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] argv) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame("4242228 Test");

            JScrollPane sourcePane = new JScrollPane();
            final JTextPane htmlEditor = new JTextPane();
            final JTextPane sourceEditor = new JTextPane();
            final JScrollPane editorPane = new JScrollPane();

            tabPane = new JTabbedPane();
            htmlEditor.setText(" ");
            htmlEditor.setEditorKit(new HTMLEditorKit());

            sourceEditor.setText(" ");
            sourceEditor.setEditorKit(new StyledEditorKit());

            frame.setLayout(new BorderLayout());

            editorPane.getViewport().add(htmlEditor);

            tabPane.addTab("Editor", editorPane);
            tabPane.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    if (tabPane.getSelectedComponent() == editorPane) {
                        htmlEditor.setText(sourceEditor.getText());
                    } else {
                        sourceEditor.setText(htmlEditor.getText());
                    }
                }
            });

            sourcePane.getViewport().add(sourceEditor);
            tabPane.addTab("Source", sourcePane);
            tabPane.setTabPlacement(SwingConstants.BOTTOM);
            htmlEditor.setDocument(new HTMLDocument());

            frame.add(tabPane);
            frame.setSize(400, 300);
            frame.setVisible(true);
        }
    });

    ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < 50; i++) {
                tabPane.setSelectedIndex(i % 2);
            }

            frame.dispose();
        }
    });
}
 
Example 18
Source Project: openjdk-8   Source File: bug4242228.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] argv) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame("4242228 Test");

            JScrollPane sourcePane = new JScrollPane();
            final JTextPane htmlEditor = new JTextPane();
            final JTextPane sourceEditor = new JTextPane();
            final JScrollPane editorPane = new JScrollPane();

            tabPane = new JTabbedPane();
            htmlEditor.setText(" ");
            htmlEditor.setEditorKit(new HTMLEditorKit());

            sourceEditor.setText(" ");
            sourceEditor.setEditorKit(new StyledEditorKit());

            frame.setLayout(new BorderLayout());

            editorPane.getViewport().add(htmlEditor);

            tabPane.addTab("Editor", editorPane);
            tabPane.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    if (tabPane.getSelectedComponent() == editorPane) {
                        htmlEditor.setText(sourceEditor.getText());
                    } else {
                        sourceEditor.setText(htmlEditor.getText());
                    }
                }
            });

            sourcePane.getViewport().add(sourceEditor);
            tabPane.addTab("Source", sourcePane);
            tabPane.setTabPlacement(SwingConstants.BOTTOM);
            htmlEditor.setDocument(new HTMLDocument());

            frame.add(tabPane);
            frame.setSize(400, 300);
            frame.setVisible(true);
        }
    });

    ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < 50; i++) {
                tabPane.setSelectedIndex(i % 2);
            }

            frame.dispose();
        }
    });
}
 
Example 19
Source Project: jdk8u_jdk   Source File: bug4242228.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] argv) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame("4242228 Test");

            JScrollPane sourcePane = new JScrollPane();
            final JTextPane htmlEditor = new JTextPane();
            final JTextPane sourceEditor = new JTextPane();
            final JScrollPane editorPane = new JScrollPane();

            tabPane = new JTabbedPane();
            htmlEditor.setText(" ");
            htmlEditor.setEditorKit(new HTMLEditorKit());

            sourceEditor.setText(" ");
            sourceEditor.setEditorKit(new StyledEditorKit());

            frame.setLayout(new BorderLayout());

            editorPane.getViewport().add(htmlEditor);

            tabPane.addTab("Editor", editorPane);
            tabPane.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    if (tabPane.getSelectedComponent() == editorPane) {
                        htmlEditor.setText(sourceEditor.getText());
                    } else {
                        sourceEditor.setText(htmlEditor.getText());
                    }
                }
            });

            sourcePane.getViewport().add(sourceEditor);
            tabPane.addTab("Source", sourcePane);
            tabPane.setTabPlacement(SwingConstants.BOTTOM);
            htmlEditor.setDocument(new HTMLDocument());

            frame.add(tabPane);
            frame.setSize(400, 300);
            frame.setVisible(true);
        }
    });

    ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < 50; i++) {
                tabPane.setSelectedIndex(i % 2);
            }

            frame.dispose();
        }
    });
}
 
Example 20
Source Project: jdk8u-jdk   Source File: bug4242228.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] argv) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame("4242228 Test");

            JScrollPane sourcePane = new JScrollPane();
            final JTextPane htmlEditor = new JTextPane();
            final JTextPane sourceEditor = new JTextPane();
            final JScrollPane editorPane = new JScrollPane();

            tabPane = new JTabbedPane();
            htmlEditor.setText(" ");
            htmlEditor.setEditorKit(new HTMLEditorKit());

            sourceEditor.setText(" ");
            sourceEditor.setEditorKit(new StyledEditorKit());

            frame.setLayout(new BorderLayout());

            editorPane.getViewport().add(htmlEditor);

            tabPane.addTab("Editor", editorPane);
            tabPane.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    if (tabPane.getSelectedComponent() == editorPane) {
                        htmlEditor.setText(sourceEditor.getText());
                    } else {
                        sourceEditor.setText(htmlEditor.getText());
                    }
                }
            });

            sourcePane.getViewport().add(sourceEditor);
            tabPane.addTab("Source", sourcePane);
            tabPane.setTabPlacement(SwingConstants.BOTTOM);
            htmlEditor.setDocument(new HTMLDocument());

            frame.add(tabPane);
            frame.setSize(400, 300);
            frame.setVisible(true);
        }
    });

    ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < 50; i++) {
                tabPane.setSelectedIndex(i % 2);
            }

            frame.dispose();
        }
    });
}
 
Example 21
Source Project: jdk8u-dev-jdk   Source File: bug4242228.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] argv) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            frame = new JFrame("4242228 Test");

            JScrollPane sourcePane = new JScrollPane();
            final JTextPane htmlEditor = new JTextPane();
            final JTextPane sourceEditor = new JTextPane();
            final JScrollPane editorPane = new JScrollPane();

            tabPane = new JTabbedPane();
            htmlEditor.setText(" ");
            htmlEditor.setEditorKit(new HTMLEditorKit());

            sourceEditor.setText(" ");
            sourceEditor.setEditorKit(new StyledEditorKit());

            frame.setLayout(new BorderLayout());

            editorPane.getViewport().add(htmlEditor);

            tabPane.addTab("Editor", editorPane);
            tabPane.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    if (tabPane.getSelectedComponent() == editorPane) {
                        htmlEditor.setText(sourceEditor.getText());
                    } else {
                        sourceEditor.setText(htmlEditor.getText());
                    }
                }
            });

            sourcePane.getViewport().add(sourceEditor);
            tabPane.addTab("Source", sourcePane);
            tabPane.setTabPlacement(SwingConstants.BOTTOM);
            htmlEditor.setDocument(new HTMLDocument());

            frame.add(tabPane);
            frame.setSize(400, 300);
            frame.setVisible(true);
        }
    });

    ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            for (int i = 0; i < 50; i++) {
                tabPane.setSelectedIndex(i % 2);
            }

            frame.dispose();
        }
    });
}