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...
Type: Posts; User: kinkita
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...
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:
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...
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...
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...
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...
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 {
That shall be the next step :)
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...
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...
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...
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...
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 = {
...
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...
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...
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...
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 ---
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...
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);
...
Ahh, I also forgott to put the squareRed.draw(g); after super.paintComponent(g);. But now i did and it works :) thank you
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);
...
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);
...
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.
I understand when you say that there should be a loop, but what do you mean by list? how should it look like?
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...