Search:

Type: Posts; User: javapenguin

Page 1 of 20 1 2 3 4

Search: Search took 0.10 seconds.

  1. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    When I find out when neg repped me like that, they are DEAD!

    I was NOT spoonfeeding. That code was a copy/paste pretty much of their own code a few posts earlier.

    I've reported the incident...
  2. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    r.nextInt() will return some random number that is a valid integer. That's from -2^32 +1 to 2^32 -1 I think. However, you could keep it as it but do this

    int k = Math.abs(r.nextInt()) % 10;
    ...
  3. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    Array indexes aren't valid, unless your variable happens to be of type Object, then it could be I think, if you initialized it as such, for regular int type.

    Try using a different variable than...
  4. Replies
    4
    Views
    2,570

    Re: How to make this Java Code in NetBeans

    The user presumably means that the code works, but they don't know the logic or it or why it is what it is.

    The game goes on forever. You don't seem to have a thing that will end it.
  5. Replies
    6
    Views
    3,550

    Re: Socket Programming over the Internet

    Never mind. That was a spammer. Using AI stuff to copy posts, and it copied your first line, and post semi-relevant stuff, along with possibly links or stuff. That user has been banned.

    Anyway,...
  6. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    The Random's nextInt() could return negatives. However, this might work for you.

    r.nextInt(Integer.MAX_VALUE)%10;

    However, if that generated 1000 and then 100, it would both go to 0 with that...
  7. Replies
    4
    Views
    1,031

    [SOLVED] Re: Trying to fix repaint method

    #-o

    Should have realized that. (Probably would have if I wasn't sleep deprived.)
  8. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    Actually, you might possibly be able to use a for loop for that one, though the while should be kept as well.

    for (int k = 1; k <=10; k++)
    {


    if ( n < 0.1k) count(k-1)++;


    }
  9. Replies
    4
    Views
    1,031

    [SOLVED] Re: Trying to fix repaint method

    import javax.swing.JFrame;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;

    public class myFrame extends JPanel implements KeyListener, ActionListener...
  10. Replies
    47
    Views
    4,759

    Re: Guys, really need your help

    Arrays are a collection of similar, to an extent, an Object array could hold anything for instance, types.

    It has int indexes and would, assuming it was already intiialized, and assuming you...
  11. Re: creating a new method that's not outputting correct result

    It appears that you're incrementing i several times in the same iteration, hence it's exiting quicker. If all of them are occurring under the same condition, then combine them under the same if...
  12. Re: How come the AbstractBorder class is abstract?

    I did have such a test program. However, the results, which did point at what copeg was saying, conflicted with that I had long believed to be true about abstract, that is that I thought I needed at...
  13. Replies
    3
    Views
    1,338

    Re: Trouble using aggregate classes

    No it's not inheritance. If anything, it's composition (or aggregation) hence the thread title.
  14. Re: Not setting colors in JMenu submenu like it should.

    Thanks. However, it appears it's a Model-T style thing, not that I have to choose black, but that I can't have one JMenu with a Red selection and another, in the same program, with a Green...
  15. Not setting colors in JMenu submenu like it should.

    It seems to do this every single solitary time so I think I can make a shorter version of it that will show what's going on.




    import javax.swing.JMenuItem;
    import javax.swing.JMenu;
    import...
  16. Replies
    3
    Views
    1,338

    Re: Trouble using aggregate classes

    You could always have both.

    Create a second one that will initialize your current object to the values of the parameter object.

    Use getters and setters, like setLength(), setWidth(),...
  17. Thread: hello

    by javapenguin
    Replies
    27
    Views
    3,108

    [SOLVED] Re: hello

    Go to forum and then there should be a bunch of forums. Like What's Wrong with my code? Java Theory and Questions, etc.
  18. Replies
    21
    Views
    2,409

    Re: Almost Giving up :((

    I'm a bit confused here, unless there are two level variables, but is that java statement legal? It's declaring a variable and then initializing it to itself plus one. I'm not sure if that will...
  19. Re: How come the AbstractBorder class is abstract?

    An SSCEE? I was asking pretty much how a class could be abstract without any abstract methods or unimplemented interface methods.

    Also, another thing, I can sub that class so far and only have...
  20. How come the AbstractBorder class is abstract?

    It implements, I think, all the methods from the interface Border. Yet it's abstract. How is that possible? I thought that in java an abstract class had to have at least one abstract method. I...
  21. Thread: Swing Help

    by javapenguin
    Replies
    6
    Views
    1,247

    Re: Swing Help

    JTextField field = new JTextField(20);
    field.setText("Button 1");

    That is because you are referring to the field object you created that only has the scope of the ActionListener.

    Also,...
  22. Thread: Swing Help

    by javapenguin
    Replies
    6
    Views
    1,247

    Re: Swing Help

    Put this line before your actionListeners are coded.

    JTextField field = new JTextField(20);

    Right now field is null when it's going into them.
  23. Re: Comparable is implemented, but still " java.lang.Comparable" error appears

    Try changing it, in the TextBook class, to

    implements Comparable<TextBook> and see if that works.



    An Item might not necessarily be a TextBook. If you also had a class that extended...
  24. Re: Comparable is implemented, but still " java.lang.Comparable" error appears

    Any reason why both Item and Textbook are both implementing Comparable<Item>?

    I think that it's

    Comparable<T>

    so if you also want to have TextBook implement Comparable, then I think it...
  25. Replies
    5
    Views
    1,116

    Re: I need help! Urgent!

    You posted the GUI class twice it looks like.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4