• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Drawing text inside rectangles

 
Andrei Zeus
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this task. I need to create rectangles and lines aand to put text inside the rectangle(comment box). I managed to cread rectangles and lines i can put text inside but the text is not displaying when i chancge the button(e.g i want to draw another rectangle
after i created a comment box). I worked with JTextArea and seem to be stacked.
First i dont know where is the problem. because i dont know how to do it.
Maybe you didnt understand my problem. I dont know how to do that and dont know where is the problem.
I tried to do it like this
when i put the mouse down , at mouseDown i did something like this:
I create my own class rectanglet everything is working but text, because when i click on the trectangle the text area doesnt display all , just a small part and after i enter some text it appears aand the rest but when i tried to change the button because i have buttons for every draw(rectangle , line, clear_all and text) the text dissapears. First i want to know how to save the text and draw it every time i change the shape.
More if i try to delete all the shapes including the JTextArea the textarea reamins there.
Declration variables and stuff



And the paint function




MouseDown event


in the next mouse event
mouseUp i tried to save it in a vector




The problem is that i dont know how to do to remain on the screen, i think is maybe in the paint function.
 
Darryl Burke
Bartender
Posts: 5132
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrei, welcome to the Ranch! Please BeForthrightWhenCrossPostingToOtherSites
http://www.javaprogrammingforums.com/awt-java-swing/5746-drawing-rectangles-lines.html

edit And the recommendation to post an SSCCE still holds good.
 
Kevin Workman
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like I said in the other thread: You've been told what you need to do to get help. That's going to be the case no matter where you go, unless you're paying for a professional tutor. Whether or not you're willing to put forth that effort is up to you.

"No matter where you go" means that even on other forums, you're going to have to post an SSCCE and ask a specific question. Read the SSCCE link. It tells you what to do. Or don't, and don't get help. It's really up to you.
 
Rob Spoor
Sheriff
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although he puts it a bit harshly, Kevin is quite right. If you don't provide us information (and especially with GUI programs, an SSCCE is often required information) we cannot help you. To solve strange behaviour we must often see strange behaviour ourselves.
 
Kevin Workman
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the only reason I stated anything the least bit harshly was because I tried so many times in the other thread to coax an SSCCE or a specific question out, only to have the OP call it quits and jump to another forum even after I told him the SSCCE/question requirement would be true everywhere. Hmph.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic