Hey, so when i attempt to use the BorderLayout, then run the program nothing is shown in the window, my slider/textboxes and labels are gone. Then when i revert back to using a FlowLayout, they come...
Type: Posts; User: jason3460
Hey, so when i attempt to use the BorderLayout, then run the program nothing is shown in the window, my slider/textboxes and labels are gone. Then when i revert back to using a FlowLayout, they come...
I found what the problem is, it is because i am calling add(drawShape); within my jSlider stateChanged.
But it needs to be called within the stateChanged or else it will not work, is there a way...
right, so in the DrawShape class if I run:
public DrawShape(int newX, int newY, int newLength, MyShape shape)
{
x = newX;
y = newY;
length = newLength;
...
how can i call setShape() function on drawShape? seeing as i cant create an instance of DrawShape because it requires 3 int values ??
DrawShape drawShape = new DrawShape(int,int,int);
2520
do you mean the setShape() method which i used?
I don't understand how i would do it with the DrawShape class, because it requires three int values when creating an instance of it:
...
I understand what you mean, but how do I fix my problem ? I cant figure it out
this is what happens when i force the shape to be a square, then select square and move the slider:
2519
how do i get them to be the same variable ?
EDIT: yeah, when i use a...
I have this method within the MyControlPanel class:
public void setShape(MyShape suppliedShape)
{
theShape = suppliedShape;
}
The actionListeners look like this,...
I add the DrawShape within MyControlPanel constructor, is it called a constructor?
public MyControlPanel()
{
initComponents();
//JSlider setup
...
no nothing changed, still no shape being drawn
The code does not draw any shapes, just produces a white box in my program(where the shape is meant to be drawn):
2518
That code is meant to, when i select a shape from the menu, say i picked...
I tried making a new class, though I've been having a lot of trouble,
I made a new thread here, your help would be much appreciated, If you want i will post all my code, or any code you would...
Well I'm kind of desperate to get this finished today!
Sorry, I'm just giving up all hope, I should be able to figure this out, but I can't.
well i tried this:
package calculations;
could you please write an example later for me, I'm completely lost! I'm making this program messier and messier! I've got bits of everything everywhere. Are you able to download my program? If so...
So in inside each of my shape classes(circle, square and triangle), i should add a paint component ?
for example,
public void paintComponent(Graphics g)
{
...
Hey, I've uploaded my program, so that you can test it, seeing as pasting large chunks of code wont let you see what my problem is.
Link: http://www.filedropper.com/calculations_1
In...
Hey, so my problem is that when my program draws a shape it is inside a small square, as you can see here(the arrow shows the small square):
2517
does anyone know how i can stop this from...
okay thanks a lot, ill have a try at it!
Hey, so I'm making this program, and I want it to be laid out a certain way, but I'm not sure how to do this, seeing as this is the first time I've made a GUI with java.
Here is what I have at the...
Alright thanks a lot, I'll most likely be back for help -__-
--- Update ---
One question, would I make a new class for the painting, or would i implement it within the MyFrame or MyControlPanel...
Well thank you so much! Can't believe I didn't realize I had called it twice.
Now I have to get it so that the shape is drawn on the screen, and changes size depending on the value selected by the...
Thanks!! I was calling MyControlPanel twice.. -__-
MyShape.java
package calculations;
public class MyShape
{
public double getArea(double length)
{
return 0;
but my actionlistener has these lines of code :
myShape = new Circle();
theControlPanel.setShape(myShape);
System.out.println("The shape is: "+myShape);
...
I tried clicking each of the shapes, and then moving the slider, i get the null error.
I tried not clicking the menu and moving the slider, and the same thing happens.
I tried using:
...