CasiOo's Profile User Rating: *****

Reputation: 1377 Grandmaster
Group:
Mentors
Active Posts:
3,029 (2.5 per day)
Joined:
05-April 11
Profile Views:
11,790
Last Active:
User is offline Today, 08:45 AM
Currently:
Offline

Previous Fields

Country:
DK
OS Preference:
Who Cares
Favorite Browser:
Opera
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
225
Expert In:
Java

Latest Visitors

Icon   CasiOo has not set their status

Posts I've Made

  1. In Topic: How to make a JLabel hyperlink change depending on a JTextField

    Posted 30 Jul 2014

    You never remove the previously added MouseListener
    You might end up having multiple MouseListeners attached to the JLabel

    Maybe you can come up with a solution where you'll only ever need a single MouseListener
    Adding the MouseListener outside the actionPerformed method might help make the problem easier to tackler
  2. In Topic: looking for a timer class without ActionEvent

    Posted 30 Jul 2014

    DateUtils is that from the apache library?
    I would much rather take advantage of System.nanoTime() than the Date class. It is very likely that the Date class isn't very precise
    It really isn't that difficult if you use the built in TimeUnit class
    TimeUnit will convert the time for you :)
    public class Stopwatch {
    	private boolean hasRun;
    	private boolean stopped = true;
    	//All times are in nanos
    	private long startTime;
    	private long currentTime;
    	
    	public void start() {
    		if (stopped) {
    			startTime = System.nanoTime();
    			hasRun = true;
    			stopped = false;
    		}
    	}
    	
    	public void stop() {
    		if (!stopped) {
    			updateTime();
    			stopped = true;
    		}
    	}
    	
    	public long getElapsedTime(TimeUnit targetUnit) {
    		if (hasRun) {
    			updateTime();
    			long elapsed = currentTime - startTime;
    			return TimeUnit.NANOSECONDS.convert(elapsed, targetUnit);
    		}
    		
    		throw new IllegalStateException("Stopwatch hasn't yet been started");
    	}
    	
    	private void updateTime() {
    		if (!stopped)
    			currentTime = System.nanoTime();
    	}
    }
    
    
  3. In Topic: looking for a timer class without ActionEvent

    Posted 30 Jul 2014

    Sorry but you won't find a stopwatch class in Java
    There's a big chance someone else has coded one in Java for you, or you could just code it yourself
    The timers found in Java are not high precision either, and you can't count on their delay
  4. In Topic: LWJGL help please.

    Posted 29 Jul 2014

    Does any exceptions appear?
    Have you remembered to set the native library location?

    Otherwise try and run one of the examples from http://www.lwjgl.org...sics_4_(Timing)
  5. In Topic: [Help] Skips my scanner

    Posted 28 Jul 2014

    It's a common problem we see often here on DIC

    It is important to note that you are giving input through the console, which will only write content to the stream on a carriage return &/ new line

    You start by calling nextInt() for the menu choice
    nextInt() will search for the next integer in the stream, but without consuming the newline character from the stream. Remember that you hit return on the keyboard in order to write the message to the stream
    The next nextLine() call will read the remaining newline and return an empty String

    You might be inputting the following into the stream:
    1\r\nPeter\r\n20\r\n
    
    

    And here is how it is being read
    nextInt(): 1
    nextLine(): \r\n
    nextInt(): 20 (Peter is consumed as well but discarded)
    nextLine(): \r\n
    
    


    A solution could be to call nextLine() after reading the menu choice just to consume the newline

My Information

Member Title:
D.I.C Lover
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Years Programming:
3
Programming Languages:
Java, C#, VB.NET, JavaScript, PL/SQL, PHP (Basic)

Contact Information

E-mail:
Private

Comments

Page 1 of 1
  1. Photo

    riperator Icon

    31 Jul 2013 - 10:33
    <3 you
  2. Photo

    b.netana Icon

    23 Mar 2013 - 17:32
    thank*
  3. Photo

    b.netana Icon

    23 Mar 2013 - 17:32
    wanted to that you for your help with my gui practice
  4. Photo

    raghav.naganathan Icon

    25 Nov 2012 - 21:15
    Hi dude...I would like to tell you that your rep(729) is a perfect cube :) Cheers :)
  5. Photo

    ubunta Icon

    30 Sep 2012 - 23:33
    hi hello
    hope will be fine and feeling well!!!!!!!!!!!!!!
  6. Photo

    Proshnobodhok Icon

    12 Oct 2011 - 12:31
    Hi CasiOo,
    I really didnt know the term. nyways seems like you can help me in at least telling me the way to get the related resources. but is it against the IT laws?
  7. Photo

    CasiOo Icon

    28 Jun 2011 - 04:11
    Thank you :)
  8. Photo

    smohd Icon

    26 Jun 2011 - 19:39
    Welcome to contributors group
Page 1 of 1