ho questo jframe con dentro un jpanel, un jscrollpane e un jbutton.
il jpanel ha come sfondo una immagine totale del desktop.
teoricamente quindi il jpanel dovrebbe essere più grande del proprio contenitore.
però nn scrolla:
il jframe è richiamato da un'altra classe e si avvia massimizzato:codice:public class DrawPanel extends JFrame { private JButton button; private JScrollPane scroll; public DrawPanel(String path) { super("Draw panel"); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setLayout(new BorderLayout()); button = new JButton("Capture"); imagePanel panel = new imagePanel(path); scroll = new JScrollPane(); scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scroll.setViewportView(panel); add(scroll, BorderLayout.CENTER); add(button, BorderLayout.SOUTH); } private class imagePanel extends JPanel implements MouseListener, MouseMotionListener { private BufferedImage buff; private Rectangle currentRect; private String fileDelete; private int xx = 0; private int yy = 0; private int w = 0; private int h = 0; public imagePanel(String path) { setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); fileDelete = path; try { buff = ImageIO.read(new File(path)); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { capture(e); } }); .........
ho cercato anche su un libro che ho a casa e già ho scritto più codice degli esempi.codice:DrawPanel panel = new DrawPanel(percorso); panel.setVisible(true); panel.setExtendedState(JFrame.MAXIMIZED_BOTH);

Rispondi quotando

