类javax.swing.text.StyledEditorKit源码实例Demo

下面列出了怎么用javax.swing.text.StyledEditorKit的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: openAGV   文件: ButtonFactory.java
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;
}
 
源代码2 项目: openAGV   文件: ButtonFactory.java
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;
}
 
源代码3 项目: openAGV   文件: ButtonFactory.java
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;
}
 
源代码4 项目: CodenameOne   文件: HTMLEditor.java
/** 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());
}
 
源代码5 项目: netbeans   文件: DetailsPanel.java
@Override
public void removeNotify () {
    setEditorKit (new StyledEditorKit ());
    if (hyperlinkListener != null) {
        removeHyperlinkListener (hyperlinkListener);
    }
    scrollPane = null;
    super.removeNotify ();
}
 
源代码6 项目: egdownloader   文件: HTMLDocumentEditor.java
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);
	}
}
 
源代码7 项目: egdownloader   文件: HTMLDocumentEditor.java
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);
	}
}
 
源代码8 项目: egdownloader   文件: HTMLDocumentEditor.java
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);
	}
}
 
源代码9 项目: dragonwell8_jdk   文件: bug4242228.java
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();
        }
    });
}
 
源代码10 项目: TencentKona-8   文件: bug4242228.java
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();
        }
    });
}
 
源代码11 项目: jdk8u60   文件: bug4242228.java
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();
        }
    });
}
 
源代码12 项目: openjdk-jdk8u   文件: bug4242228.java
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();
        }
    });
}
 
源代码13 项目: openjdk-jdk8u-backup   文件: bug4242228.java
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();
        }
    });
}
 
源代码14 项目: openjdk-jdk9   文件: bug4242228.java
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();
        }
    });
}
 
源代码15 项目: jdk8u-jdk   文件: bug4242228.java
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();
        }
    });
}
 
源代码16 项目: hottub   文件: bug4242228.java
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();
        }
    });
}
 
源代码17 项目: openjdk-8-source   文件: bug4242228.java
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();
        }
    });
}
 
源代码18 项目: openjdk-8   文件: bug4242228.java
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();
        }
    });
}
 
源代码19 项目: jdk8u_jdk   文件: bug4242228.java
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();
        }
    });
}
 
源代码20 项目: jdk8u-jdk   文件: bug4242228.java
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();
        }
    });
}
 
源代码21 项目: jdk8u-dev-jdk   文件: bug4242228.java
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();
        }
    });
}
 
 类所在包
 类方法
 同包方法