This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

O Joseph

Ranch Hand
+ Follow
since Jun 27, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by O Joseph

Roel De Nijs wrote:You can purchase a voucher here.



Thanks. Does anyone know anywhere else? I have heard of Vouchers4Exam but I don't know if they are trustworthy.
8 years ago
Does anyone know where I can get genuine vouchers to give the Java SE 7 OCA Certification exam?
8 years ago
Has anyone used ePractize Lab's Java SE 7 OCA Certification Training Lab - Study Guide and Mock Exam Questions Simulator (Software Book)?

I'm asking because I want to give the OCA exam and not sure if K&B Java 6 book and enthuware's mock exams would be sufficient.
I have tried that but the compiler complains they are incompatible types
14 years ago
the error is as follows :
warning [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
Any suggestions
14 years ago
hi,
is it possible to use generic types for a vector that stores different objects e.g. other vectors and Color?
14 years ago
What does it mean when you run your program and although it runs you have the following message on the console:
Note: *.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

How can one get rid of it.
14 years ago
Thanks a lot buddy, that was the problem.
14 years ago
Thanks a lot. Here are the details:-

In the PaintButton class i have;
_________________________________________________________________________
private class MyPaintButtonListener implements ActionListener
{

public void actionPerformed(ActionEvent ae)
{
if(ae.getSource() == square)
{
74:myPaintCanvas.setDrawMode(myPaintCanvas.mySquare);
}
________________________________________________________________________

and this is a summary of what the MyPaintCanvasClass looks like:

package MyPaintPackage;

import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.util.*;
import java.io.*;
import javax.swing.*;
import javax.swing.filechooser.*;
//import javax.swing.filechooser.FileFilter;
import javax.imageio.*;

public class MyPaintCanvas extends JPanel implements MouseListener, MouseMotionListener, Serializable
{

private File file;
JFileChooser fileChooser;
//FileExtension filter;


private Color defaultBGColour, defaultFGColour/*, canvasFGColour, canvasBGColour*/;

protected static int open_fn, save_fn;

private boolean myFillCheck;
protected final static int mySquare = 1, myOval = 2, myRoundRect = 3, myLine = 4, myFreeH = 6,
fillMySquare = 11, fillMyOval = 22, fillMyRoundRect = 33;
private int x1, y1, x2, y2, lineX1, lineX2, lineY1, lineY2, drawMode = 0;
protected static Vector squareV, ovalV, rRV, lineV, freeHV, vector, fileV,
fillMySquareV, fillMyOvalV, fillMyRoundRectV;

/**
* Method MyPaintCanvas
*
*
*/
public MyPaintCanvas()
{
// TODO: Add your code here


squareV = new Vector();
fillMySquareV = new Vector();
ovalV = new Vector();
fillMyOvalV = new Vector();
rRV = new Vector();
fillMyRoundRectV = new Vector();
lineV = new Vector();
freeHV = new Vector();
fileV = new Vector();


addMouseListener(this);
addMouseMotionListener(this);

defaultFGColour = Color.black;
defaultBGColour = Color.white;
setBackground(defaultBGColour);

repaint();

}//End of constructor


public void mouseClicked(MouseEvent me)
{

}

public void mouseEntered(MouseEvent me)
{
setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
}

public void mouseExited(MouseEvent me)
{
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}

public void mousePressed(MouseEvent me)
{
x1 = lineX1 = lineX2 = me.getX();
y1 = lineY1 = lineY2 = me.getY();
}

public void mouseReleased(MouseEvent me)
{
if (drawMode == mySquare)
{
if (myFillCheck)
{
if(x1 > me.getX() || y1 > me.getY())
{
fillMySquareV.add(new MyCoordinates(me.getX(), me.getY(), x1, y1, defaultFGColour));
}else{
fillMySquareV.add(new MyCoordinates(x1, y1, me.getX(), me.getY(), defaultFGColour));
}
}else{
if(x1 > me.getX() || y1 > me.getY())
{
fillMySquareV.add(new MyCoordinates(me.getX(), me.getY(), x1, y1, defaultFGColour));

}else{

fillMySquareV.add(new MyCoordinates(x1, y1, me.getX(), me.getY(), defaultFGColour));

}
}
}

repaint();
}

public void mouseMoved(MouseEvent me)
{

}
/*=============================================================================*/
public void paintComponent(Graphics g)
{
super.paintComponent(g);

redrawVectorBuffer(g);

g.setColor(defaultFGColour);

if (drawMode == mySquare)
{
if(myFillCheck)
{
if(x1 > x2 || y1 > y2)

g.fillRect(x2,y2,x1-x2,y1-y2);
else
g.fillRect(x1,y1,x2-x1,y2-y1);


}else{

if(x1 > x2 || y1 > y2)

g.drawRect (x2,y2,x1-x2,y1-y2);
else
g.drawRect (x1,y1,x2-x1,y2-y1);

}
}



public void setDrawMode(int d)
{
drawMode = d;
}

public int getDrawMode()
{
return drawMode;
}




private RenderedImage myCreateImage()
{
BufferedImage bufferedImage = new BufferedImage(600,390, BufferedImage.TYPE_INT_RGB);

Graphics g = bufferedImage.createGraphics();
redrawVectorBuffer(g);

g.dispose();
return bufferedImage;
}

private void redrawVectorBuffer(Graphics g)
{

for (int i=0;i<squareV.size();i++){
g.setColor(((MyCoordinates)squareV.elementAt(i)).colour());
g.drawRect(((MyCoordinates)squareV.elementAt(i)).getX1(),((MyCoordinates)squareV.elementAt(i)).getY1(),((MyCoordinates)squareV.elementAt(i)).getX2()-((MyCoordinates)squareV.elementAt(i)).getX1(),((MyCoordinates)squareV.elementAt(i)).getY2()-((MyCoordinates)squareV.elementAt(i)).getY1());
}

}

public class MyCoordinates implements Serializable
{
int x1, y1, x2, y2;
Color fColor;

public MyCoordinates(int xx1, int yy1, int xx2, int yy2, Color color)
{
x1 = xx1;
y1 = yy1;
x2 = xx2;
y2 = yy2;
fColor = color;

}

public Color colour()
{
return fColor;
}

public int getX1()
{
return x1;
}

public int getX2()
{
return x2;
}

public int getY1()
{
return y1;
}

public int getY2()
{
return y2;
}

}//End of class [MyCoordinates]

} //End of class
14 years ago
Hi,
I'm trying to develop a paint application, i have done everything i can think of but i dont seem to be able to get d shapes displayed on the canvas and whenever i click on the shape buttons it gives me the following error:

"Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at MyPaintPackage.MyPaintButton$MyPaintButtonListener.actionPerformed(My
PaintButton.java:74)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:18
49)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
a:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258
)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:234)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:2
31)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212
)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Press any key to continue..."

do you have any suggestions on how i can tackle this problem?
thank you.
14 years ago
hi, could anyone please tell me where i can get useful information on the various types of alternative passwords that we have. by this i mean passwords that are completely different from the common text inputs. someone mentioned graphical passwords but i would like to know about others before making a decision. ty.
14 years ago
isn't there a way i can design it without using the applet?
14 years ago
hi,
can anyone explain how to draw a simple clock in java? i dont need to make it work yet. just the circle with the hour and minute hand. thanks
14 years ago