스크롤 막대를 JTextArea
에 추가하고 싶지만 표시되지 않습니다. 포럼에서 많은 것을 읽었지만 모두 헛된 것입니다. 모든 제안은 높이 평가됩니다. 미리 감사드립니다. 아래는 제 코드입니다.JScrollPane 두 개의 패널이있는 JFrame에서
JPanel pan, pan2;
JTextArea text = new JTextArea();
JTextField fname = new JTextField(18);
JLabel filename = new JLabel("Filename");
JButton view = new JButton("View");
public FileReading() {
setLayout(new BorderLayout());
pan = new JPanel();
pan2 = new JPanel();
JScrollPane scroll = new JScrollPane(text);
//scroll.setBounds(400,400,400,400);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
text.setEditable(false);
scroll.setViewportView(text);
pan2.add(scroll);
//scrollpane.setViewportView(text);
pan2.setLayout(new BorderLayout());
//pan2.add(scrollpane);
pan.setLayout(new FlowLayout());
pan.add(filename, FlowLayout.LEFT);
pan.add(fname, FlowLayout.CENTER);
pan.add(view, FlowLayout.RIGHT);
view.addActionListener(this);
fname.addActionListener(this);
pan2.add(text, BorderLayout.CENTER);
pan2.add(pan, BorderLayout.SOUTH);
//BorderLayout.EAST
//add(pan, BorderLayout.SOUTH);
add(pan2);//, BorderLayout.CENTER
setVisible(true);
}
public static void main(String args[]) {
FileReading frame = new FileReading();
frame.setTitle("Enter The Full Path to the File");
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setBounds(400,400,400,400);
//frame.setSize(400,400);
}
많은 분들께 감사드립니다. 힘든 시간을 생각해 냈습니다. 지금 그것의 모든 일은 내가 그것을 원했던 방식으로 awesomely :). – guthik
@ user1825142 작동하는 경우 ... 답변을 수락하고 upvote도 허용 할 수 있습니다. – exexzian