I am trying to create a grid (5*5) size like GUI. I tried and made a very basic grid, which is working quite fine, but I am trying to change the background colour of each JPanel when user click and drop over it. But I am not aware of the GUI in Java yet. So wondering if someone could help me please.
This my code to the grid and matching the both files(Sentiment word analyzing)
public static TwitterSystem getObject()
{
if (Object==null)
Object = new TwitterSystem();
return Object;
}
long startTime = System.currentTimeMillis();
long endTime = System.currentTimeMillis();
long totalTime = endTime - startTime;
//read jason from file into String
//create a lot of tweet objects
//run the tweetSystem
public void Run()
{
double r;
for (int i = 0; i < 5; i++)
for (int j = 0; j < 5; j++)
DataGrid[i][j] = 0.0;
// trying to load the wordlist and tweets
try
{
WordList = new Sentiment_Analysis("E:\\JAVA\\src\\wordlist.txt");
Tweet = new Tweet_Reader("E:\\JAVA\\tweets.json");
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
tweets = Tweet.getTweets();
// for each tweet, we getting the rating and working out where it is in the grid.
for(Tweet t : tweets) {
r = WordList.getRating(t);
if((int)t.getCoordinate().getLatitude() == 24 && (int)t.getCoordinate().getLongitude() == 54 ) {
DataGrid[2][2] += r;
}
if((int)t.getCoordinate().getLatitude() == 25 && (int)t.getCoordinate().getLongitude() == 54 ) {
DataGrid[0][1] += r;
}
}
// printing out the score for each square.
for (int i = 0; i < 5; i ++)
for (int j = 0; j < 5; j++)
System.out.format("[%4d][%4d] = %.4f\n", i, j, DataGrid[i][j]);
System.out.println("Finish calculating");
System.out.println("STATS - TIME: Analysis took "
+ TimeUnit.SECONDS.convert(totalTime, TimeUnit.MILLISECONDS)
+ " seconds");
}
}
Thank you in advance! i'm quite new to Programming
So far got the grid working but i want make the grid in GUI
HELP PLEASE!!!!