The moose likes Swing / AWT / SWT / JFace and the fly likes Dialog with scroll bar for text and resizable Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply 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
Saloon Keeper

Joined: Oct 27, 2005
Posts: 18365

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
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
Rancher

Joined: Jun 09, 2003
Posts: 4041
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
 
 
subject: Dialog with scroll bar for text and resizable
 
Threads others viewed
Panel in ScrollPane
Arrays Won't Work
How to Resize JScrollPane used in a JPanel?
Why aren't my components wrapping?
JFrame won't repaint...
developer file tools