File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Beginner Swing - TextAerea size problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Beginner Swing - TextAerea size problem" Watch "Beginner Swing - TextAerea size problem" New topic
Author

Beginner Swing - TextAerea size problem

Jochen Rittmann
Greenhorn

Joined: Jun 20, 2009
Posts: 6
Sorry, i´am beginner. After hours of trying and searching in forums i give up.

I have a simple form with a textarea. Created with VisualEditor.

How can i resize the textarea??? There is no attribute or other possiblities to make it bigger with mouse action in development.

function 'initcompontents'
add(getJScrollPane0(), new Constraints(new Leading(8, 100, 10, 10), new Leading(151, 80, 47, 47)));

private JScrollPane getJScrollPane0() {
if (jScjtLog == null) {
jScjtLog = new JScrollPane();
jScjtLog.setViewportView(getJtLog());
}
return jScjtLog;
}

private JTextArea getJtLog() {
if (jtLog == null) {
jtLog = new JTextArea(240,240);
jtLog.setEditable(false);
jtLog.setText("");
jtLog.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
}
return jtLog;
}

Thank you,
Jochen
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

Check out setPreferredSize()

Note: Not all layout managers respect the preferred size. Usually one does not set the size for the text area. Just wrap it in a JScrollPane and add the pane to the parent container. The scroll pane helps the user view/interact with the "hidden" text.
Also, do yourself a favor and drop the visual editor. You end up learning the editors than the actual coding. Search the forums to find many discussions on why editors are a bad idea.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2179
    
    7


Use more realistic values. Now you are asking for a text area with 240 rows and 240 columns.

If you do set the preferred size, it should be done on the scroll pane, NOT the text area.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19679
    
  18

And please UseCodeTags next time. See how much better Rob's little code snippet looks compared to yours.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

Rob Prime wrote: See how much better Rob's little code snippet looks compared to yours.

Er Rob, surely you mean Rob's code snippet
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19679
    
  18

That's what I said!

Seriously, Rob, I apologize for mistaking you for Michael. It's just that you two are both such helpful members here in the GUI forum.
Jochen Rittmann
Greenhorn

Joined: Jun 20, 2009
Posts: 6
Hello,

thank you for help!

The problem was the Dialog add functionallity like


The other size functions for the objects did not work, because this one is the one, that is working. I learned a lot.

 
wood burning stoves
 
subject: Beginner Swing - TextAerea size problem