ProjectDraw.zip (7K)
Number of downloads: 43I am trying to create a simple drawing program that will allow two users to draw out math problems to work on together. So, instead of a user typing 2^2 they could instead draw it. I was wanting to add buttons with simple geometric shapes (line, right triangle, rectangle, circle), as well as buttons with mathematical symbols such as (>, <, =, +, v, =, =, -, *, =, ?, ÷, ?, 8) I have been running against a brick wall for a month and cannot find help and have not been able to get even a simple line drawing program to work.
I have tried viewing similar source code files for drawing programs but none contain any comments explaining to me what does what and my instructor is of no use. I have some of the code I have pieced together so far and have included it below.
Could someone please explain to me what I have done wrong and what I need to do to fix it. I need to get a grasp on this so that I can continue with this project and get it completed in time. I wish I could borrow someone's brain for the next 5 weeks to get me through this course as I feel I have learned nothing and wasted my money when I would have been better off teaching myself, but with all the assignments I do not have time to teach myself and I am just skimming by. (sorry for my little rant; just frustrated)
Thank you in advance <3
KitKat
Portion of Current Code:
package simpledraw;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class drawing extends JFrame implements MouseListener{//this gives me an error
/**
*
*/
private static final long serialVersionUID = 1L;
int positionX1 = 0;
int positionY1 = 0;
int positionX2 = 0;
int positionY2 = 0;
int maxLines = 1000;
int currentLines = 0;
int[][] drawLines = new int[maxLines][4];
ArrayList al = new ArrayList();//this gives me an error
public drawing(){
setLayout(null);
JPanel p = new JPanel();
p.addMouseListener(this);
p.setBounds(0,0,800,600);
add(p);
setTitle(title);//
setSize(800,600);
setResizable(false);
setLocationRelativeTo(null);
setVisible(true);
}
public static void main(String[] args){
drawing DL = new drawing();
}
public void paint(Graphics g){
super.paintComponents(g);
for(int i = 0; i < al.size(); i++){
g.drawLine(drawLines[i][0],drawLines[i][1],drawLines[i][2],drawLines[i][3]);
}
}
public void mouseClicked(MouseEvent e) {
}
public void mouseEntered(MouseEvent e) {}//this gives me an error
/* (non-Javadoc)
* @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
*/
public void mouseExited(MouseEvent e) {}
public void mousePressed(MouseEvent e) {
drawLines[currentLines][0] = positionX1 = e.getX();
drawLines[currentLines][1] = positionY1 = e.getY();
}
public void mouseReleased(java.awt.event.MouseEvent e) {
drawLines[currentLines][2] = positionX2 = e.getX();
drawLines[currentLines][3] = positionY2 = e.getY();
al.add(drawlines); //this is showing an error
currentLines++;
repaint();
}
}
ProjectDraw.zip (7K)
Number of downloads: 43

New Topic/Question
Reply



MultiQuote




|