473,503 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Drawing a line to JFrame???

10 New Member
hi guys, my line doesn't appear on the frame. what's the problem?

import java.util.*;
import java.io.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.*;

public class Operation {

public static void main(String args[]){
DrawPanel panel = new DrawPanel();
JFrame frame = new JFrame("Voronoi Diagram");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
frame.add(panel);
frame.setSize(800, 600);
frame.setLocation(220, 150);
frame.setVisible(true);
}
}

public class DrawPanel extends JPanel{

private static final long serialVersionUID = 1L;

public void PaintComponent(Graphics g){
super.paintComponent(g);
g.setColor(Color.orange);
g.drawLine(5, 10, 50, 60);
}
}
Mar 14 '08 #1
2 10589
BigDaddyLH
1,216 Recognized Expert Top Contributor
hi guys, my line doesn't appear on the frame. what's the problem?

public void PaintComponent(Graphics g){ // <-- mistake on this line
super.paintComponent(g);
g.setColor(Color.orange);
g.drawLine(5, 10, 50, 60);
}
}
You misspelled "paintComponent" -- it starts with a lowercase 'p'.

In Java versions 5 or later, you can use the attribute @Override to catch this sort of typo:

Expand|Select|Wrap|Line Numbers
  1. @Override
  2. protected void paintComponent(Graphics g) {
  3.     super.paintComponent(g);
  4.     ///etc...
  5. }
http://java.sun.com/j2se/1.5.0/docs/...notations.html
Mar 14 '08 #2
zahit
10 New Member
thanks, it took so much time for me :-)
Mar 16 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

19
4781
by: Atif | last post by:
Hello all, In my html page I want to add an image say of 800x600. Now I want that when ever I am given two coordinates on this image say (x1, y1)=(50, 100) and (x2, y2)=(200, 300), the java script...
3
45946
by: Bob | last post by:
Hello, I am trying to draw a line across a page. The problem is that it is affecting the text subsequent text. I may be doing something wrong with the html but I am not sure. You can see the...
2
11249
by: Anand Ganesh | last post by:
Hi All, In my application I am allowing the user to draw a line. But when the user clicks the start point and starts moving the mouse there is a series of line generated. When the mouse is up...
3
6921
by: Evo | last post by:
Below is my code,it passed the compile and link under TC2.0 correctly. But the line it draws is obviously wrong. I think it's somewhere I thought wrong. But I really can't find it out. Can someone...
0
1728
by: SurajPrabhu | last post by:
Hi All, I am tying to build a ASP.net 2.0 based web page which displays a Analog Guage ( 0 to 180 degrees) with an Arrow in the middle. The application accepts the Percentage as input from a...
2
1966
by: rkgarimella9 | last post by:
Friends, i'm facing with a severe problem while coding an windows application. the problem is that i'm using a usercontrol consisting of three labels upon which three images are placed. the problem...
1
6595
by: dishal | last post by:
Can anyone help me please? How do I convert these codes to launch from a JFrame instead of a Java Applet? A simple program where the user can sketch curves and shapes in a variety of...
0
1186
by: aseem | last post by:
how to drawline between two user control using mousedown and mouseup events in c#.net I am using radiobutton_MouseDown and radiobutton_MouseUp events the user control are dropped on the panel...
4
3766
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I've windows form, in this form i've a panel. I want to draw lines inside the panel using the panel coordinates( meaing that the left upper corner of the panel is 0,0), how can i do it? ...
10
14651
Mas Juliza Alias
by: Mas Juliza Alias | last post by:
I have a table (MSFlexgrid1) in a form (frmCalculate) containing 2 columns of Depth and Volume data. I want to draw a line graph of Depth Vs Volume in a new form (frmGraph) by using MSChart control....
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7074
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7322
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1501
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.