我正在尝试向我的 JTextarea 添加滚动条,但滚动条没有显示,我的 Jtoolbar 也没有任何人可以告诉我这段代码有什么问题。这样我就可以修复它。我一直在到处寻找,但滚动窗格仍然没有出现
public PlayerGui() {
// create main windows
super("Liste");
JTextArea editors = new JTextArea();
editors.setLineWrap(true);
editors.setWrapStyleWord(true);
// scroll bar
JScrollPane scroll = new JScrollPane(editors);
setEditor(editors);
// create center panel
JPanel cent = new JPanel();
//create Panel for the to
JPanel north = new JPanel();
setNorthpanel(north);
// create tool bar
JToolBar toolbar = new JToolBar();
toolbar.add(scroll);
// set center panel and add preferred layout and backgrounds and size
setCenter(cent);
getCenter().setLayout(new BorderLayout());
// add scroll bar and toolbar
add(scroll, BorderLayout.EAST);
add(toolbar, BorderLayout.SOUTH);
//getCenter().setBackground(Color.black);
Dimension size = new Dimension(getCenter().getPreferredSize());
getEditor().setPreferredSize(size);
getCenter().getPreferredSize();
getCenter().setBorder(new CompoundBorder(new EmptyBorder(10,10 ,10,10),new EtchedBorder(Color.BLACK, Color.black)));
//add text editor to the center panel
getCenter().add(getEditor(),BorderLayout.CENTER);
//set layout of the frame
setLayout(new BorderLayout());
menubar1 = new JMenuBar();
//create menu list from a string arrays
for(int i=0; i<list.length; i++){
JMenu menus = new JMenu(list[i]);
menubar1.add(menus);
}