-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.3.0
-
x86
-
windows_nt
Name: krT82822 Date: 03/18/2000
(see also 4263904)
java version "1.3.0rc1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-T)
Java HotSpot(TM) Client VM (build 1.3.0rc1-S, mixed mode)
1. use java1.3 RC1
2. javac EditorPaneInsertList.java (source code attached)
3. java EditorPaneInsertList
4. Click Menu "Insert List --> Insert an ordered list". This will print the
first item index of the list, "1. ", which appears on the left side of the
editor pane
5. Start input text and you will find the content appears on the center of the
editor pane!!!
6. Click Menu "Insert List --> Insert an ordered list item". This will print
two more item indexes of the list, "2. \n3. ", which appear on the left side
of the editor pane
7. Start input text and you will find the content appears on the center of the
editor pane!!!
********************************************************************************
*****
<pre>
//Source code of EditorPaneInsertList.java:
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
import java.awt.*;
import java.io.*;
import java.util.*;
import java.awt.event.*;
/**
*/
public class EditorPaneInsertList
{
public static void main(String[] args)
{
try{
JFrame f = new JFrame();
JEditorPane ep = new JEditorPane();
ep.setContentType("text/html");
ep.setBorder(BorderFactory.createEmptyBorder(2,4,2,4));
JScrollPane sp = new JScrollPane(ep);
f.getContentPane().add(sp, "Center");
f.setJMenuBar(createJMenuBar(ep));
f.setSize(400, 400);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
System.exit(0);
}
});
f.setVisible(true);
ep.requestFocus();
} catch (Exception e)
{
e.printStackTrace(System.out);
System.exit(0);
}
}
/**
* create a menubar with two actions, "Set New Document" and "SetText Empty"
*/
static int count = 0;
private static JMenuBar createJMenuBar(final JEditorPane ep)
{
JMenuBar menuBar = new JMenuBar();
JMenu testM = new JMenu("Insert List");
//get all the actions that the JEditorPane has
Action[] act = ((HTMLEditorKit)ep.getEditorKit()).getActions();
Hashtable actHash = new Hashtable();
for(int i=0;i<act.length;i++)
{
String name = (String)act[i].getValue(Action.NAME);
actHash.put(name, act[i]);
//System.out.println("Action "+i+": "+name);
}
//get the action for inserting an ordered list
TextAction listAction = (TextAction)actHash.get("InsertOrderedList");
listAction.putValue(Action.NAME, "Insert an ordered list");
testM.add(listAction);
//get the action for inserting an ordered list item
TextAction itemAction = (TextAction)actHash.get("InsertOrderedListItem");
itemAction.putValue(Action.NAME, "Insert an ordered list item");
testM.add(itemAction);
menuBar.add(testM);
return menuBar;
}
}
</pre>
(Review ID: 102555)
======================================================================
- duplicates
-
JDK-4357975 HTMLEditorKit InsertUnorderedListItem action behaves strangely
-
- Resolved
-