The Artima Developer Community
Sponsored Link

Java Answers Forum
GUI

2 replies on 1 page. Most recent reply: Aug 3, 2007 6:52 AM by Jonathan Davids

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Jonathan Davids

Posts: 11
Nickname: jonat
Registered: Mar, 2007

GUI Posted: Jul 24, 2007 7:31 AM
Reply to this message Reply
Advertisement
Hello,
I am trying out GUI programming for the second time. I have 3 different classes; the first class "Drawgraphics.java" draws some graphic objects like triangle, circle etc. The second class "Gui.java" is for the GUI with buttons, TextAreas and panels and a JTextArea (is it correct?) where I hope to display the graphic objects. The third class RunGui.java is just a main class to run Gui.java.

Currently, the objects are shown in another frame which I defined in the main method of class "Drawgraphics.java" - see code below;
public static void main(String [] args){
		
		Drawgraphics dg = new Drawgraphics();
		JFrame frame = new JFrame();
		frame .setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		
		dg.setBackground(Color.WHITE);
		frame.getContentPane().add(dg);
		frame.setSize(850, 710);
		frame.setVisible(true);
		dg.start();
		
	
		
	}

Now, I want to remove the above main method and display the objects in JTextArea of my GUI "Gui.java". How do I go about it?

Thanks for your expected help.

Jonat


Jonathan Davids

Posts: 11
Nickname: jonat
Registered: Mar, 2007

Re: GUI Posted: Aug 3, 2007 6:46 AM
Reply to this message Reply
Hello,
Let me explain my problem once more; I have a class;
 public class Drawgraphics extends JPanel implements Runnable 
this class makes the drawing and the second class
 public class Gui extends JFrame
this class is the user interface which has buttons, textAreas and a JPanel called "Drawing" where the diagrams will be shown. The third class
 public class RunGui 
is just only a main method that starts the class Gui.

I have a problem of linking the classes together so that the diagrams will show in the JPanel of the user interface. I tried
Drawing = new JPanel();
Drawing.setBackground(new Color(255, 255, 255));
		Drawing.add(df);
		Drawing.setVisible(true); 

but it is not working, any help?

Jonat

Jonathan Davids

Posts: 11
Nickname: jonat
Registered: Mar, 2007

Re: GUI Posted: Aug 3, 2007 6:52 AM
Reply to this message Reply
Hello,
I imported the class like this;
DrawingGraphics df = new DrawingGraphics();
which I forgot to include in my last reply.

Any help?

Jonat

Flat View: This topic has 2 replies on 1 page
Topic: GUI Previous Topic   Next Topic Topic: Excel File download using Java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use