Newsgroup: it.comp.java
Titolo: Richiesta info per resize dinamico

Salve a tutti, grazie per chi vorrï¿œ aiutarmi.
Sto scrivendo una classe che mi visualizza un file di mia scelta, e 
avrei la necessita di ridimensionare il jPanel nel JFrame principale al 
ridimesnionamento dello stesso, il JPanel non ï¿œ standard, in quanto sto 
ridefinendo la paint. Sapreste indicarmi la strada la per ridimensionare 
il ciï¿œ che viene visualizzato nel JPanel?
Di seguito vi allego le due Classi:
************************************************************************
*								       *
*	                    ReportClass.java			       *
*    								       *
************************************************************************
package my.easyreport;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.UIManager;
/**
  *
  * @author Patrick
  */
public class ReportClass extends JFrame {
  private final Dimension screenSize = 
Toolkit.getDefaultToolkit().getScreenSize();
  private final Dimension initSize = new Dimension(screenSize.width  / 
2, screenSize.height / 2);
  public boolean isResized(Dimension actualSize) {
   if ((actualSize.width > initSize.width) || (actualSize.height > 
initSize.height)) {
     return true;
  }
   return false;
  }
  public ReportClass(){
  }
  public static void main(String[] args) {
   try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (Exception e) {
   }
   ReportClass appGui = new ReportClass();
   JScrollPane appScrPnl = new JScrollPane();
   DocumentPanel dcmntPnl = new DocumentPanel(appGui.initSize);
 
appGui.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
   appGui.setTitle("Easy Report Class");
   appGui.setPreferredSize(appGui.initSize);
   appScrPnl.setViewportView(dcmntPnl);
   appGui.add(appScrPnl);
   appGui.pack();
   appGui.setVisible(true);
  }
}
************************************************************************
*								       *
*	                    DocumentPanel.java			       *
*    								       *
************************************************************************
/*
  * To change this template, choose Tools | Templates
  * and open the template in the editor.
  */
package my.easyreport;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JPanel;
/**
  *
  * @author Patrick
  */
public class DocumentPanel extends JPanel implements AppConstant{
  private Dimension appSize;
  public DocumentPanel(Dimension constructorAppSize) {
   updateSize(constructorAppSize);
  }
  public void updateSize(Dimension newSize) {
   appSize = newSize;
   this.repaint();
  }
  @Override
  public void paint(Graphics g) {
   Graphics2D g2 = (Graphics2D) g;
   g2.setColor(BGCOLOR);
   g2.fillRect(STARTX, STARTY, (appSize.width - OFFSET), (appSize.height 
+ OFFSET));
   g2.setColor(WHITE);
   g2.fillRect(STARTX + 10, STARTY + 10, (appSize.width - (OFFSET * 3)), 
(appSize.height - (OFFSET * 3)));
  }
}

 1KVisualizzaScarica
Prova a impostare il layout di ReportClass come un BorderLayout:
    ...
    ReportClass appGui = new ReportClass();
    appGui.setLayout(new BorderLayout());
    JScrollPane appScrPnl = new JScrollPane();
    ...
    appGui.add(appScrPnl, BorderLayout.CENTER);
    ...
ciao

 ciao
Ale grazie per la risposta, prover� e ti far� sapere