Witam przeszukałem już wiele różnych rozwiązań jednak żadne nie działa w stu procentach. Moim celem jest zrobienie aby podczas rozciągania JFrame rozciągał się JPanel w którym jest narysowana plansza. Póki co doszedłem do takiego kodu:
public void paintComponent(Graphics g) {
Graphics offgc;
Image offscreen = null;
// create the offscreen buffer and associated Graphics
offscreen = createImage(this.getWidth(), this.getHeight());
offgc = offscreen.getGraphics();
// clear the exposed area
offgc.setColor(getBackground());
offgc.fillRect(0, 0, this.getWidth(), this.getHeight());
offgc.setColor(getForeground());
// do normal redraw
((Graphics2D)offgc).draw(board);
drawHelpLines(((Graphics2D)offgc));
fig.draw(((Graphics2D)offgc));
for( int i = 0; i < dfig.size(); i++ )
dfig.get(i).draw(((Graphics2D)offgc));
// transfer offscreen to window
// Image asd; // ten asd to po prostu drugi sposób
// asd = null;
// asd = offscreen.getScaledInstance(this.getWidth(),this.getHeight(),Image.SCALE_FAST);
// g.drawImage( asd, 0,0,this);
g.drawImage(offscreen, 0, 0,this.getWidth(),this.getHeight(), this);
}
Może dodam jeszcze że struktura layoutów wygląda mniej więcej tak:
JFrame ma cardlayout i cardPanel w którym jest MenuPanel i oczywiście mój niesforny JPanel. Ten JPanel posiada BorderLayout i w miejsce CENTER wstawiony jest JPanel w którym rysuje się gra, a w miejsce EAST panel z wynikami. Proszę o pomoc bo na prawdę już nie mam pojęcia jak to trzeba zrobić....