![]() |
|
|
|
| ||||||
|
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: |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |||
| [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); } } |
| |
| ||||
| That part is commented though isn't it? therefore it would be looked at as a comment and not cause an error? __________________ ![]() Great looking text - by just typing into a box you can create great looking text for your msn names, myspace, bebo, netlog, facebook and more |
| The Following User Says Thank You to Lee For This Useful Post: | ||
HelloWorld (07-23-2007) | ||
| ||||
| 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? __________________ ![]() Great looking text - by just typing into a box you can create great looking text for your msn names, myspace, bebo, netlog, facebook and more |
![]() |
| Thread Tools | |
| Display Modes | |
| |