0

Recently, i am having problem to add the vertical scrollbar but even if after adding the scrollbar the complete text is not showing and the text is just repainting using repaint() inside adjustment listener.

This is my code:

ver.setBounds(900,100,20,500);
add(ver);
Scrollbar ver;
ver = new Scrollbar(Scrollbar.VERTICAL,0,50,0,500);
ver.setUnitIncrement(2);
ver.setBlockIncrement(5);

ver.addAdjustmentListener(this);

public void adjustmentValueChanged(AdjustmentEvent ae)
{
repaint();
}

Do i have to add anything else for my listener and why is the scrolling not happening properly please comment.

rahulkapoor99
  • 117
  • 10
  • 1) For better help sooner, post an [MCVE](http://stackoverflow.com/help/mcve) (Minimal Complete Verifiable Example). 2) Use a logical and consistent form of indenting code lines and blocks. The indentation is intended to make the flow of the code easier to follow! 3) Why code an applet? If it is due to the teacher specifying it, please refer them to [Why CS teachers should **stop** teaching Java applets](http://programmers.blogoverflow.com/2013/05/why-cs-teachers-should-stop-teaching-java-applets/). 4) Is this using AWT or Swing? 5) An applet should never set it's own size. – Andrew Thompson Nov 08 '14 at 02:57
  • @AndrewThompson this is awt, i cant use swing for my program and can you ellaborate 5 point. – rahulkapoor99 Nov 08 '14 at 04:24
  • *"..i cant use swing for my program.."* Why not? *"..and can you ellaborate 5 point."* Can you first answer my question in point 3? I don't ask these questions for my own amusement. I expect answers. – Andrew Thompson Nov 08 '14 at 04:43
  • about that 3 point..actually it is because im in college and learning java as part of my programme so in the final project i am making quiz system using applet as teacher told me to do but after adding more than 5 questions and its 4 options i am unable to add scrolling to the code. – rahulkapoor99 Nov 08 '14 at 04:53
  • *"..because im in college.."* OK right. And what did your instructor have to say about my thoughts in that blog article? Also re. AWT. Why use AWT? See [this answer](http://stackoverflow.com/questions/6255106/java-gui-listeners-without-awt/6255978#6255978) for many good reasons to abandon AWT using components in favor of Swing. If you reply that is again the teacher consider: A) Changing teachers - that one's teaching obsolete, and more difficult, ways of doing things. B) Smacking them upside the head. They truly deserve it. – Andrew Thompson Nov 08 '14 at 04:59

0 Answers0