What components should I use for building a Java WYSIWYG HTML editor

后端 未结 2 1379
-上瘾入骨i
-上瘾入骨i 2020-12-22 09:50

I like to build java WYSIWYG HTML to practice my or better learn Java swing all the simple swing layouts and simple components i understand , but what should i use to repres

相关标签:
2条回答
  • 2020-12-22 10:23

    You might look into metaphase editor, "A WYSIWYG HTML Editor Component for use in Java Applications." It's based on Charles Bell's HTMLDocumentEditor.

    0 讨论(0)
  • 2020-12-22 10:32

    Basically, to draw grids and lines, you need to draw the HTML elements graphically on one or more JPanels.

    You do this by overriding the paintComponent() method with your Graphics and Graphics2D method calls.

    Here's a simple example:

     public void paintComponent(Graphics g) {
        // Dynamically calculate size information
        Dimension size = getSize();
        // diameter
        int d = Math.min(size.width, size.height); 
        int x = (size.width - d)/2;
        int y = (size.height - d)/2;
    
        // draw circle (color already set to foreground)
        g.fillOval(x, y, d, d);
        g.setColor(Color.black);
        g.drawOval(x, y, d, d);
    }
    
    0 讨论(0)
提交回复
热议问题