• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JVeiwporterror

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
i hve following code prgram working good
but component not visible which are scrolled
how can i scroll them help


import java.awt.*;
import javax.swing.*;
import java.net.*;
import java.awt.event.*;


class SDemo2
{
static JScrollBar sv;
static JPanel p;
static JViewport jvp;


public static void main(String a[])




{

JScrollPane j ;
jvp=new JViewport();
sv =new JScrollBar(JScrollBar.VERTICAL,0,0,0,600);
p=new JPanel();

p.setLayout(null);

JFrame f=new JFrame();
JButton b[]=new JButton[100];
//JTextField b[]=new JTextField[90];
int y=10;

for(int i=0; i<15; i++)
{
b[i]=new JButton("High");

b[i].setBounds(10,y,100,50);
y=y+40;

p.add(b[i]);
}



jvp.add(p);
f.getContentPane().add(jvp,BorderLayout.CENTER);
f.getContentPane().add(sv,BorderLayout.EAST);


f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

f.setVisible(true);
f.setSize(500,500);


sv.addAdjustmentListener(new AdjustmentListener()
{
public void adjustmentValueChanged( AdjustmentEvent e)
{

JScrollBar h=(JScrollBar)e.getSource();


Point pt=jvp.getViewPosition();
pt.y=e.getValue();

jvp.setViewPosition(pt);


}});



}




}
 
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ususally if some action manages to make a component
whose setVisible method has been called (with true as the argument),
invisible, calling setSize (i.e. setSize(100,100)) will force the entire componentto become visible.

Its kind of a hack but always seems to work for me.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic