aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Dialog with scroll bar for text and resizable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Dialog with scroll bar for text and resizable" Watch "Dialog with scroll bar for text and resizable" New topic
Author

Dialog with scroll bar for text and resizable

aniketh kumar
Greenhorn

Joined: Mar 19, 2010
Posts: 2
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

Joined: Oct 27, 2005
Posts: 19670
    
  18

Welcome to JavaRanch. Could you please edit your post and UseCodeTags? HowToAskQuestionsOnJavaRanch may also be interesting to read.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
aniketh kumar
Greenhorn

Joined: Mar 19, 2010
Posts: 2
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

Joined: Jun 09, 2003
Posts: 4632
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dialog with scroll bar for text and resizable