Hi,
Anyone know what is the problem? how to make it paint correctly when scroll?
import javax.swing.*; import java.awt.*; public class MainClass extends JFrame{ public static void main(String[] args){ MainClass aa = new MainClass(); aa.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); bb b = new bb(); b.setPreferredSize(new Dimension(1000, 1000)); JScrollPane sp = new JScrollPane(b); aa.getContentPane().add(sp); aa.setSize(100,100); aa.setVisible(true); aa.repaint(); } } class bb extends JPanel{ public void paint(Graphics g){ // g.drawString("hihihihi",20,20); } }
[Edited]
It is solved, i just nid to repaint the jframe everytime i adjust the scrollbar. case closed. thanks.