Reputation: 849
Hey All, I have two JEditorPane
in my GUI, from the image the two with hyperlinks
. Although in NetbeansIDE
I align them together, the page editorpane
appears to be shifting right everytime and its pretty annoying. I'm also trying to remove the pointless white background but failing.
Here's some setup for them:
private void initEditorPane(JEditorPane editorPane) {
editorPane.setBorder(null);
editorPane.setContentType("text/html");
editorPane.setEditable(false);
editorPane.setOpaque(false);
editorPane.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
launchHyperLink(e);
}
}
});
}
I am not sure if it's the above causing the problems, or this:
pageTxtComp.setText("<html> <a href='" + ac.getPage() + "'>" + ac.getPage() + "</a> </html>");
emailTxtComp.setText("<html> <a href='mailto://" + ac.getEmail() + "'>" + ac.getEmail() + "</a> </html> ");
How can I improve the alignment?
How can I remove the white background? In Properties, I've tried choosing a matching background colour with panel, does not do the trick.
Upvotes: 0
Views: 1267
Reputation: 57421
You can get Document
from the pane. Cast it to StyledDocument
and use setParagraphAttributes()
setting desired alignment or change alignment by adding < p > < / p > tags specifying the alignment there.
For background try to set opaque to false for the pane.
Upvotes: 1