here is my rough thoughts but since I am at work I am restricted from compiling and trying to run this or from using an IDE to clear up the bugs. I am attempting to create a simple 'Clock' with continuously rotating hands as part of a bigger project. Just trying to get this running before I go deeper.
Any help would be appreciated.
import java.awt.Color;
import java.awt.Graphics;
import Javax.swing.JPanel;
public class BusinessLogo extends JPanel
{
public void paintComponent (Graphics g)
{
// --- call superclass's paintComponent ---
super.paintComponent(g);
// --- set array for minute hand 'x' and 'y' coordinates ---
int minuteHand [][]= {20,21,21,22,22,23,23,24,24,24,23,23,22,22,21,21,20,19,19,18,18,17,17,16,16,16,17,17,18,18,19,19},
{16,16,17,17,18,18,19,19,20,21,21,22,22,23,23,24,24,24,23,23,22,22,21,21,20,19,19,18,18,17,17,16};
// --- set array for hour hand x' and 'y' vertices ---
int hourHand [][]= {20,21,21,22,22,23,23,24,24,24,23,23,22,22,21,21,20,19,19,18,18,17,17,16,16,16,17,17,18,18,19,19},
{16,16,17,17,18,18,19,19,20,21,21,22,22,23,23,24,24,24,23,23,22,22,21,21,20,19,19,18,18,17,17,16};
// --- for loop to animate the clock ---
// --- first loop for the hour hand ---
for (int hour = 0; hour <999999; hour++)
{
for (int minute = 0; minute < hourHand.length; minute++)
{
g.getColor(Color.BLACK); // *here is the code in question
g.drawLine(20,20,hourHand[hour][hour]); // *can I use the array minutehand
g.getColor(Color.BLACK); // * or hourHand to set the second
g.drawLine(20,20,minuteHand[minute][[minute]); // * coordinates for my Line
}
}
}// --- end method paintComponent
}// --- end class BusinessLogo ---

New Topic/Question
Reply




MultiQuote




|