Results 1 to 7 of 7
- 06-04-2010, 04:28 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 2
- Rep Power
- 0
problem in adding jscrollbar to panel
hi
please any one can tell how to add jscrollbar to the following code
Moderator Edit: Code tags addedJava Code:import java.awt.*; import javax.swing.JScrollPane; import javax.swing.*; import java.awt.event.*; import java.applet.*; import java.sql.*; public class LoginPage extends JFrame { JComboBox jb; JFrame f2; public static String s1,s2,s3,s4,s5; char ch[]=new char[30]; JTextField f; JPanel jp; JPasswordField f1; Container c; JLabel l1, l2,l3; static JLabel l4=new JLabel("hai"); JButton b1,b2,b3,b4,b5,b6; JScrollPane jsp; ImageIcon im; String s[]={"-------Select------","Incharge","Assistent","Staff","co_staff"}; JComboBox jcb; public static Dimension scrsize; LoginPage() { c=getContentPane(); l3=new JLabel(im); Toolkit toolkit=Toolkit.getDefaultToolkit(); scrsize=toolkit.getScreenSize(); setSize(scrsize.width,scrsize.height-50); jp=new JPanel(); jp.setLayout(null); l1=new JLabel("user name :"); f=new JTextField(30); l2=new JLabel("password :"); f1=new JPasswordField(30); jcb=new JComboBox(s); b1=new JButton("submit"); b2=new JButton("Admin Login"); b3=new JButton("about"); b4=new JButton("Contact us"); b5=new JButton("help"); b6=new JButton("Back to Login Page"); l1.setBounds(450,400,75,25); f.setBounds(600,400,180,25); l2.setBounds(450,500,75,25); l1.setForeground(Color.white); l2.setForeground(Color.white); f1.setBounds(600,500,180,25); l3.setBounds(0,0,scrsize.width,170); jcb.setBounds(830,400,120,25); b1.setBounds(660,610,100,25); b2.setBounds(315,170,180,25); b3.setBounds(495,170,180,25); b4.setBounds(675,170,180,25); b5.setBounds(855,170,180,25); jp.add(l1); jp.add(f); jp.add(jcb); jp.add(l2); jp.add(f1); jp.add(jcb); jp.add(b1); add(b2); add(l4); add(l3); add(b3); add(b4); add(b5); jp.setBackground(Color.darkGray); jp.setForeground(Color.white); add(jsp); jcb.addActionListener(this); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); b4.addActionListener(this); b5.addActionListener(this); b6.addActionListener(this); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } }Last edited by Fubarable; 06-05-2010 at 12:26 AM. Reason: Moderator Edit: Code tags added
- 06-04-2010, 04:42 PM #2
What are you going to control with a JScrollBar?
Or is it a JScrollPane you want?
Have you looked in the java tutorial for how to use them?
- 06-04-2010, 09:16 PM #3
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
the thread is for SWING forum ;)
If my answer helped you. Please click my "REP" button and add a comment
Have a Good Java Coding :)
-
Agree -- Moving.
Also, to the original poster, hello, and welcome to the forum. I hope you don't mind that I edited your code and added code tags which should help make your posted code retain its formatting and be more readable.
To do this yourself, 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:
Best of luck, and again, welcome!Java Code:[code] // your code goes here // notice how the top and bottom tags are different [/code]
Last edited by Fubarable; 06-05-2010 at 12:28 AM.
- 06-05-2010, 03:20 AM #5
Member
- Join Date
- Jun 2010
- Posts
- 2
- Rep Power
- 0
hi NORM sir,
thank u for replying sir
whenever i placed in any 15 inches screen it doesn't show complete window
some of buttons are hide
i want my window is suitable for any computer sir
and i want JSCROLLPANE sir
yes sir i see java tutorial how to add it
but it doesn't work it sir
thanks once again sirLast edited by Mani_4; 06-05-2010 at 03:40 AM.
-
Hello Mani:
Please elaborate because "it doesn't work" tells us nothing about what you're doing wrong. The tutorials have worked for me and most other Swing coders here. For example, in your code above, you're adding a JScrollPane to a container, but you don't appear to be adding anything that you want scrolled to the JScrollPane's viewport, so the code above doesn't conform to the tutorials instructions and of course won't work.
I suggest you create a very small program that tries to use a JScrollPane, and then if it doesn't work, post the complete program together with any error messages you may have received, and then we'll be able to help you.
Much luck!
- 06-06-2010, 11:46 AM #7
clear, if you don't use any layout to place your components, each add() will override the previous component. so sir, study this first.
Similar Threads
-
Problem with JScrollBar
By Arthur in forum AWT / SwingReplies: 3Last Post: 02-19-2010, 02:59 AM -
Adding a panel to a panel
By rclausing in forum New To JavaReplies: 7Last Post: 02-02-2010, 05:56 AM -
A problem with JScrollBar and the Jbutton
By cowboy in forum New To JavaReplies: 5Last Post: 12-19-2009, 09:17 PM -
Adding components to a panel
By jboy in forum New To JavaReplies: 1Last Post: 10-10-2009, 01:02 PM -
problem with jscrollbar in my applet
By leonard in forum Java AppletsReplies: 1Last Post: 08-03-2007, 11:39 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks