GIDForums  

Go Back   GIDForums > Computer Programming Forums > Java Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 15-Mar-2006, 01:32
metan metan is offline
New Member
 
Join Date: Mar 2006
Posts: 1
metan is on a distinguished road
Unhappy

[GRAPHICS] - SymbolDesignerTool - URGENT HELP PLS


Hi to all!
im a newbie in this forum so pls forgive my mistakes if any.
Coming to the question:

Im designing an symbol drawing tool. I ve buttons such as. circle. line. recttangle and so..
I created a JFrame, and build all my buttons, panels, and so into it by using JGoodies. (just a layout manager *www.JGoodies.com*) Anywayz. The important parts of the source are below:

JAVA Code:
public class MainWindowEngineeringTool extends JFrame implements ActionListener,ChangeListener,
WindowListener, MouseListener
{
// lot of button and panel definitions here
private JPanel mDrawingPnl = new JPanel(); // panel that the drawings will be in it.

pubic static void main(String[] args)
{
JFrame frame = new JFrame();
frame.setTitle("PLS HELP :)");
//setBounds...
//AlwaysOnTop
//resizable = false
frame.setDefaultCloseOperation(WindowConstraints.EXIT_ON_CLOSE);
JComponent panel = new MainWindowEngineeringTool().BuildPanel();
frame.getContentPane().add(panel);
frame.setVisible(true);
}

public MainWindowEngineeringTool() //CONST
{
super();
//some JGoodies related layout definitions
//all Listener implementations to the buttons.
//label and button initializations.

mDrawingPnl.addMouseListener(this);
mDrawingPnl.addMouseMotionListener(this);
mDrawingPnl.setDoubleBuffered(true);
}

public void stateChanged(ChangeEvent e) // Used for color selection
{
if(e.getSource() == mSelectedColor)
{
ColorSelectionModel model = (ColorSelectionModel)e.getSource();
mCurrentColor = model.getSelectedColor();
}
}

public void actionPerformed(ActionEvent e)
{
int returned = this.switchButton(e); // Just used for switch case below, to define what button is clicked.

switch(returned) // just some of the button actions
{
case 8: setShape(CIRCLE); //int parametered shape definer.
break;
case 10: setShape(ARROW);
break;
case 17: mColorDialog.setContentPane(mColorChooser);
mColorDialog.setTitle("Colors");
//setBounds
//setResizable false
//always on top
//visible true
break;
default: break;
}
}

public void setShape(shape_) {shape = shape_;}

public void paint(Graphics g)
{
//g.setColor(mCurrentColor); //throws exception here so İ commented it.
switch(shape)
{
case NONE: g.fillOval(prevX, prevY, 2,2); //simple brushing right?
break;
case CIRCLE: g.drawOval(prevX, prevY, lastX-prevX, lastY-prevY);
break;
//and the other shapes...
default: break;
}
}

public void mousePressed(MouseEvent e)
{
prevX=e.getX();
prevY=e.getY();
}

public void mouseDragged(MouseEvent e)
{
//some code for printing the mouse X and Y positions in the label.
lastX = e.getX();
lastY = e.getY();
prevX = lastX;
prevY = lastY;
}
}

I ve tried everything but I dont know why its not painting. There is a panel in the middle of the Frame where the painting should go. the listeners set to that panel. I've even tried calling paint in the mouseEvent methods. but none of them worked.

The big question is: how can I paint with mouse in the panel which is located in the frame?


Thanx for any replies.
Urgent Help needed.
Any helps are appriciated.
Best Regards
Metan.
Last edited by admin : 15-Mar-2006 at 01:34. Reason: Please insert your JAVA code between [java] & [/java] tags
 
 

Recent GIDBlogWriting a book by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to install Sims Deluxe Edition! jack2006 Computer Software Forum - Games 3 22-Oct-2006 19:51
Need Help URGENT eccoflame C Programming Language 1 19-Apr-2005 13:20
Communication via the rs232 interface banur22 C++ Forum 1 13-Apr-2005 12:04
Urgent !question about read file(variable length) robin1977 C Programming Language 2 13-Mar-2005 18:01

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 09:09.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.