Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Swing-AWT scrollbar in JPanel
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


FaizalArafath
scrollbar in JPanel
1 Answer(s)      4 years and 2 months ago
Posted in : Swing AWT


Scroll bar is not working when i am using the panel layout is null. If i change the panel layout to flow or grid its working. I have a great trouble in this please help me. Here my code.....

import java.awt.*;
import javax.swing.*;
class scroll
{
public static void main(String[] args)
{
Frame f = new Frame ("Demo");
JPanel p = new JPanel();
JButton b1 = new JButton("Button 1");
JButton b2 = new JButton("Button 2");
p.setLayout(null);
p.setBackground(Color.red);
b1.setBounds(100,500,150,20);
b2.setBounds(100,150,150,20);
p.add(b1);
p.add(b2);
JScrollPane s = new JScrollPane(p, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
f.add(s);
f.setSize(70,70);
f.setVisible(true);
}
}

Advertisement
View Answers

October 18, 2010 at 11:17 AM


Hi Friend,

import java.awt.*;
import javax.swing.*;
class scroll
{
public static void main(String[] args)
{
Frame f = new Frame ("Demo");
JPanel p = new JPanel();
JButton b1 = new JButton("Button 1");
JButton b2 = new JButton("Button 2");
p.setBackground(Color.red);
p.add(b1);
p.add(b2);
JScrollPane s = new JScrollPane(p);
f.add(s);
f.setSize(70,70);
f.setVisible(true);
}
} 

Thanks


Related Tutorials/Questions & Answers:
scrollbar in JPanel
scrollbar in JPanel  Scroll bar is not working when i am using... f = new Frame ("Demo");JPanel p = new JPanel();JButton b1 = new..., JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);f.add(s
scrollbar
scrollbar  I add a scrollbar to my Frame and its not working
Advertisements
Java Scrollbar
Java Scrollbar   What is the difference between a Scrollbar and a ScrollPane
vertical scrollbar but without a horizontal scrollbar
vertical scrollbar but without a horizontal scrollbar  How do I make a frame with a vertical scrollbar but without a horizontal scrollbar
Scroll in JPanel
static void main(String[] args) { Frame f = new Frame ("Demo"); JPanel p = new JPanel(); JButton b1 = new JButton("Button 1"); JButton b2 = new JButton("Button 2
Jpanel allignment
Jpanel allignment  i have two panels added one below anotehr. and i have a one button. when i clicked button. the first panel ara should be overlapped with second panel. i mean second panel size should cover both paenls size
Horizontal Scrollbar
Horizontal Scrollbar  How can I implement a horizontal scrollbar
Scrollbar
Scrollbar       A scrollbar is represented by a "slider" widget. The characteristics of it are specified by integer values which are being set at the time of scrollbar
frame with a vertical scrollbar but without a horizontal scrollbar.
frame with a vertical scrollbar but without a horizontal scrollbar.  How do I make a frame with a vertical scrollbar but without a horizontal scrollbar
menu with scrollbar
menu with scrollbar  I want to use MenuBar with Scrollbar. I tried...); bar.add(setting); bar.add(help); JPanel panel=new JPanel(); JButton b1=new...*; public class menu extends JFrame{ private JPanel panel; public menu
Horizontal Scrollbar
Horizontal Scrollbar  I am creating a JSF project that has a print("<af:table/>"); the table is too wide to display in the browser. I was wondering if there was anyway to implement a horizontal scrollbar in this table so
How to add JTable in JPanel
How to add JTable in JPanel  How to add JTable in JPanel
java program:scrollbar
java program:scrollbar  my program logic is that when i scrolling scrollbar according to that the oval shap is changed by fetching the value of scrollbar the oval is drawn please give me a proper code of this logic
CSS ScrollBar Properties
CSS ScrollBar Properties  How can i set ScrollBar properties in CSS? I am using HTML, CSS and Div in my code. Thanks!!   overflow: scroll; overflow-y: scroll; overflow-x: scroll; overflow:-moz-scrollbars-vertical
scrollbar - applet - Applet
scrollbar - applet  Hi!! It is the program for a vertical scroll bar and the output is (small vertical scrollbar). Suppose if I want a lengthy... ScrollbarDemo extends Applet { public void init() { Scrollbar sb = new
Scrollbar problem with struts <layout:collection>
Scrollbar problem with struts   How activate the vertical scrollbar in struts in mozilla firefox
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java... it shows the scrollbar but do not show the scrolling tabs here is my code pls do help... java.awt.TextField.*; public class try1 extends JPanel implements ActionListener,ItemListener
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java... it shows the scrollbar but do not show the scrolling tabs here is my code pls do help... java.awt.TextField.*; public class try1 extends JPanel implements ActionListener,ItemListener
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java... it shows the scrollbar but do not show the scrolling tabs here is my code pls do help... java.awt.TextField.*; public class try1 extends JPanel implements ActionListener,ItemListener
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java... it shows the scrollbar but do not show the scrolling tabs here is my code pls do help... java.awt.TextField.*; public class try1 extends JPanel implements ActionListener,ItemListener
how to add scrollbar to JFrame
how to add scrollbar to JFrame  hello friends i am making a java... it shows the scrollbar but do not show the scrolling tabs here is my code pls do help... java.awt.TextField.*; public class try1 extends JPanel implements ActionListener,ItemListener
Draw bufferimage in jpanel using netbeans
Draw bufferimage in jpanel using netbeans  please i need urgent help. i have form which contains some fields generated in netbeans. how can i draw bufferimage in Jpanel that is inside the form. thanks
div to scrollbar - Java Beginners
vertical scrollbar. for this i am using a css for that div in which i tried to add... who replied my answer.  hi, div and scrollbar html... ""; } function scrollBar(ownerID, ownerContentID, upID, dnID) { this.ownerID
How to draw in jPanel? swing/graphics Java
How to draw in jPanel? swing/graphics Java  How to draw in jPanel? (swing/graphics Java
Draw a line in a JPanel with button click in Java
Draw a line in a JPanel with button click in Java  Draw a line in a JPanel with button click in Java
How to save JPanel as gif or jpeg file
How to save JPanel as gif or jpeg file  i draw polygons , rectangles, lines on jpanel using draw line method drawpolygon methods etc, now i want save the data of jpanel which is drawn by me(lines,polygons) as a gif or jpeg file
Display Multiple Images in jscrollpane using Java Jpanel
Display Multiple Images in jscrollpane using Java Jpanel  Browse and Display multiple images in vertical view of java jscrollpane using jpanel
Visibal Certical scrollbar with struts collection layout.
Visibal Certical scrollbar with struts collection layout.  how to Visibal Vertical scroll bar with struts collection layout
resize image with the change in size of jpanel.. - Java Beginners
resize image with the change in size of jpanel..  hi.. i am try to insert image in jpanel in jform to give attractive look to application,but the of image do not changes if the size of jframe or jpanel changes. if there is any
dropdown to vert. scrollbar - Java Beginners
dropdown to vert. scrollbar  can u please help me how to change a dropdown into scrollbar when we resize th window in java script  Hi friend, drop down example var messages = new Array(6); messages[0
How to save JPanel as gif or jpeg file
How to save JPanel as gif or jpeg file  i draw polygons , rectangles, lines on jpanel using draw line method drawpolygon methods etc, now i want save the data of jpanel which is drawn by me(lines,polygons) as a gif or jpeg file
 

 

 

DMCA.com