java - JScrollPane not working with JInternalFrame -
i'm trying use jscrollpane in program. need see horizontal , vertical scroll bar when change position of internal frame.
i write code (by drag , drop) below:
package test; public class test2 extends javax.swing.jframe { public test2() { initcomponents(); } @suppresswarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="generated code"> private void initcomponents() { jpanel1 = new javax.swing.jpanel(); jscrollpane1 = new javax.swing.jscrollpane(); jdesktoppane1 = new javax.swing.jdesktoppane(); jinternalframe1 = new javax.swing.jinternalframe(); setdefaultcloseoperation(javax.swing.windowconstants.exit_on_close); jscrollpane1.setautoscrolls(true); jinternalframe1.setclosable(true); jinternalframe1.setmaximizable(true); jinternalframe1.setresizable(true); jinternalframe1.setvisible(true); javax.swing.grouplayout jinternalframe1layout = new javax.swing.grouplayout(jinternalframe1.getcontentpane()); jinternalframe1.getcontentpane().setlayout(jinternalframe1layout); jinternalframe1layout.sethorizontalgroup( jinternalframe1layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addgap(0, 424, short.max_value) ); jinternalframe1layout.setverticalgroup( jinternalframe1layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addgap(0, 271, short.max_value) ); jinternalframe1.setbounds(70, 50, 440, 300); jdesktoppane1.add(jinternalframe1, javax.swing.jlayeredpane.default_layer); jscrollpane1.setviewportview(jdesktoppane1); javax.swing.grouplayout jpanel1layout = new javax.swing.grouplayout(jpanel1); jpanel1.setlayout(jpanel1layout); jpanel1layout.sethorizontalgroup( jpanel1layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addcomponent(jscrollpane1, javax.swing.grouplayout.default_size, 674, short.max_value) ); jpanel1layout.setverticalgroup( jpanel1layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addcomponent(jscrollpane1, javax.swing.grouplayout.default_size, 491, short.max_value) ); javax.swing.grouplayout layout = new javax.swing.grouplayout(getcontentpane()); getcontentpane().setlayout(layout); layout.sethorizontalgroup( layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addcomponent(jpanel1, javax.swing.grouplayout.default_size, javax.swing.grouplayout.default_size, short.max_value) ); layout.setverticalgroup( layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addcomponent(jpanel1, javax.swing.grouplayout.default_size, javax.swing.grouplayout.default_size, short.max_value) ); pack(); }// </editor-fold> /** * @param args command line arguments */ public static void main(string args[]) { /* set nimbus , feel */ //<editor-fold defaultstate="collapsed" desc=" , feel setting code (optional) "> /* if nimbus (introduced in java se 6) not available, stay default , feel. * details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { (javax.swing.uimanager.lookandfeelinfo info : javax.swing.uimanager.getinstalledlookandfeels()) { if ("nimbus".equals(info.getname())) { javax.swing.uimanager.setlookandfeel(info.getclassname()); break; } } } catch (classnotfoundexception ex) { java.util.logging.logger.getlogger(test2.class.getname()).log(java.util.logging.level.severe, null, ex); } catch (instantiationexception ex) { java.util.logging.logger.getlogger(test2.class.getname()).log(java.util.logging.level.severe, null, ex); } catch (illegalaccessexception ex) { java.util.logging.logger.getlogger(test2.class.getname()).log(java.util.logging.level.severe, null, ex); } catch (javax.swing.unsupportedlookandfeelexception ex) { java.util.logging.logger.getlogger(test2.class.getname()).log(java.util.logging.level.severe, null, ex); } //</editor-fold> /* create , display form */ java.awt.eventqueue.invokelater(new runnable() { public void run() { new test2().setvisible(true); } }); } // variables declaration - not modify private javax.swing.jdesktoppane jdesktoppane1; private javax.swing.jinternalframe jinternalframe1; private javax.swing.jpanel jpanel1; private javax.swing.jscrollpane jscrollpane1; // end of variables declaration }
how do that? googled lot, either used wrong keywords or there no simple solutions on internet. hope here can me.
Comments
Post a Comment