Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-12-2009, 07:51 PM
Member
 
Join Date: Oct 2008
Posts: 21
Rep Power: 0
kumar_gemi is on a distinguished road
Default panel resizing
Hello,

I am using a free layout and I am using panel.getGraphics method to draw. I figured it out that the panel size is not resizing . COuld someone guide me how to overcome that. I am using net beans .

Thanks in Advance
kumar
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 03-12-2009, 10:04 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,469
Rep Power: 8
Fubarable is on a distinguished road
Default
We need a bit more information. Also you may be using a wrong layout manager. have you gone over the layout manager tutorial at the Sun Swing tutorials? If not, you should as it will help you.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 03-13-2009, 03:39 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,469
Rep Power: 8
Fubarable is on a distinguished road
Default
Quote:
I have added the code for your kind reference. I am trying draw some vertical lines in drawPanel and the size is not changing. So I am unable to use the scrollbar. I didnt use any layout managers as I used netbeans and the layout manager I used is freedesign just drag and drop.
I suggest that you learn how to use other layout managers, managers that may help you resize your panel better. You can read up on them here: Lesson: Laying Out Components Within a Container (The Java™ Tutorials > Creating a GUI with JFC/Swing)

Also, when posting code here, please use code tags so that your code will retain its formatting and thus will be readable -- after all, your goal is to get as many people to read your post and understand your code as possible, right?

To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.

Another way to do this is to manually place the tags into your code by placing the tag [code] above your pasted code and the tag [/code] below your pasted code like so:

Code:
[code]
  // your code goes here
  // notice how the top and bottom tags are different
[/code]
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 03-13-2009, 03:51 AM
Member
 
Join Date: Oct 2008
Posts: 21
Rep Power: 0
kumar_gemi is on a distinguished road
Default
I am really sorry. Thank you for your help.
Code:
//code to draw vertical lines





Graphics g = drawPanel.getGraphics();


Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASIN G,RenderingHints.VALUE_ANTIALIAS_ON);


int dwidth = 0;
dwidth = (width/20) ;//10=processmax

if(dwidth < 30)
{
dwidth = 70;
}

int dheight = 0;
dheight = height - 50;




int x1 = 30 ; //left
int y1 = 50; //top --- Constant value
int x2 = 30 ; //right
int y2 = dheight; //bottom
int y3 = y1-10; //for process no. string
int x3 = x1-5;

for (int i = 0;i <= 20;i++)
{
g2.setColor(Color.BLACK);
g2.drawLine(x1, y1, x2, y2);
g2.setColor(Color.BLUE);
g2.drawString("P"+i,x3 , y3);
x1 = (x1 + dwidth);
x2 = (x2 + dwidth);
x3 = (x1 - 10);

}



int height1 = drawPanel.getHeight();
int width1 = drawPanel.getWidth();
System.out.println("Height of DrawPanel new " + height1);
System.out.println("Width of DrawPanel new " + width1);

JScrollPane scroll = new JScrollPane(drawPanel);

scroll.setSize(600,800);
if(drawPanel .getSize().height > scroll.getSize().height)
{ scroll.createVerticalScrollBar(); }

if(drawPanel.getSize().width>scroll.getSize().widt h)
{ scroll.createHorizontalScrollBar(); }
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

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

BB 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
Image Resizing and DPi Rob_ Java Applets 4 11-27-2008 03:21 PM
Flicker with resizing and need general code examination MrFreeweed Java 2D 2 11-17-2008 06:41 AM
panel positioning shwein New To Java 4 09-09-2008 06:15 PM
add image on panel samiksha.goel AWT / Swing 4 08-02-2008 08:38 PM
Image resizing alley Java 2D 2 11-13-2007 11:10 AM


All times are GMT +2. The time now is 07:53 PM.



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