Search:

Type: Posts; User: kinkita

Page 1 of 2 1 2

Search: Search took 0.10 seconds.

  1. Replies
    11
    Views
    2,319

    Re: Removing a JPanel from another class

    Yes that works but the problem I am having is changing the cardlayout from another class, that is a different file.

    I modifyed your code.

    main code


    package cardlayouttest;
    import...
  2. Replies
    11
    Views
    2,319

    Re: Removing a JPanel from another class

    I managed to acces the class method "changeToGame". I added a System.out text to see if it worked and it did, but when I add the code "cardlayout.show(cardPanel, "2");" this error message comes up:
  3. Replies
    11
    Views
    2,319

    Re: Removing a JPanel from another class

    I created the method "changeToGame()" in the class "TicTacToe" but I can't manage to acces it through other classes.

    I can't do: TicTacToe tac = new TicTacToe();

    tac.changeTogame();

    since...
  4. Replies
    11
    Views
    2,319

    Re: Removing a JPanel from another class

    Sorry it took me a while to respond(my internet was just too slow)

    Okey looked at the cardlayout functions, found an example, and now I have this:

    main code:

    package tictactoe;
    import...
  5. Replies
    11
    Views
    2,319

    Removing a JPanel from another class

    Hello everyone, I have once again aproached a problem on my journey to Java.

    What I want to do:
    I want to be able to remove a Jpanel from the main class but with another class. I'll try to show...
  6. Replies
    2
    Views
    1,386

    Re: Can't load image from folder. ImageIcon

    ahh, I forgot that, but how would you do that? I tryed this, to make it a label since JPanel doesn't seem to accept Image objects:

    ImageIcon i=new ImageIcon("You_lostPNG.png");
    Image...
  7. Replies
    2
    Views
    1,386

    Can't load image from folder. ImageIcon

    Hi everyone. I'm trying to load and image to a program but for some reason it's not working.

    Main code:

    package javdrawimagetst;
    import javax.swing.JFrame;



    public class JavDrawImagetst {
  8. Re: Check if number is prime number or not problem[SOLVED]

    That shall be the next step :)
  9. Re: Check if number is prime number or not problemm

    You're refering to this code right? "if(d / x == 1.0 && foundDivs == 0)"; How could i not see this -_-. I took this code from an example:
    d % x == 1.0
    and if it's true then d would be an even...
  10. Check if number is prime number or not problem[SOLVED]

    Hi everyone!

    I've tried to develop a simple programm which will tell the user if the given number is a prime number or not.


    this is the method I've been trying to fix:


    public void...
  11. Replies
    7
    Views
    6,671

    Re: Java applet error: "Blocked Exception"

    I keep getting a "BlockedException", but I think I have everything set up.

    I have a folder which contains:
    1. the java package (now named javapplettest)
    2. the jar named JAvAppletTest
    3. the...
  12. Replies
    7
    Views
    6,671

    Re: Java applet error: "Blocked Exception"

    I followed a random tutorial (yeah, I'm was kind of desperate. I don't even remember the site but I think it was sun) which stated that the preferable way to launch applets was with javascript. I did...
  13. Replies
    7
    Views
    6,671

    Re: Java applet error: "Blocked Exception"

    UPDTAE (I tried to fix it, created new files etc, so here are the current files/errors):

    HTML:


    <script src="http://www.java.com/js/deployJava.js"></script>
    <script>
    var attributes = {
    ...
  14. Replies
    7
    Views
    6,671

    Java applet error: "Blocked Exception"

    HI everyone! It has been a while now, but I have encountered a problem testing Java applets.

    The error I'm getting is "Blocked Exception" as you can see and I realy have no clue why. here's my...
  15. Replies
    1
    Views
    1,177

    oop, directions

    I was just wondering, in object orientend programming, how would you assaign a direction for an object.
    For example:

    Lets say I have an object in position (100, 350) and but I wont it to move to...
  16. Replies
    42
    Views
    3,716

    Re: A beginner needs help in oop

    I tried to put the code in mtPanel before but then the drawing functions messed up:



    package objectclasstrain;
    import javax.swing.SwingUtilities;
    import javax.swing.JFrame;
    import...
  17. Replies
    42
    Views
    3,716

    Re: A beginner needs help in oop

    Tank you, no it works perfectly :)




    My IDE did not give me an error when I ran the program, but the IDE is netbeans and free, so that might be why.

    --- Update ---
  18. Replies
    42
    Views
    3,716

    Re: A beginner needs help in oop

    I see what you mean. It's just that I'm so used to the fact that you can set a hspeed to an object. Before I decided to try to learn java I used a program called game maker, and in that program you...
  19. Replies
    42
    Views
    3,716

    Re: A beginner needs help in oop

    I've got another problem no :/ I've created two objects of the Square class, squareRed and squareRed2, and I'm trying to draw them each with the code

    squareRed2.draw(g);
    ...
  20. Replies
    42
    Views
    3,716

    Re: A beginner needs help in oop

    Ahh, I also forgott to put the squareRed.draw(g); after super.paintComponent(g);. But now i did and it works :) thank you
  21. Replies
    42
    Views
    3,716

    Re: A beginner needs help in oop

    You're right, I should do something like this instead:


    public static void draw(Graphics g){
    g.setColor(Color.BLACK);
    g.fillRect(Xposition, Yposition, 32, 32);
    ...
  22. Replies
    42
    Views
    3,716

    Re: A beginner needs help in oop

    okey, I tried to create the draw method, I put it in the Square class:

    public static void draw(int x, int y){
    setColor(Color.BLACK);
    fillRect(x, y, 32, 32);
    ...
  23. Replies
    42
    Views
    3,716

    Re: A beginner needs help in oop

    Would a for loop be of best usage here?

    for (int i; i < 10; i ++){
    i.draw();

    }

    so then there would be 10 objects, each numbered from 1 to 10, draw in a loop calling them separately.
  24. Replies
    42
    Views
    3,716

    Re: A beginner needs help in oop

    I understand when you say that there should be a loop, but what do you mean by list? how should it look like?
  25. Replies
    42
    Views
    3,716

    Re: A beginner needs help in oop

    Just another quick question:

    What should I do to be able to create a new square object with properties on a command? for example when button released.

    What I thought I would do (which does not...
Results 1 to 25 of 47
Page 1 of 2 1 2