Results 1 to 2 of 2
- 07-16-2007, 03:54 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 26
- Rep Power
- 0
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?
Java 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 ); } }ThanksJava 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 ); } }
- 07-16-2007, 04:11 PM #2
Similar Threads
-
Moments with Windows
By tim in forum EntertainmentReplies: 13Last Post: 11-10-2009, 12:34 PM -
Problems with gridBaglayout when I resize the window
By Iyengar in forum AWT / SwingReplies: 1Last Post: 02-16-2008, 11:43 PM -
swt for windows
By Gajesh Tripathi in forum SWT / JFaceReplies: 2Last Post: 10-18-2007, 06:43 AM -
resize tabs in jtabbedpane
By osval in forum New To JavaReplies: 1Last Post: 08-02-2007, 03:02 AM -
Resize frame
By lenny in forum AWT / SwingReplies: 1Last Post: 07-29-2007, 11:18 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks