My issue is that whenever my JTextPane is highlighted by the user or the user scrolls, the text within the JTextPane overlaps itself many times and the color frequently changes.
I've tried looking for other answers but my current code allows the JTextPane to get added to a JScrollPane, which is added to a JLayeredPane which is then added to a class that extends JFrame
public class View extends JFrame {
private static final long serialVersionUID = 1L;
final Dimension SIZE = new Dimension(2661, 1663);
/**
* @return the pre-determined size of the JFrame
*/
public Dimension getDimensionSize() {
return SIZE;
}
public View(){
setTitle("Warframe Alert/Invasion Tracker - Project 4");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
createPanel();
pack();
setLocation(0,0);
setVisible(true);
}
public void createPanel(){
JTextPane textPane = new JTextPane();
Font font = new Font("Apple Casual", Font.PLAIN, 35);
textPane.setEditable(false);
textPane.setBackground(new Color(0, 200, 255, 50));
textPane.setText(Content.getAlertText()); //Content class is a class that creates the content to show on the textPane
textPane.setForeground(Color.black);
textPane.setFont(font);
JScrollPane scrollPane = new JScrollPane(textPane, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scrollPane.setBounds(50, 50, 1331, 1331);
JLabel background = new JLabel(new ImageIcon("..\\Project 4\\img\\bg.jpg"));
background.setBounds(0, 0, 2661, 1663);
JLayeredPane layeredPane = new JLayeredPane();
layeredPane.setPreferredSize(getDimensionSize());
layeredPane.add(background);
layeredPane.add(scrollPane);
this.getContentPane().add(layeredPane, BorderLayout.CENTER);
}
}
Here is an image of the result I am getting: