java - drawLine won't show up -
hi i'm halfway through simple gui , can't seem figure out why drawlines etc not drawing onto page. want draw intersecting lines onto drawingpanel before adding slider adjust lines intersect, can't seem them show. i'm new java, , code not quite complete appreciated! thanks
jpanel
package jpanel; import java.awt.*; import javax.swing.*; public class jpanel { public static void main(string[] args) { jframe frame = new jframe("gui design"); frame.setdefaultcloseoperation (jframe.exit_on_close); boxlayout layout = new boxlayout (frame.getcontentpane(), boxlayout.x_axis); frame.setlayout(layout); jpanel drawingpanel = new jpanel(); jpanel controlpanel = new jpanel(); controlpanel.setbackground (color.white); controlpanel.setpreferredsize (new dimension (200, 500)); drawingpanel.setpreferredsize (new dimension (500, 500)); frame.setsize(700,500); jlabel label1 = new jlabel ("quadrant"); jlabel label2 = new jlabel ("x: " + x + ", y: " + y); double x=0; double y=0; jslider slide = new jslider(); slide.setorientation(swingconstants.horizontal); slide.setminimum(1); slide.setmaximum(4); controlpanel.add (label1); controlpanel.add (slide); controlpanel.add (label2); frame.getcontentpane().add(drawingpanel); frame.getcontentpane().add(controlpanel); frame.pack(); frame.setvisible(true); } }
drawingpanel
package drawingpanel; import javax.swing.*; import java.awt.*; import java.util.*; public class drawingpanel extends jpanel { public void paint (graphics page) { super.paintcomponent (page); page.drawline(10, 10, 180, 300); //i have tried messing around can't draw. //super.paintcomponent returns 'cannot find symbol' error //which confused about. code imcomplete } }
Comments
Post a Comment