The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > Java


Welcome to the The ProgrammersTalk Community 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), respond to polls, upload content and access many other special features. 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 contact us.
Tags:

Closed Thread
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 07-23-2007, 01:57 AM
siri_mail
Posts: n/a
[SOLVED] query on JScrollpane in swings

Hello,
I have created a form with a scrollpane, where the scrollpane is working if i wont give any alignments to the controls
..if i give alignments its not working.Here i am attaching 2 pgms...plz check it and send me the solution asap

// Program with alignments //
import javax.swing.*;
import java.awt.*;

public class Test1 extends JFrame
{
private JLabel jl,jl1,jl2,jl3,jl4,jl5,jl6,jl7,jl8,jl9,jl10,jl11,j l12,jl13,jl14,jl15,jl16,jl17;
private JLabel line,l,l1,l2,l3,l4,l5,l6,l7,l8,l9,l10;
private JTextField jtf,jtf1,jtf2,jtf3,jtf4,jtf5,jtf6,jtf7,jtf8,jtf9,j tf10;
private JTextArea jta,jta1;
private JScrollPane jsp,jsp1;
private JScrollBar jsb;
private JPanel jp;

public Test1()
{
super("Screen");
create();
}
private void create()
{
jp=new JPanel(new GridLayout(0,1));
l=new JLabel("Heading");
l.setBounds(400,40,300,20);
jp.add(l);
l1=new JLabel("First Floor,");
l1.setBounds(300,70,300,20);
jp.add(l1);
l2=new JLabel("Street No,");
l2.setBounds(300,90,300,20);
jp.add(l2);
l3=new JLabel("location.");
l3.setBounds(300,110,300,20);
jp.add(l3);
l4=new JLabel("Phone number.");
l4.setBounds(300,130,300,20);
jp.add(l4);
l5=new JLabel("Street");
l5.setBounds(550,70,300,20);
jp.add(l5);
l6=new JLabel("Location,");
l6.setBounds(550,90,300,20);
jp.add(l6);
l7=new JLabel("City,");
l7.setBounds(550,110,300,20);
jp.add(l7);
l8=new JLabel("State");
l8.setBounds(550,130,300,20);
jp.add(l8);
l9=new JLabel("Phone");
l9.setBounds(550,150,300,20);
jp.add(l9);
l10=new JLabel("Email : info@abc.com");
l10.setBounds(450,170,300,20);
jp.add(l10);
line=new JLabel("__________________________________________ __________________________________________________ __________________________________________________ _______________");
line.setBounds(150,190,800,20);
jp.add(line);

jl=new JLabel("Date :");
jl.setBounds(800,220,100,20);
jp.add(jl);

jl1=new JLabel("<HTML><H2><U>ENQUIRER DETAILS</U></H2></html>");
jl1.setBounds(400,240,200,20);
jp.add(jl1);

jl2=new JLabel("Name:");

jl2.setBounds(250,270,200,40);
jp.add(jl2);
jl3=new JLabel("Address:");
jl3.setBounds(250,335,200,40);
jp.add(jl3);
jl4= new JLabel("Email Address:");
jl4.setBounds(250,370,200,40);
jp.add(jl4);
jl5= new JLabel("Contact Number:");
jl5.setBounds(250,400,200,40);
jp.add(jl5);
jl6= new JLabel("Residence:");
jl6.setBounds(350,420,200,40);
jp.add(jl6);
jl7= new JLabel("Office:");
jl7.setBounds(350,450,200,40);
jp.add(jl7);
jl8= new JLabel("Mobile:");
jl8.setBounds(350,480,200,40);
jp.add(jl8);

jl9= new JLabel("If Working Company Name :");
jl9.setBounds(250,510,200,40);
jp.add(jl9);

jl10= new JLabel("Qualification :");
jl10.setBounds(250,540,200,40);
jp.add(jl10);


jl11= new JLabel("Accademic :");
jl11.setBounds(350,570,200,40);
jp.add(jl11);

jl12= new JLabel("Technical :");
jl12.setBounds(350,600,200,40);
jp.add(jl12);

jl13= new JLabel(" Course ");
jl13.setBounds(250,640,200,40);
jp.add(jl13);

jl14= new JLabel(" Preferred:");
jl14.setBounds(250,680,200,40);
jp.add(jl14);

jl15= new JLabel("Would u like to avail");
jl15.setBounds(250,700,400,40);
jp.add(jl15);

jl16= new JLabel("Verification:");
jl16.setBounds(250,730,400,40);
jp.add(jl16);

jl17= new JLabel("With Reference from :");
jl17.setBounds(250,760,400,40);
jp.add(jl17);


jtf=new JTextField();
jtf.setBounds(850,220,100,20);
jp.add(jtf);

jtf1=new JTextField();
jtf1.setBounds(450,270,300,30);
jp.add(jtf1);

jta1=new JTextArea();
jsp=new JScrollPane(jta1);
jsp.setBounds(450,310,300,50);
jp.add(jsp);

jtf2=new JTextField();
jtf2.setBounds(450,370,300,30);
jp.add(jtf2);

jtf3=new JTextField();
jtf3.setBounds(450,420,150,25);
jp.add(jtf3);

jtf4=new JTextField();
jtf4.setBounds(450,450,150,25);
jp.add(jtf4);

jtf5=new JTextField();
jtf5.setBounds(450,480,150,25);
jp.add(jtf5);

jtf6=new JTextField();
jtf6.setBounds(450,510,300,30);
jp.add(jtf6);

jtf7=new JTextField();
jtf7.setBounds(450,570,150,25);
jp.add(jtf7);

jtf8=new JTextField();
jtf8.setBounds(450,600,300,30);
jp.add(jtf8);

jtf9=new JTextField();
jtf9.setBounds(450,640,300,30);
jp.add(jtf9);

jtf10=new JTextField();
jtf10.setBounds(550,730,400,40);
jp.add(jtf10);

jsb=new JScrollBar(JScrollBar.VERTICAL,30,50,10,150);

// jp.add(jsb);

//jsp=new JScrollPane(jp,JScrollPane.VERTICAL_SCROLLBAR_ALWA YS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
//jsp.setPreferredSize(new Dimension(800,700));

//s jsp.setAutoscrolls(true);

jp.setLayout(new BorderLayout());

getContentPane().add(jsb,BorderLayout.EAST);

add(jp,BorderLayout.CENTER);

setVisible(true);

setSize(1024,1024);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}
public static void main(String args[])
{
Test1 t1=new Test1();
t1.setVisible(true);

}
}

2nd Program

import javax.swing.*;import java.awt.*;
class test
{
public static void main(String args[])
{
JFrame jf= new JFrame();
JPanel jp = new JPanel(new GridLayout(0,1));
JLabel lb1=new JLabel("Heading");
// lb1.setBounds(20,40,200,20);
JLabel lb2=new JLabel("Name");
// lb2.setBounds(60,60,200,20); JLabel lb3=new JLabel("Address");
// lb3.setBounds(400,240,200,20);
JLabel lb4=new JLabel("Qualification");
JLabel lb5=new JLabel("Email Id");
JLabel lb6=new JLabel("Phone");
JLabel lb7=new JLabel("Working Company");
JLabel lb8=new JLabel("Reference");
JTextField jtf1=new JTextField(5);
JTextField jtf2=new JTextField(5);
JTextField jtf3=new JTextField(5);JTextField jtf4=new JTextField(5);
jp.add(lb1); jp.add(jtf1); jp.add(lb2); jp.add(jtf2); jp.add(lb3); jp.add(jtf3);
jp.add(lb4); jp.add(jtf4); jp.add(lb5); jp.add(lb6); jp.add(lb7); jp.add(lb8);
JScrollPane jsp = new JScrollPane(jp);
jsp.setPreferredSize(new Dimension(500,100));
jf.getContentPane().add(jsp, BorderLayout.CENTER);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.pack();
jf.setVisible(true);
}
}

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
  #2 (permalink)  
Old 07-23-2007, 07:13 AM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Quote:
JScrollPane.VERTICAL_SCROLLBAR_ALWA YS
There's a space on your code between ALWA and YS, so I guess that may become the problem

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
  #3 (permalink)  
Old 07-23-2007, 07:20 AM
Lee's Avatar
Lee Lee is offline
PT Staff*
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: Blackpool, UK
Posts: 616
iTrader: (0)
Lee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enough
Quote:
Originally Posted by HelloWorld View Post
There's a space on your code between ALWA and YS, so I guess that may become the problem
That part is commented though isn't it? therefore it would be looked at as a comment and not cause an error?
The Following User Says Thank You to Lee For This Useful Post:
HelloWorld (07-23-2007)
  #4 (permalink)  
Old 07-23-2007, 07:41 AM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Quote:
Hello,
I have created a form with a scrollpane, where the scrollpane is working if i wont give any alignments to the controls
..if i give alignments its not working.Here i am attaching 2 pgms...plz check it and send me the solution asap
I tried to understand what your question, but I don't know where to look for the problem. Are you talking about the 1st or the 2nd program? Both of them are the one that you're working on and have the same problems?

EDIT:
Also, please also tell us what are you trying to create?

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!

Last edited by Lee : 07-23-2007 at 03:17 PM. Reason: User not read since, made sence to merge, keep things clean :)
  #5 (permalink)  
Old 07-23-2007, 07:53 AM
Lee's Avatar
Lee Lee is offline
PT Staff*
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: Blackpool, UK
Posts: 616
iTrader: (0)
Lee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enough
On thinking about this again it would also be great if you could post any debug information such as the line and what error it gives?
Closed Thread


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



All times are GMT -7. The time now is 12:56 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50