Search:

Type: Posts; User: javapenguin

Page 1 of 3 1 2 3

Search: Search took 0.07 seconds.

  1. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    Actually, what I'm going to try and do is create handlers for those two other buttons. That way they won't get null values that screw it up. Then the game will work.
  2. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    Well, I almost got it to work. The battleship at last is anchored. The setTexts work in the correct spots, but, as I used the same reference variable as I did for the getActionCommand() calls, it...
  3. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.JFrame;
    import javax.swing.JDialog;
    import javax.swing.JPanel;
    import java.awt.Graphics;
    ...
  4. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    Part of the code you suggested has made my buttons Quit and Surrender not work as your Point loc thing made them part of it to, but they aren't part of the array.

    I'm very tired right now.
    ...
  5. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    I got the location thing to work.

    Now I'm going to try to get the battleship to stay in one spot and not get lost.
  6. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    Ok, the compiler errors went away, but it still is only changing 0,0.

    What do I do with it now?

    Oh, so loc shows which button was clicked.

    Also, shouldn't I have to Point classes?

    How do...
  7. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    No, it passes an actionEvent to the listener.

    Wait, which is a subclass of EventObject.
    #-o#-o^:)^^:)^^:)^
  8. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    I don't?

    So I use the actionEvent variable?
  9. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    I did.

    What goes in the constructor?

    EventObject evt = new EventObject();

    I tried
    Object obj; = new Object();
    EventObject evt = new EventObj(ob);
  10. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    Ok, what kind of Object goes in the constructor?


    EventoObject evt = new EventObject();

    BattleshipGUI.java:305: cannot find symbol
    symbol : constructor EventObject()
    location: class...
  11. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    I never used event object before. I only suspected that as I looked up that method online and it came up in java api as coming from that class, though some classes can have the same method names,...
  12. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    Ok, the battleship has now, I think, weighed anchor, but it appears to still not be changing after button is pushed. Maybe it's not supposed to. Oh, wait....


    public void...
  13. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    Ok, now the battleship is staying put, but I can never seem to hit it.

    So it keeps setting it to 0,0.

    I think it's now set so that you can only hit the battleship if you hit it in your first...
  14. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    It doesn't compile. It's syntax.

    Also, battleship still moving. Where should I call it?

    In the listener?

    In the constructor, where it'll never execute?

    Somewhere else?
  15. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    I have an idea how to do with the moving battleship, even if I have to put it in the listener.

    I can't put it sooner or it won't put it at all.

    I haven't tried before the constructor but that...
  16. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    JButton jb = (JButton)evt.getSource();

    That doesn't compile.

    I've spent a month on this stupid project but I can't give up now. I wish I could get the Battleship to stay put. Where do I...
  17. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    Well, it'll keep calling placeBattleship every time because GUIs are usually executed more than one till some condition is met.

    Is there a way to store the coordinates and set them to that so...
  18. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    Ok, nearly got it, but how do I get it from calling the method placeBattleship every time I hit a button, thus the battleship keeps moving.

    Also, how to I get it i and j to the right values:

    ...
  19. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    It's only applying for 0,0 as that's what I initialized it to, but I have no idea how to get it to update according to which button I clicked nor do I know how to keep it from calling the method...
  20. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    How do I get it so it stops calling place Battleship every time I click a button?
  21. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    I know what it's doing. i and j are initialized to 0, so it only works for 0, 0.

    How do I fix that problem? I've also noticed my battleship is moving.
  22. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    I need to get it to figure out what button was clicked and get the indexes of those and set them to I and J.

    Then it'll work.

    But how do you do that?
  23. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    for ( int i = 0; i < arrayOfButtons.length; i++)
    {
    for ( int j = 0; j < arrayOfButtons[i].length; j++)
    arrayOfButtons[i][j] = new JButton("0");
    ...
  24. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    Also, how do you get something to be a parseString?

    like Double.parseDouble();

    or Integer.parseInt();

    What's the one for String?
  25. Replies
    85
    Views
    10,242

    [SOLVED] Re: Battleship GUI Program

    arrayOfButtons[i][j].setText("H"); // changes text on button to H


    arrayOfButtons[i][j].setText("B");

    arrayOfButtons[i][j].setText("A"); // changes text on button to A

    ...
Results 1 to 25 of 55
Page 1 of 3 1 2 3