Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-16-2007, 04:54 PM
Member
 
Join Date: Jul 2007
Posts: 26
paul is on a distinguished road
Help with JTextArea, resize windows
How can I get the JTextArea to display without having to resize the window?
And is there a way I can position it?
Code:
import javax.swing.*; import java.awt.*; import java.util.Random; public class Oval extends JPanel { public void paintComponent( Graphics g ) { super.paintComponent( g ); Random randomNumbers = new Random(); int width = 1 + randomNumbers.nextInt( 200 ); int height = 1 + randomNumbers.nextInt( 200 ); double area = Math.PI * (width/2) * (height/2); String text = "Area = " + area + "\n"; JTextArea textArea1 = new JTextArea( text, 10, 10 ); add (textArea1); //( int x, int y, int width, int height ) g.drawOval( 10, 10, width, height ); } }
Code:
import javax.swing.JFrame; public class OvalTest { public static void main(String args[]) { JFrame frame = new JFrame( "Oval of random size" ); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frame.setSize( 600, 210 ); Oval oval = new Oval(); frame.add(oval); frame.setVisible( true ); } }
Thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-16-2007, 05:11 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
You need to learn layout managers to be able to place the component to the position you want.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moments with Windows tim Jokes and Funny Things 4 05-05-2008 09:27 AM
Problems with gridBaglayout when I resize the window Iyengar AWT / Swing 1 02-17-2008 12:43 AM
swt for windows Gajesh Tripathi SWT / JFace 2 10-18-2007 07:43 AM
resize tabs in jtabbedpane osval New To Java 1 08-02-2007 04:02 AM
Resize frame lenny AWT / Swing 1 07-30-2007 12:18 AM


All times are GMT +3. The time now is 01:13 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org