473,434 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

Swing draw points

I want to loop through an array of numbers and use those to plot points. What method should I be thinking of? I know there's one that takes an X and Y coordinate and draws points. Is there one that draws bars, too?
Nov 24 '08 #1
4 5467
JosAH
11,448 Expert 8TB
@KiddoGuy
A bar basically is just a rectangle; a Graphics object can draw rectangles.

kind regards,

Jos
Nov 25 '08 #2
Ok, thanks. Can you give me a sample usage? Or is something like this correct?
Expand|Select|Wrap|Line Numbers
  1. java.awt.Panel panel = new java.awt.Panel();
  2. panel.getGraphics().drawRect(1,2,3,4);
  3.  
Would something like that work?
Nov 25 '08 #3
Actually, now my problem is when I'm trying to draw on a Panel. When I call getGraphics() it returns null...
Nov 25 '08 #4
JosAH
11,448 Expert 8TB
@KiddoGuy
Read Sun's Swing tutorial. The AWT event dispatch thread calls the paint() method which calls the paintComponent() method; that's the method you have to override (re-implement) if you want to draw your own stuff. Your approach is not going to work.

kind regards,

Jos
Nov 25 '08 #5

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

Similar topics

5
by: Chris | last post by:
Having been traumatised many years ago when using MFC/C++ to develop front-end code, I've religiously avoided GUI work since and stuck to back-end / server-side projects. So I'm a bit of a novice...
6
by: Joseph | last post by:
hi 1) i plan on having an awt canvas component (to draw graphs) on a JFrame with other swing components..will this be okay? i've read that swing and awt aren't compatible.. 2)Also, if i...
2
by: frank_ulbricht | last post by:
Hi folks, I'm a Java programmer and now I have to use C# for a new large project. The language is the best I've ever seen. In some points it goes far beyond Java. I like that. But then there...
4
by: thomasp | last post by:
I found the following code on MSDN to draw a line in VB2005. Public Sub DrawLinePoint(ByVal e As PaintEventArgs) ' Create pen. Dim blackPen As New Pen(Color.Black, 3) ' Create points that...
1
by: balakrishnan.dinesh | last post by:
Hi frnds, Im creating function to plot line graph in javascript . I have marked the points in graph. but what i need to do is, i want to draw the line between those marked point, but i dont...
5
by: lgeastwood | last post by:
I have tweaked the PictureBox97.mdb (Stephen Lebans <www.lebans.com>) code to nicely draw lines, rectangles and circles to the specs that I input. I'm at a loss though with trying to setup an...
1
by: jojojjose | last post by:
function draw() { var s=''; s+='<v:polygon points="'; s+= //points from server s+="> </v:polygon>'"; document.wrie(s); }
3
by: aleplgr | last post by:
Hi! I'm trying to draw some filled rectangles in a JPanel, should I define a paintComponent like this? public void paintComponent(Graphics g) { super.paintComponent(g); ...
6
by: r035198x | last post by:
I have put together this article to give people starting Swing an awareness of issues that need to be considered when creating a Swing application. Most of the Swing tutorials that I have seen just...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.