Results 1 to 4 of 4
Thread: Problem with JScrollBar
- 02-18-2010, 05:31 AM #1
Member
- Join Date
- Feb 2010
- Posts
- 1
- Rep Power
- 0
Problem with JScrollBar
When I drag-down ScrollBar, I don't see "Contructor" with Location (20,700). :confused::confused::confused:Java Code:import java.awt.Container; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JScrollBar; class ExamJScrollBar extends JFrame { private JLabel jlb1,jlb2; private JScrollBar jsb; private Container con; public ExamJScrollBar() { con=getContentPane(); con.setLayout(null); jlb1=new JLabel("JSCROLLBAR"); jlb1.setBounds(300, 40, 300, 20); con.add(jlb1); jlb2=new JLabel("Contructor"); jlb2.setBounds(20, 700, 100, 20); con.add(jlb2); jsb=new JScrollBar(); jsb.setBounds(780,0,20,580); con.add(jsb); } public static void main(String[] args) { ExamJScrollBar ex = new ExamJScrollBar(); ex.setVisible(true); ex.setBounds(0,0,800,600); ex.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }
Please! Help me! :)
- 02-18-2010, 07:15 AM #2
Member
- Join Date
- Feb 2010
- Posts
- 1
- Rep Power
- 0
The location of the label "Constructor" is beyond the frame borders (y coordinate). the y-coordinate of the border of the frame is 600 while you are trying to add a label at the y-coordinate 700.
Try changing the
jlb2.setBounds(20, 700, 100, 20);
to
jlb2.setBounds(20, 550, 100, 20);
- 02-18-2010, 07:21 AM #3
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
Better yet learn how to use Layout Managers so you don't have this type of problem. Read the section from the Swing tutorial on Layout Managers.
- 02-19-2010, 02:59 AM #4
Similar Threads
-
A problem with JScrollBar and the Jbutton
By cowboy in forum New To JavaReplies: 5Last Post: 12-19-2009, 09:17 PM -
simple line problem / for loop problem
By helpisontheway in forum New To JavaReplies: 1Last Post: 11-17-2009, 06:12 AM -
JScrollBar
By solomon_13000 in forum AWT / SwingReplies: 1Last Post: 07-01-2009, 07:46 AM -
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