Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dialog with scroll bar for text and resizable

 
aniketh kumar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I want to create a confirmation dialog with text inside having a vertical and horizontal scrollbar also a option to user to resize the dialog. I tried doing this in following way but that doesnt work whenever I try to resize in vertical way the pane also goes to bottom and doesnt resize. Following is the snippet
JTextArea textArea = new JTextArea();
textArea.setText("Some text");
textArea.setRows(10);
textArea.setColumns(90);
JScrollPane scrollpane = new JScrollPane(textArea);
JPanel panel = new JPanel(new VerticalLayout() );
panel.add("bottom",scrollpane );
JLabel label = new JLabel("testing");
panel.add("bottom",label);
JOptionPane optionPane = new JOptionPane(panel,JOptionPane.QUESTION_MESSAGE,JOptionPane.YES_NO_OPTION);
JDialog dialog = optPane.createDialog(null, "Press yes/no");
dialog.setResizable(true);
dialog.setVisible(true);

Thanks
 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch. Could you please edit your post and UseCodeTags? HowToAskQuestionsOnJavaRanch may also be interesting to read.
 
aniketh kumar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aniketh kumar wrote:Hi All,

I want to create a confirmation dialog with text inside having a vertical and horizontal scrollbar also a option to user to resize the dialog. I tried doing this in following way but that doesnt work whenever I try to resize in vertical way the pane also goes to bottom and doesnt resize. Following is the snippet

Thanks
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what VerticalLayout is - you may have to ask whoever's layoutManager it is, your problem.

if you'd used BorderLayout and put the scrollpane at CENTER, the scrollpane will increase/decrease according to the size of the dialog
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic