This forum is excellent.

I've doing this practice project in drawing PostalAddress GUI
i created the jpanel and jframe also file but its sems i got lots of error every time i modify it please take a look and help me i've shown lots of effort thanks guys.

// Draws a panel.
import java.awt.Graphics; 
import javax.swing.JPanel;
public class DrawPanel extends JPanel
PostalAddress DrawingAddress;

drawingAddress = myAddress;
} // end of constructor 
// draws Rectangle
public void paintComponent( Graphics g )
// call paintComponent to ensure the panel displays correctly
super.paintComponent( g );

int width = getWidth(25); // total width 
int height = getHeight(35); // total height
// draw from the upper-left to the lower-right
g.drawLine( 25, 35, width, height );

// draw from the lower-left to the upper-right
g.drawLine( 35, height, width, 25 );
} // end method paintComponent
} // end class DrawPanel

// Application to display a DrawPanel.
import javax.swing.JFrame;
public class DrawPanelTest
public static void main( String args[] )
// create a panel that contains our drawing
DrawPanelTest panel = new DrawPanelTest(myAddress);

// create a new frame to hold the panel
JFrame application = new JFrame();

// set the frame to exit when it is closed
application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
application.add( panel ); // add the panel to the frame 
application.setSize( 25,35 ); // set the size of the frame
application.setVisible( true ); // make the frame visible 
} // end main
} // end class DrawPanelTest

public class PostalAddress
private String name;
private String streetAddress;
private String city;
private String state;
private String zipcode;
private String plusFour;
} // end of constructor
public void drawAddress(Graphics g, int x, int y)


This is were i git stuck Much appriciating about this lesson exam is coming up i needed the practice thanks

Recommended Answers

All 2 Replies

Member Avatar for iamthwee

point to the part ur stuck on.

I'm stuck on the JPanel and postalAddress,please any idea


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.