No they're not mental. Well, maybe partially.

It's 1:47am I'm tired as hell, but won't rest until I complete this. I know this is right in my face, and it's something stupid but I'm just not picking it up for some reason. Here's the code:

if(g1 == true){
            total + 1000;
            }

What I want is:

"If g1 is true, then add one thousand to total."

My error:

"Not a statement."

I know ya'll should eat this one up. -_-

total + 1000 doesn't do anything. as you haven't defined a place for it to store the result of the addition. If you wanted total to equal itself plus 1000, how would you write it out on paper?

total += 1000;

Assuming total is the variable.

total += 1000;

Assuming total is the variable.

That worked fine.

Thank you for the help, I knew it was a simplistic problem.


Now that I have that working, I have to add a nested GridLayout to the WEST and EAST sides of my BorderLayout.

As it is, I am just adding the GridLayouts as I go along, and I know it's totally wrong, it's just overwriting the previous layout I had before.

IE:

setLayout(new GridLayout(1,13));
            add(c1,BorderLayout.EAST);
                if(true){
                    total += 250;
                    }
            add(c2,BorderLayout.EAST);
                    if(true){
                    total += 250;
                    }
               add(c3,BorderLayout.EAST);
                    if(true){
                    total += 250;
                    }
             setLayout(new GridLayout(12,1));
            add(g1,BorderLayout.WEST);
                if(true){
                    total += 0;
                    }

I've been looking all over Google. Nested GridLayouts don't seem to be the preferred method, but in this case, I'd like to use it. I'm just not sure how to go about implementing it.

total + 1000 doesn't do anything. as you haven't defined a place for it to store the result of the addition. If you wanted total to equal itself plus 1000, how would you write it out on paper?

I get you.
Any help from my newest post would be great.

So far I've found:

WEST=Panel, layout=GridLayout(3,0)

and

EAST=Panel, layout=GridLayout(3,0)

Those are the closest I've come to getting a "Nested GridLayout" but they don't work. I'm really lost here.

Wow, okay. I figured this out. It was frustrating, and in the end I figured it out by myself with no help. But eh, it was worth it, I guess >.>

I lost some hair, but here is how I fixed it if anyone is interested:

public mooframe(){
            setLayout(new BorderLayout(25,25));
            Panel WEST = new Panel(new GridLayout(4,1));
            Panel EAST = new Panel(new GridLayout(3,1));
            Panel NORTH = new Panel(new GridLayout (1,8,10,10));
            Panel SOUTH = new Panel(new GridLayout (1,6,10,10));
            
            total = 12000;
            
            SOUTH.add(b,BorderLayout.SOUTH);
            b.addActionListener(this);

            SOUTH.add(tf,BorderLayout.SOUTH);
            NORTH.add(lab,BorderLayout.NORTH);
            NORTH.add(lab2,BorderLayout.NORTH);

            Choice ch = new Choice();
                ch.addItem("WHITE");
                ch.addItem("BLACK");
                ch.addItem("BLUE");
                ch.addItem("RED");
                ch.addItem("YELLOW");
            Choice ch2=new Choice();
                ch2.addItem("WHITE");
                ch2.addItem("BLACK");
                ch2.addItem("BLUE");
                ch2.addItem("RED");
                ch2.addItem("YELLOW");
            NORTH.add(lab,BorderLayout.NORTH);
            NORTH.add(ch,BorderLayout.NORTH);
            NORTH.add(lab2,BorderLayout.NORTH);
            NORTH.add(ch2,BorderLayout.NORTH);
            
            EAST.add(c1,BorderLayout.EAST);
                if(true){
                    total += 250;
                    }
            EAST.add(c2,BorderLayout.EAST);
                    if(true){
                    total += 250;
                    }
               EAST.add(c3,BorderLayout.EAST);
                    if(true){
                    total += 250;
                    }
            WEST.add(g1,BorderLayout.WEST);
                if(true){
                    total += 0;
                    }
            WEST.add(g2,BorderLayout.WEST);
                   if(true){
                    total += 500;
                    }
               WEST.add(g3,BorderLayout.WEST);
                   if(true){
                    total += 1500;
                    }
             WEST.add(g4,BorderLayout.WEST);
                   if(true){
                    total += 1000;
                       }
            add(WEST,BorderLayout.WEST);
            add(EAST,BorderLayout.EAST);
            add(SOUTH,BorderLayout.SOUTH);
            add(NORTH,BorderLayout.NORTH);
            setSize(800,500);
            setVisible(true);
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.