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

Reputation: 1390 Grandmaster
Group:
Mentors
Active Posts:
3,075 (2.49 per day)
Joined:
05-April 11
Profile Views:
11,959
Last Active:
User is online 43 minutes ago
Currently:
Viewing Forum: Java

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: Java Date issue,keeps reverting to 1935 form 2035

    Posted 21 Aug 2014

    You'll find the documentation for SimpleDateFormat very interesting
    They tell you exactly how it behaves with "yy"

    Quote

    For parsing with the abbreviated year pattern ("y" or "yy"), SimpleDateFormat must interpret the abbreviated year relative to some century. It does this by adjusting dates to be within 80 years before and 20 years after the time the SimpleDateFormat instance is created. For example, using a pattern of "MM/dd/yy" and a SimpleDateFormat instance created on Jan 1, 1997, the string "01/11/12" would be interpreted as Jan 11, 2012 while the string "05/04/64" would be interpreted as May 4, 1964. During parsing, only strings consisting of exactly two digits, as defined by Character.isDigit(char), will be parsed into the default century. Any other numeric string, such as a one digit string, a three or more digit string, or a two digit string that isn't all digits (for example, "-1"), is interpreted literally. So "01/02/3" or "01/02/003" are parsed, using the same pattern, as Jan 2, 3 AD. Likewise, "01/02/-3" is parsed as Jan 2, 4 BC.
  2. In Topic: Java Date issue,keeps reverting to 1935 form 2035

    Posted 21 Aug 2014

    Please show us how you are creating the Date object
  3. In Topic: transfer lowercase, not convert

    Posted 20 Aug 2014

    Merged topics
    Please keep your related questions in the same topic
  4. In Topic: transfer lowercase, not convert

    Posted 20 Aug 2014

    Use the method Character.isLowerCase(ch) to determine if the character is lower- or uppercase
    char letter = 'a';
    System.out.println(Character.isLowerCase(letter));
    
    

    Nothing tricky about it
  5. In Topic: Basic Sprite Character Movement

    Posted 18 Aug 2014

    Quote

    The sprite moves (respondent to key strokes, of course), but leaves a trail of its image behind itself.

    Sounds like you are not remembering to clear the previous render
    What you have previously drawn onto the screen is not automatically removed in each repaint
    If the one sprite is the only thing you are moving, then you'll see it leaving a trail

    A minimal effort example can be put together real quick
    The below is of course not the most efficient way of creating games in Java, but it should be more than enough for small hobby games :)
    The inefficiency really comes from using the Swing timer, but I wouldn't worry too much about it at the stage you're at
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    import javax.swing.Timer;
    
    
    public class AppFrame extends JFrame {
    
    	public static void main(String[] args) {
    		//Always do your GUI operations on the EDT Thread
    		SwingUtilities.invokeLater(new Runnable() {
    			public void run() {
    				new AppFrame();
    			}
    		});
    	}
    	
    	private int DELAY = 16;
    	private int shapeX, shapeY;
    	private final int shapeSize = 20;
    	
    	public AppFrame() {
    		AppGamePanel gamePanel = new AppGamePanel();
    		add(gamePanel, BorderLayout.CENTER);
    		setLocationRelativeTo(null);
    		setDefaultCloseOperation(EXIT_ON_CLOSE);
    		setVisible(true);
    		pack();
    		
    		Timer timer = new Timer(DELAY, new GameLoop(gamePanel));
    		timer.start();
    	}
    	
    	private class AppGamePanel extends JPanel {
    		
    		public AppGamePanel() {
    			setPreferredSize(new Dimension(800, 600));
    		}
    		
    		@Override
    		public void paintComponent(Graphics g) {
    			//The base implementation will repaint the background 
    			super.paintComponent(g);
    			
    			g.setColor(Color.BLACK);
    			g.fillRect(0, 0, getWidth(), getHeight());
    			
    			g.setColor(Color.RED);
    			g.fillRect(shapeX, shapeY, shapeSize, shapeSize);
    		}
    	}
    	
    	private class GameLoop implements ActionListener {
    		private AppGamePanel gamePanel;
    		
    		public GameLoop(AppGamePanel gamePanel) {
    			this.gamePanel = gamePanel;
    		}
    		
    		@Override
    		public void actionPerformed(ActionEvent e) {
    			update();
    			render();
    		}
    		
    		private void update() {
    			shapeX = shapeY += 2;
    		}
    		
    		private void render() {
    			gamePanel.repaint();
    		}
    	}
    }
    
    

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