Java Swing Not Rendering Correctly -
i have been working on project. in 1 part of project needed draw on jpanel. graphics2d object passed model part of framework , model draw whatever needs draw @ instance. problem jframe not rendered correctly. looks half white shaded , not painting correctly. works fine on laptop (sony vaio, windows7) it's not rendering correctly in other systems tested (2 dell laptops,windows8;1 thoshiba,windows7;1 samsung, windows8). it's rendering correctly on few other systems teammate tested.
i'm sure there no errors made in model part. problem doesn't seem rendering on jpanel. 1 information can give we're doing our project in netbeans. perhaps code generated netbeans ide causing problem? checked code couldn't identify problem. it's difficult post sscce share screen shots of issue.
ok since don't have enough reputation post images see links below....
[displays wrongly][1] [displays wrongly][2] [displays correctly on system][3] [displays correctly on system][4]
i tried debug can't know problem is.... update it's not sscce may help
code jframe....
<pre> import btapp.question; import btapp.qgens.qgengeomabstract; import btapp.qgens.qgeni; import java.awt.graphics; import java.util.arraylist; import javax.swing.jpanel; public class uitestgeomframe extends javax.swing.jframe implements uiframei, uigeomframeabstract { /** * creates new form uitestgeomframe */ public uitestgeomframe() { initcomponents(); } /** * method called within constructor initialize form. * warning: not modify code. content of method * regenerated form editor. */ @suppresswarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="generated code"> private void initcomponents() { jlabel1 = new javax.swing.jlabel(); unittestgeompanel1 = new btapp.ui.unittestgeompanel(); setdefaultcloseoperation(javax.swing.windowconstants.exit_on_close); jlabel1.settext("draw panel junittestcase"); unittestgeompanel1.setborder(javax.swing.borderfactory.createlineborder(new java.awt.color(0, 0, 0))); javax.swing.grouplayout unittestgeompanel1layout = new javax.swing.grouplayout(unittestgeompanel1); unittestgeompanel1.setlayout(unittestgeompanel1layout); unittestgeompanel1layout.sethorizontalgroup( unittestgeompanel1layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addgap(0, 406, short.max_value) ); unittestgeompanel1layout.setverticalgroup( unittestgeompanel1layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addgap(0, 260, short.max_value) ); javax.swing.grouplayout layout = new javax.swing.grouplayout(getcontentpane()); getcontentpane().setlayout(layout); layout.sethorizontalgroup( layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addgroup(javax.swing.grouplayout.alignment.trailing, layout.createsequentialgroup() .addcontainergap(160, short.max_value) .addcomponent(jlabel1, javax.swing.grouplayout.preferred_size, 263, javax.swing.grouplayout.preferred_size) .addgap(142, 142, 142)) .addgroup(layout.createsequentialgroup() .addgap(76, 76, 76) .addcomponent(unittestgeompanel1, javax.swing.grouplayout.preferred_size, javax.swing.grouplayout.default_size, javax.swing.grouplayout.preferred_size) .addcontainergap(javax.swing.grouplayout.default_size, short.max_value)) ); layout.setverticalgroup( layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addgroup(layout.createsequentialgroup() .addcontainergap() .addcomponent(jlabel1) .addgap(30, 30, 30) .addcomponent(unittestgeompanel1, javax.swing.grouplayout.default_size, javax.swing.grouplayout.default_size, short.max_value) .addcontainergap()) ); 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(uitestgeomframe.class.getname()).log(java.util.logging.level.severe, null, ex); } catch (instantiationexception ex) { java.util.logging.logger.getlogger(uitestgeomframe.class.getname()).log(java.util.logging.level.severe, null, ex); } catch (illegalaccessexception ex) { java.util.logging.logger.getlogger(uitestgeomframe.class.getname()).log(java.util.logging.level.severe, null, ex); } catch (javax.swing.unsupportedlookandfeelexception ex) { java.util.logging.logger.getlogger(uitestgeomframe.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 uitestgeomframe().setvisible(true); } }); } // variables declaration - not modify private javax.swing.jlabel jlabel1; private btapp.ui.unittestgeompanel unittestgeompanel1; // end of variables declaration @override public void presentquestions(question qo, int qno) { arraylist qd = qo.getquestiondraw(); unittestgeompanel1.setqobject(qd); unittestgeompanel1.repaint(); } @override public void presentanswers(question qo, int qno) { arraylist ad = qo.getanswerdraw(); unittestgeompanel1.setqobject(ad); unittestgeompanel1.repaint(); } @override public void presentquestions(question qo, int qno, qgeni qg) { unittestgeompanel1.setqgen(qg, qo, 0); unittestgeompanel1.repaint(); } @override public void presentanswers(question qo, int qno, qgeni qg) { unittestgeompanel1.setqgen(qg, qo, 1); unittestgeompanel1.repaint(); } @override public int getheight(){ return unittestgeompanel1.getheight(); } @override public int getwidth(){ return unittestgeompanel1.getwidth(); } } </pre>
code jpanel
import btapp.question; import btapp.qgens.qgengeomabstract; import btapp.qgens.qgeni; import java.awt.graphics; import java.awt.graphics2d; import java.awt.shape; import static java.awt.image.imageobserver.height; import static java.awt.image.imageobserver.width; import java.util.arraylist; public class unittestgeompanel extends javax.swing.jpanel { private int type; /** * creates new form unittestgeompanel */ public unittestgeompanel() { initcomponents(); } /** * method called within constructor initialize form. * warning: not modify code. content of method * regenerated form editor. */ @suppresswarnings("unchecked") // private void initcomponents() { javax.swing.grouplayout layout = new javax.swing.grouplayout(this); this.setlayout(layout); layout.sethorizontalgroup( layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addgap(0, 400, short.max_value) ); layout.setverticalgroup( layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addgap(0, 300, short.max_value) ); }// // variables declaration - not modify // end of variables declaration arraylist dal = new arraylist(); private double h, w; @override public void paintcomponent(graphics g) { super.paintcomponent(g); system.out.println("repainign based on qo object of type "+type); if(type == 0){ qg.presentquestions(qo, (graphics2d)g); } else if(type == 1) qg.presentanswers(qo, (graphics2d)g); } void setqobject(arraylist dal) { this.dal = dal; } qgeni qg; question qo; void setqgen(qgeni qg, question qo, int type) { this.qo = qo; this.qg = qg; this.type = type; } }
please me... in advance
edit: days later problem occurs in system not worse. please refer images in comment.
i had same problem, changed display setting high performance , solved problem (in windows 8 , java 1.8).
Comments
Post a Comment