Veröffentlicht 1. Juni 200421 j Hallo Wie bekomme ich ein Canvas in ein JScrollPane? Ich hatte es schon drinne allerdings schob sich das Canvas beim Scrollen sowohl über meine Toolbar als auch über mein Menü; Hier der wichtigste Code: public class MainFrame extends JFrame { public MainFrame() { super("Komodo Projekt"); this.getContentPane().setLayout(new BorderLayout()); this.setSize(700,500); createMenu(); createToolbar(); addCanvas(); this.show(); } private void addCanvas() { this.getContentPane().add(new JScrollPane( new DrawingCanvas())); } . . . public static void main(String[] args) { new MainFrame(); } } ______________________________________________________________ public class DrawingCanvas extends Canvas{ public DrawingCanvas() { super(); this.setSize(640,480); this.setBackground(Color.WHITE); } } Kann mir jemand weiterhelfen??
2. Juni 200421 j Hallo Wie bekomme ich ein Canvas in ein JScrollPane? Ich tippe mal einfach darauf, dass das Problem die Mischung von AWT- (Canvas) und Swing-Komponenten (JScrollPane) ist. Das gibt in aller Regel immer Probleme. Ciao Christian
2. Juni 200421 j Autor Was könnte ich sonst als geeignete Zeichenfläche nehmen, wenn nicht ein Canvas? Ein einfaches JPanel? Oder hat jemand einen Vorschlag wie ich die Zeichenfläche für eine "Paint"-Imitation mit Swing erstelle?
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.