Sheph's Profile User Rating: -----

Reputation: 444 Architect
Group:
Contributors
Active Posts:
1,029 (0.83 per day)
Joined:
12-October 11
Profile Views:
6,441
Last Active:
User is offline Jan 09 2015 09:36 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Who Cares
Favorite Gaming Platform:
XBox
Your Car:
Honda
Dream Kudos:
125
Icon   Sheph is probably programming.

Posts I've Made

  1. In Topic: Connect 4 GUI

    Posted 9 Jan 2015

    It is so stupid when you are told not to use a superior method because you haven't learned it yet. I could have you cheat and store your button states in a long, but that'd be pushing it. Anyway, ranting aside, you will need a way to determine which button is in which column. i would consider naming them: column1row1button, column1row2button etc. Then in the column1button handlers, you check each column1 labled button starting with the lowest row.

    public boolean isButtonEmpty(JButton btn) {
        return !(btn.getIcon()==x||btn.getIcon()==y);
    }
    
    public void setCurrentPlayerIcon(JButton btn) {
        if(player1==1)
            btn.setIcon(x);
        else
            btn.setIcon(y);
    }
    
    // in actionPerformed:
    
    if(clicked==column1row1button) {
        if(isButtonEmpty(column1row1button)) {
            setCurrentPlayerIcon(column1row1button);
            return;
        }
    
        if(isButtonEmpty(column1row2button)) {
            setCurrentPlayerIcon(column1row1button);
            return;
        }
    
        if(isButtonEmpty(column1row3button)) {
            setCurrentPlayerIcon(column1row1button);
            return;
        }
        // etc...
    }
    
    if(clicked==column2row1button) {
        if(isButtonEmpty(column2row1button)) {
            setCurrentPlayerIcon(column1row1button);
            return;
        }
    
        if(isButtonEmpty(column2row2button)) {
            setCurrentPlayerIcon(column1row1button);
            return;
        }
    
        if(isButtonEmpty(column2row3button)) {
            setCurrentPlayerIcon(column1row1button);
            return;
        }
        // etc...
    }
    

    Hope that helps...
  2. In Topic: Trouble with Draw/Paint in Swing (Sierpinski)

    Posted 4 Jan 2015

    So we see from CasiOo's example that most of your y values are negative or below 30sh. In the JFrame, the window border was probably covering the rectangles. using the JPanel we see that the top has a line of rectangles, but it is cut off. Perhaps you should pick more centrally located points that lie within the bounds of your panel. *That means it was probably working in the JFrame paint(), except that the window border was covering it, which is another good reason to use JPanel.

    Particularly, pointC[1] = (int) Math.round((Math.sin(60.0) * 100));, which always results in -30.
  3. In Topic: File Object - What is it?

    Posted 4 Jan 2015

    The API documentation describes it as "An abstract representation of file and directory pathnames."
    http://docs.oracle.c...va/io/File.html

    The File object won't create a new file on your computer when you create it, because it is only an abstraction. It does however have methods which you can call which will use the JVM's implementation to get the file system and actually create the file from the abstract data.
  4. In Topic: How to fix this keyboard input?

    Posted 4 Jan 2015

    I believe that you press the key which triggers one KeyPressed event, and then your panel is repainted many times before the system begins sending more keypressed events. Like when you want to type "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" the first "a" happens instantly, but it takes a few seconds for the rest to begin showing up. During that time, firstDown is still true because the key has not been released, and your frame is repainted every 20ms during that time, which causes many trues to appear.

    Edit: If you add some debugging statements to your code, you will find pollbutton() is only called once while your trues are printing.
  5. In Topic: Trouble with Draw/Paint in Swing (Sierpinski)

    Posted 4 Jan 2015

    Try setting the fill color of your Graphics object. It could be white on white. I would also avoid calling repaint() inside of paint, simply due to the fact that it will perpetuate an infinite loop which you have no direct control over. Every paint() call will stimulate 10000 repaint requests to the EDT (which might get coalesced down into one, but still its bogging down the system.)

My Information

Member Title:
D.I.C Lover
Age:
24 years old
Birthday:
January 7, 1991
Gender:
Interests:
Tennis, Karate, Board & Card Games, Fantasy Novels
Full Name:
Richard Shepherd
Years Programming:
5
Programming Languages:
Java, C++, html, CSS and javascript.

Contact Information

E-mail:
Private
AIM:
AIM  Sheph1220
Yahoo:
Yahoo  Richjm12

Comments

Page 1 of 1
  1. Photo

    helppp Icon

    09 Feb 2013 - 21:48
    Can someone answer this for me Ill rep you
    http://www.dreamincode.net/forums/topic/311754-how-do-i-create-a-terms-of-conditions-popup-that-you-cannot-exit/page__p__1800087__fromsearch__1&#entry1800087
    sorry fro spamming
  2. Photo

    Sheph Icon

    07 Dec 2012 - 03:59
    Why, thank you! :)
  3. Photo

    raghav.naganathan Icon

    07 Dec 2012 - 03:44
    Congrats on the 400 :)
  4. Photo

    .Aaron Icon

    12 Jul 2012 - 23:24
    "It's printLn() (lowercase L) - not printIn. Why would an OutputStream have an IN function? :)"
    [Insert the thumbs up emoticon here]
  5. Photo

    fromTheSprawl Icon

    18 Apr 2012 - 19:10
    Oh, hey there, wasn't intentional, not trying to do a "Club 27" there. Things just got too much, I found something I want to do, rode a unicorn, found out there was no candy on top of Mt. Everest, and hitchhiked the way back here. So... sup? Hahaha.
  6. Photo

    Sheph Icon

    04 Mar 2012 - 22:11
    Thanks, Mylo. You are actually the reason I made it. I saw your suggestion in the tutorial suggestions thing when i was looking to become a contributor.
  7. Photo

    Mylo Icon

    29 Dec 2011 - 21:06
    The bitwise tutorial is appreciated =) I may learn a few more things from it
  8. Photo

    Sheph Icon

    10 Dec 2011 - 19:58
    Oh nice. Yeah I answered like 3 of those questions in 30 minutes one day, and after a while you start wondering why it isn't common sense.
    Side note. You are a creeper to come by that quickly. What do you have my profile monitored? jk
  9. Photo

    Sho Ke Icon

    09 Dec 2011 - 09:27
    " It's printLn() (lowercase L) - not printIn. Why would an OutputStream have an IN function? :) "
    :D
  10. Photo

    Sheph Icon

    08 Dec 2011 - 21:32
    I just changed it. Which part? the random order?
  11. Photo

    Sho Ke Icon

    08 Dec 2011 - 15:58
    Your signature made me giggle. *goes back to lurking*
  12. Photo

    Sheph Icon

    06 Nov 2011 - 17:00
    Yeah! Thanks for noticing! :)
  13. Photo

    DimitriV Icon

    06 Nov 2011 - 12:57
    You're a stalwart!
Page 1 of 1