Results 1 to 6 of 6
Thread: Paint method
- 06-19-2012, 11:48 PM #1
Member
- Join Date
- Jun 2012
- Posts
- 3
- Rep Power
- 0
-
Re: Paint method
- 06-20-2012, 12:14 AM #3
Member
- Join Date
- Jun 2012
- Posts
- 3
- Rep Power
- 0
Re: Paint method
I have two class files formUI and paint. formUI has text box component from which i need to fetch the string value and pass it on to the paint(Graphics g) method.
-
Re: Paint method
OK, but I'm assuming that you've got a Swing application, and I thought I knew all of the standard Swing components in existence in particular the text components, but I've never heard of a "text box". Can you clarify this some more.
As for the gist of your question, the devil's in the details: how you extract information will depend much on the program code and overall structure, things we still know nothing about. Again, you may wish to tell us much more of the details about your problem and your code. You're almost asking it as if we have magic that allows us to see the code you've not shown and be able to understand problems that you've not stated. I wish we had these abilities, but unfortunately, we don't.
- 06-20-2012, 12:45 AM #5
Member
- Join Date
- Jun 2012
- Posts
- 3
- Rep Power
- 0
Re: Paint method
Java Code:public class Ex1 extends JDialog{ JDialog dlg=new JDialog(); JTextField txt=new JTextField(10); JButton click=new JButton("Print"); String mesg; PaintScreen p=new PaintScreen(); public void drawEx1() { dlg.setLayout(new FlowLayout()); dlg.add(txt, FlowLayout.LEFT); dlg.add(click, FlowLayout.LEFT); click.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent me) { call(); } }); dlg.setSize(100, 100); dlg.setVisible(true); } public void call() { mesg=txt.getText(); p.display(mesg); } public static void main(String[] a) { Ex1 obj=new Ex1(); obj.drawEx1(); } }Java Code:public class PaintScreen extends JDialog { String name=""; JDialog dlg; void display(String mesg) { name=mesg; System.out.println("passed value:"+name); dlg=new PaintScreen(); dlg.setSize(200, 200); dlg.setVisible(true); } public void paint(Graphics g) { g.drawString(name, 100, 50); // here i am getting a null pointer exception } }Last edited by subbus; 06-20-2012 at 01:35 AM.
- 06-20-2012, 03:38 AM #6
Similar Threads
-
Paint method, need help
By PeterPan in forum AWT / SwingReplies: 2Last Post: 01-15-2012, 12:35 AM -
paint method
By larry_d1990 in forum Advanced JavaReplies: 1Last Post: 01-09-2011, 05:45 PM -
Using Graphics outside of a paint method
By Catfish1 in forum New To JavaReplies: 6Last Post: 10-26-2010, 08:57 PM -
how to add more than one paint method
By gautham in forum Java 2DReplies: 2Last Post: 04-06-2010, 07:07 AM -
an error in paint method
By hopey in forum Java 2DReplies: 7Last Post: 04-24-2009, 10:12 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks