这是我的代码,我想在 JScrollPane 中居中 JTextPane:
JFrame frame = new JFrame("Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JTextPane editor = new JTextPane();
editor.setEditorKit(this);
JScrollPane scroll = new JScrollPane(editor);
//scroll.setAlignmentX(JScrollPane.CENTER_ALIGNMENT); <<<didnt change anything, so //'ed it
frame.getContentPane().add(scroll);
frame.setBounds(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());