473,406 Members | 2,451 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,406 software developers and data experts.

3d Shape

176 100+
Hello guys. How do you draw a 3d shape in a GUI? Here is my code:
Expand|Select|Wrap|Line Numbers
  1. import javax.swing.SwingUtilities;
  2. import javax.swing.JFrame;
  3. import javax.swing.JPanel;
  4. import javax.swing.BorderFactory;
  5. import java.awt.Color;
  6. import java.awt.Dimension;
  7. import java.awt.Graphics;
  8.  
  9. public class SwingPaintDemo2 {
  10.  
  11.     public static void main(String[] args) {
  12.         SwingUtilities.invokeLater(new Runnable() {
  13.             public void run() {
  14.                 createAndShowGUI(); 
  15.             }
  16.         });
  17.     }
  18.  
  19.     private static void createAndShowGUI() {
  20.         System.out.println("Created GUI on EDT? "+
  21.         SwingUtilities.isEventDispatchThread());
  22.         JFrame f = new JFrame("Swing Paint Demo");
  23.         f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
  24.         f.add(new MyPanel());
  25.         f.pack();
  26.         f.setVisible(true);
  27.     }
  28. }
  29.  
  30.  
  31. class MyPanel extends JPanel {
  32.  
  33.     public MyPanel() {
  34.         setBorder(BorderFactory.createLineBorder(Color.black));
  35.     }
  36.  
  37.     public Dimension getPreferredSize() {
  38.         return new Dimension(250,200);
  39.     }
  40.  
  41.     public void paintComponent(Graphics g) {
  42.         super.paintComponent(g);       
  43.  
  44.         // 3d shape code goes here
  45.     }  
  46. }
  47.  
May 8 '08 #1
6 1711
BigDaddyLH
1,216 Expert 1GB
Please define "3D shape". I am a poor programmer who can only afford a flat screen.
May 8 '08 #2
JosAH
11,448 Expert 8TB
Please define "3D shape". I am a poor programmer who can only afford a flat screen.
:-) I think the OP is talking about eye points, view cones and projections and such.

kind regards,

Jos (<--- on a paper tape ;-)
May 9 '08 #3
Kid Programmer
176 100+
:-) I think the OP is talking about eye points, view cones and projections and such.

kind regards,

Jos (<--- on a paper tape ;-)
You are right JosAH. Cones, cube, pyramids etc.
May 9 '08 #4
JosAH
11,448 Expert 8TB
You are right JosAH. Cones, cube, pyramids etc.
I didn't say that, I mentioned the technology participants in 3D projection math.
You can either google for it (it is simple 101 geometry) or use the Java3D package
that does it for you but it also does a whole lot more.

kind regards,

Jos
May 9 '08 #5
BigDaddyLH
1,216 Expert 1GB
As Woody Allen said, "Students achieving Oneness will move on to Twoness", perhaps you should consider 3D only after you have mastered 2D. Have you mastered 2D?

http://java.sun.com/docs/books/tutorial/2d/index.html
May 9 '08 #6
JosAH
11,448 Expert 8TB
Is this thread dead now? Did the OP expect boilerplate code? Too bad because
the subject can be an interesting one.

kind regards,

Jos
May 12 '08 #7

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

Similar topics

5
by: Rose Alit,mon mignon | last post by:
Hi, I'm trying the following and doesn't work. Could someone have any clue? dim arrMyShapes(1 to MxA,1 to MxB) of New Shape Thanks JeanM
0
by: Anchorman | last post by:
I'm using the following SHAPE command: SHAPE {SELECT * FROM Chapters WHERE SchoolID=320} APPEND ({SELECT * FROM ChapterLink} RELATE ID TO ChapterID) AS Advisors ({SELECT FirstName, LastName...
0
by: minjie | last post by:
Hello, I have several reports that were written with ADO shape command (in C++) to access Microsoft Access database. Now we have migrated all the data from Access to DB2 UDB (version 8.1), and the...
3
by: PM | last post by:
Hi, Im a student currently designing a game for a project. As part of my game, I want to be able to drag a shape over a series of panels. The shape needs to be able to be dropped on any of the...
0
by: nets-rac | last post by:
Hi, I use c# to automate powerpoint. I created a new shape with PowerPoint.Shape shape = slide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, left, top, width, height);...
0
by: saravanansvks | last post by:
Dear Friends, I have prepared a programme in Visual Basic for SHAPE OPERATOR.But my coding are changing the shape only.It does not changes the fill style of the shape tool .And it is not giving ant...
1
by: JWest46088 | last post by:
I am a little confused about what I need to do here. I created four separate classes (Circle, Rectangle, Square, and Triangle) that each calculate their own area and perimeter via user input. Now...
5
by: Peter Webb | last post by:
I have created two sets of circles using addshape, innercircle(i) and outercircle(i), and I want to group them in pairs so innercircle(1) and outercircle(1) are grouped, etc. I am supposed to be...
4
by: Linda Liu[MSFT] | last post by:
Hi Moondaddy, I downloaded your sample project and run it and did see the problem on my side. There're three problems in the source code of your project. 1. You should move the following...
12
by: ab12 | last post by:
I'm trying to write a program in C that gets a shape outlined with asterisks from the user, and returns that shape filled with asterisks. It will also get the coordinates of a point inside the shape...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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...

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.