1
인터넷에서 stackoverflow &을 검색했지만 작동하지 않았습니다. 스크롤 막대가 나타나지 않습니다. 제발 도와주세요, 그것이 효과가 있다면 당신의 답변에 투표 해 드리겠습니다. (미리 감사드립니다!)JTextPane에 JScrollPane이 나타나지 않습니다.
package com.james.client;
import javax.swing.*;
import javax.swing.UIManager.LookAndFeelInfo;
public class Main extends JFrame{
private static final long serialVersionUID = 1L;
public static void main(String [] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException
{
//Set program to nimbus
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
//Window stuff
JFrame window = new JFrame("MinecraftProgrammer++");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setSize(1000, 600);
window.setResizable(false);
JPanel content = new JPanel();
content.setLayout(null);
JMenuBar nav = new JMenuBar();
JMenu file = new JMenu("File");
JMenu newfile = new JMenu("New");
JMenuItem Class = new JMenuItem("Class");
JMenuItem Package = new JMenuItem("Package");
JMenuItem Other = new JMenuItem("Other");
newfile.add(Class);
newfile.add(Package);
newfile.add(Other);
file.add(newfile);
nav.add(file);
JTextPane code = new JTextPane();
JScrollPane codescroll = new JScrollPane(code);
codescroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
codescroll.setBounds(0, 0, 994, 547);
code.setAutoscrolls(true);
code.setBounds(0, 0, 994, 547);
content.add(codescroll);
content.add(code);
window.setJMenuBar(nav);
//No more code after this line
window.add(content);
window.setVisible(true);
}
}
완벽하게 작동합니다! 내가 멍청한 실수를 했어. 고맙습니다. –
@JamesL. 문제 없어. Swing으로 시작했을 때이 오류를 나 자신으로 많이 만들었습니다. –