Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can't declare methods within other methods, so those that you have crammed into the switch statement have to be moved out.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And I agree with Niek_e: airing this out in a public thread in Community Feedback is probably not the most productive way to address the situation.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Use a JTable. What you are describing is not a list.

You could override toString() on the object you add to JList to present the description you want, but if you want to present those as separate fields, use a table.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You access that inner array list just like I indicated above. I still don't understand why you need to create a new one, but then I don't know what you're trying to do with that structure. Here's a loop that will print each element, maybe that will help answer your question.

ArrayList playerinfo = new ArrayList();
for (int i=0; i< playerinfo.size(); i++){
    ArrayList innerList = (ArrayList)playerinfo.get(i);
    for (int j=0; j<innerList.size(); j++){
        System.out.println( innerList.get(j).toString() );
    }
}

If your ArrayLists are declared with generics, you won't need the cast.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You just need to "get()" the info that is there. The code you posted is trying to create a new ArrayList.

It looks more like you want playerinfo.get(0).get(0) .

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Try adding a revalidate() and possibly a repaint() in your runnable after you set the new screen.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Sounds like you just need to tweak your coordinate math a little. If you got a solid triangle you are on the right track.

Edit: Oops, cross posted with santiagozky. I would agree that you should add more than if you don't want solids.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Just a note: it's preferable to override paintComponent() in most cases instead of paint(), since paint() is also responsible to painting children and the border.
http://java.sun.com/docs/books/tutorial/uiswing/painting/closer.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Take a look at OpenMap.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That's because you moved the code into the anonymous listener. If you aren't going to define that method on your class then remove the "implements ActionListener" from your class declaration.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

In your Netbeans installation directory, go to "etc/netbeans.conf". There you will find an entry for "netbeans_jdkhome".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, looking at that brace on line 64, your code to add the listener is not in a method at all. So you've left out some other code in your post or that piece above won't even compile.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The post is over four years old. Not everything on the web persists forever.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your example is only a case of poor variable naming. Why would you name a boolean "state"? What would "state equals true" mean in a logical description of the program flow? If it is truly a boolean state then you can easily assign a name that accurately reflects that binary nature.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Why not stick with the ButtonGroup? You can put both radio buttons and check boxes in the button group just fine. CheckboxGroup is for use with AWT Checkbox.

(By the way, you forgot

add(noSelectionButton);

in your code above. You created the button but didn't add it to the panel.)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You are trying to assign a single int value to an int[] array. You need to assign that int to a specific element in your array, such as

stateCode[count] = input.nextInt();
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The compiler is usually very explicit in telling you what the problem is.

At a quick glance, one problem is that you used "Pow" instead of "pow". Java is case sensitive .

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And what is your question? As I said, "it doesn't work" is not a question. Be specific.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

"It didn't work" is not a question.

And use code tags if you post code.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

... and it always makes me wince).

++
Me too. Not only is it unnecessary, the code just reads a whole lot cleaner without them.

if (isComplete) {...
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You already have a thread on this question here:
http://www.daniweb.com/forums/thread235128.html

Do not create multiple threads for the same question.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

!!!!11!one!!oneone!!

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The literal value of a float in your code would be "6.0f", but printed output does not show that "f" unless you put it there explicitly.

Your output is perfectly fine.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Are you expecting it to print the "f"? Doubles and floats don't look any different as output.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So now you can create a CO2Footprint object and call methods on it

CO2Footprint footprint = new CO2Footprint();
double[] glassReduct = footprint.calcGlassReductions();
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Maybe you want to reverse line 23?

shroomiin commented: always helpful +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That isn't Java code. Perhaps you meant to post this in another forum?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Because you are calling that method statically but it is not declared as a static method. To call it as you have defined it, you would need to create an object of that type and call the method on it.

That method doesn't return anything though, so trying to capture a return value from it won't get you anywhere.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Walk through and match up your braces.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Using the pattern (\w+?[RK]) with the regex Matcher.find() method will capture all of those groups except for the last one, which doesn't end with R or K.

Edit: This pattern \w+?[RK]|\G\w++$ seems to produce the result you wanted.

Pattern pat = Pattern.compile("\\w+?[RK]|\\G\\w++$");
String input = "AMLARMLAKFGFP";
Matcher matcher = pat.matcher(input);
while (matcher.find()){
    System.out.println(matcher.group());
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

(Yes, the HTML page source is just marked up text)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Much appreciated response ezzaral, just one quick question when reading the text from the url, does that automatically read the source of the page?

Give it a quick try and you'd have a definitive answer. :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
KirkPatrick commented: you've always been helpful around here bud, the world needs more helpful people like you +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And don't you have about 5 threads started on this now?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

My suggestion: learn how to type and communicate effectively. It will serve you well.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I think you are correct that the behavior did stem from some blocking, but this can still be simplified a great deal to work without a separate listening thread.

Here's a re-wired version of the same that behaves itself. It's worth noting that these two versions only differ in what kind of socket is created to make one the "server". They could be coalesced to a single class. (It's also a quickly slapped together modification that doesn't properly handle exceptions or shut down properly and close io streams :) )

package game;

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;

import javax.swing.*;

public class Clientms2 extends JFrame implements MouseListener {

    private static final long serialVersionUID = 1L;
    JFrame container;
    InetAddress address;
    Socket s;
    String host = "localhost";
    PrintWriter out = null;
    BufferedReader in = null;
    int port = 5656;
    String message;
    int mouseX, mouseY;

    boolean myTurn = true;
    JTextArea status = new JTextArea();

    public Clientms2() {
        super("Client 1: Player 1");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        //this.setResizable(false);
        addMouseListener(this);
        status.addMouseListener(this);
        add(status);
        pack();
        setSize(400, 400);
    }

    public static void main(String args[]) {
        Clientms2 client = new Clientms2();
        client.setVisible(true);
        client.run();
    }

    public void run() {
        try {
            address = InetAddress.getByName(host);
            s = new Socket(address, port);

            // establish streams one time
            out = new PrintWriter(s.getOutputStream(), true);
            in = new BufferedReader(new InputStreamReader(
                    s.getInputStream()));

            // start processing
            myTurn = true;
            String input = "";
            while ((input = in.readLine()) != null) {
                if (!myTurn) {
                    process(input);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void mouseClicked(MouseEvent …
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The problem is that all of your code, including the thread.sleep() calls, are executing on the AWT event queue thread, which is the same thread that handles the repaint calls to update the display. You have to separate the animation updates from the painting. One way to do that would be to wrap the code you currently have in the show() method into a small Runnable class

class LineAnimation implements Runnable{
        public void run() {
            Vector<Line> LINES = this.lines(POINTS);
            Vector<Line> PWLINES = new Vector<Line>();
            for (int i = 0; i < LINES.size(); i++) {
                PWLINES.add(LINES.get(i));
                this.G.transfer(POINTS, PWLINES);
                this.G.repaint();
                try {
                    Thread.sleep(500);
                } catch (Exception e) {
                }
            }
        }
    }

and start a new thread with that Runnable in your show method

Thread lineAnim = new Thread(new LineAnimation());
lineAnim.start();

As BestJewSinceJC mentioned, a Swing Timer can also be used for this.

kolibrizas commented: A very decent help to my problem! +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, to get rid of that error, don't call methods that do not exist

helpMenu = menuBar().addMenu(tr("&Pomoc"));
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No, I hadn't seen anything about Nimbus as yet. It looks pretty nice.

Here at work we just use the XP look and feel and all of our time is taken up working on functional requirements. We don't have much time left to play with UI customizatoin. =\

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Looks like you have a bit of work ahead of you. Let us know if you have specific questions about portions of it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Or keep them in a List.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

y u a hater 4 nikka wow is a good game everyone plays it u just mad cause u cant hit lvl 80

Absolutely brilliant.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It all comes down to the details of "changing the look". Some things are trivial, others are quite complicated. You asked a very general question.

If you just want to set the frame to be borderless, use setUndecorated(true);

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Call methods on "clickedButton". I wrote that to show you how to obtain a reference to the button that was clicked.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can customize all kinds of things about how the UI appears. A lot is possible with the methods provided by the Swing components, but if that isn't sufficient it's possible to use the the pluggable look and feel and custom UI delegates to gain a greater degree of customization. Here is an overview of that architecture: http://java.sun.com/products/jfc/tsc/articles/architecture/

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your listener is setting the icon on whichever button i and j corresponds to

button[i][j].setIcon(imageO);

What you really want to do is getSource() from the mouse event and cast that to a JButton and set it's image.

JButton clickedButton = (JButton)e.getSource();
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You could define a method like

private void enableLength(boolean enable){
   txtLength.setEnabled( enable );
   lblLength.setEnabled( enable );
}

so your if() code becomes

if (optBox.isSelected() ){
  enableLength(true);
}

That would be a little clearer to follow and a bit less repetition. You would have one method for each of your dimensions.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You have to actually create the JButtons in your array. You have only declared the array of references with this statement

JButton[][] button = new JButton[3][3];

You must still initialize those objects by adding

button[i][j] = new JButton();

in your loop before you try to do anything with them.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Um, waiting for a question perhaps?