1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
import javax.swing.*;
import java.awt.*;
class MyEditorPanel extends JEditorPane
{
public MyEditorPanel(){
super();
setBounds(200,200,200,200);
}
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
}
}
public class EditorPanelTest extends JPanel
{
public Dimension getPreferredSize() {
int w = 900;
int h = 900;
return new Dimension(w,h);
}
public EditorPanelTest() {
//setLayout(new BorderLayout());
setLayout(null);
MyEditorPanel editorPane = createEditorPane();
add(editorPane);
}
private MyEditorPanel createEditorPane() {
MyEditorPanel editorPane = new MyEditorPanel();
editorPane.setEditable(false);
editorPane.setText("totototototootototo tototototo"+"\n"+" titititi");
return editorPane;
}
public static void main(String[] args) {
JFrame frame = new JFrame("EditorPanelTest");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JComponent newContentPane = new EditorPanelTest();
frame.setContentPane(newContentPane);
frame.pack();
frame.setVisible(true);
}
} |