Ok so, I’m trying to make this program that has “menus”, and each menu is a container that replaces the main JFrame content pane, in my main menu there is a code editing space in which someone can type code in a language that I created, but I used a JTextPane to create the editing area which doesn’t have a scroll bar, so I tried to add a scroll bar by using JScrollPane editing_pane = new JScrollPane(editing_area);
and replacing the main_menu_container.add(editing_area);
with main_menu_container.add(editing_pane);
, but that only makes my program have a white screen. I have no idea why this is happening and it only seems to happen whenever I have this particular JScrollPane in my container…
full code here:
Container main_menu_container = new Container();
main_menu_container.setLayout(new BorderLayout());
JPanel top_bar = new JPanel();
top_bar.setPreferredSize(new Dimension(-1,30));
top_bar.setLayout(new GridLayout(1,-1));
JTextPane editing_area = createTextPane();
JScrollPane editing_pane = new JScrollPane(editing_area,ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JButton file_button = createButton("File");
top_bar.add(file_button);
JButton compile_button = createButton("Compile");
top_bar.add(compile_button);
main_menu_container.add(top_bar,BorderLayout.PAGE_START);
main_menu_container.add(editing_pane,BorderLayout.CENTER);
main_menu_container.revalidate();
return main_menu_container;