I am creating a simple JTextPane
and setting a long text after viewport setting, but when I run program in Mac os 10.11.5, my JTextPane
text lines collapses with each other. When I scroll slowly it does not happen, but when I scroll little fast it starts collapsing. This problem is not occurring in windows. Here is my sample source code:
public class JTextPaneScroll extends javax.swing.JFrame {
private String s = "Wait! Some of your past questions have not been well-received, and you're in danger of being blocked from asking any more.\n"
+ "\n For help formulating a clear, useful question, see: How do I ask a good question?\n"
+ "Also, edit your previous questions to improve formatting and clarity."
+ "Wait! Some of your past questions have not been well-received, and you're in danger of being blocked from asking any more.\n"
+ "\n For help formulating a clear, useful question, see: How do I ask a good question?\n"
+ "Also, edit your previous questions to improve formatting and clarity."
+ "Wait! Some of your past questions have not been well-received, and you're in danger of being blocked from asking any more.\n"
+ "\n For help formulating a clear, useful question, see: How do I ask a good question?\n"
+ "Also, edit your previous questions to improve formatting and clarity.";
public JTextPaneScroll() {
initComponents();
setTextToPane();
}
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jspcomp = new javax.swing.JScrollPane();
comp = new javax.swing.JTextPane();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jspcomp.setViewportView(comp);
getContentPane().add(jspcomp, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 20, 290, 180));
pack();
}// </editor-fold>
private void setTextToPane() {
try {
comp.setText(s);
} catch (Exception ex) {
ex.printStackTrace();
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(JTextPaneScroll.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(JTextPaneScroll.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(JTextPaneScroll.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(JTextPaneScroll.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new JTextPaneScroll().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextPane comp;
private javax.swing.JScrollPane jspcomp;
// End of variables declaration
}