Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Moved to it's own thread.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Regarding the rep comment about it possibly being the Collection.sort() call, no it is not, read the API docs - NoSuchElementException is not thrown by that method.
Sorting an empty collection is actually the easiest operation you could hope to implement :P

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you consider that the component generally starts with a cleared surface of the background color, it's often unnecessary to use clearRect() or fillRect() to clear out the background, but if you are maintaining an image reference for purposes of buffering some updates then you would need to clear that manually before painting the new data.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Distance to center would provide a single calculation to check against that only involves two points. It's arbitrary, really, how close you decide is "close enough" for the association for "A vs B". Given that you only have to know when a user a dragged them near one another, I wouldn't bother determining min distance checks per side.

BestJewSinceJC commented: Good suggestion - & thanks for all the help +4
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

In the same vein you are already discussing, keep in mind that you don't have to code all of the coordinate stuff yourself either. You can make a small wrapper to manage that glyph that just contains the other objects you need to work with

class TeamGlyph {
  private Team team;
  private Rectangle2D glyph;
  // etc
}

and you can forward to any of those methods as needed.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Form1 form = new Form1();
form.setVisible(true);

Of course, that still leaves it to you to create your "Form1" class that extends JFrame or whatever.
http://java.sun.com/docs/books/tutorial/uiswing/components/frame.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

i need more precise info like; go grab this brand this model and this guitar, then you are good to go...

It's just not that simple. There is a wide variety of amps with a wide variety of different sounds and settings. Add in effect pedals/boards such as those that Mosaic mentioned above and the subtleties of effect become quite numerous and it's not uncommon for different effects/settings to be used at certain points in a particular piece of music. That said, you can often get fairly close with the settings available on many reasonably priced amplifiers and perhaps a pedal or two (chorus is nice sometimes).

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You didn't say which line the error is occurring on, but I am guessing that it's this one

int minMarks = Collections.min(tmaMarks);

because the Collections.min() method states that exception is thrown when it's invoked on an empty collection - which you are doing.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Looks reasonable, however you probably want to sleep for a bit between each update and you may want to ensure that your updates to the text area are being made on the event thread

public void run() {
            try {
                setFinish(false);

                for (int i = 0; i < 1000; i++) {
                    // queue the text update
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            myTextArea.setText(myTextArea.getText() + i);
                        }
                    });
                    // sleep for a bit so repaint and other stuff can process
                    Thread.sleep(100);
                }

                setFinish(true);               
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
        }
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You would need to run a loop like that on a separate thread from the Event Dispatch thread because that event thread is where repaints of the screen are processed. There is a small tutorial on that here: http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

This code went under ZKM obfuscation. I Deobed it, and tryna rename. Im making progress with other area's. But every now and then you run thru stuff that doesnt make sense. And so I thought maybe you guys would give me an idea of whats its tryna do, since you guys are all obviously more advanced then me.

You just don't get the point here, do you? That code was obfuscated for a reason - the original source code didn't just accidentally fall into an obfuscator and then delete itself. Obviously the authors did not want to share that code and you aren't going to get much help hacking it here.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Perhaps applicable, but really it just seemed like a very odd thing to contemplate wearing. ;)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And how do you feel about Jello shorts?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Hack and refactor don't mean the same thing. If they wanted you to be able to "refactor" that code, they would have made it available.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It's rather suspect that you do not mention where you got the code, why the actual source is not available, what it is supposed to be for, or anything of the sort. As you can see, decompiled/deobfuscated code is not the easiest thing to read and make sense of and you've not given much reason why anyone should.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Did you read any of the posts above? Did you understand them? If not, what didn't you understand? You need to learn how to ask questions.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you need help then start a new thread and post specific questions you are having trouble with.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'm guessing it's decompiled code. If you want to know the details of what it is doing, consult the source.

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

I think TreeMap is the closest to what you are looking for. As for "storing unique item", the map is unique in the key, but not the value. You can read more info on the various collection implementations here if you like: http://java.sun.com/docs/books/tutorial/collections/implementations/index.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

As you have it described, simply java Main should work just fine. You do not need to include the ".class" part. In fact, when the "java" command sees the ".", it assumes that is a package designation, which is why it is trying to find "Main/class".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Packages have nothing to do with "gadgets". The answer is as meaningless as the original question.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Java Advanced Imaging (JAI) API has a lot of tools for that: http://java.sun.com/javase/technologies/desktop/media/jai/
or you can look through the standard image api package: http://java.sun.com/javase/6/docs/api/java/awt/image/package-summary.html

You may also find this tutorial helpful: http://www.dickbaldwin.com/java/Java174.htm

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

i think i need to adjust my meds. or cut back on caffeine. or have more sex. or something.

At least work backward through that list - you may as well start with the best option :icon_cheesygrin:

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Try enclosing your ID value in single quotes.

string myCommand = "SELECT * FROM Manager WHERE UserName='" + ID + "'";
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So from my understanding, the getTableCellEditorComponent method is what gets called when the user clicks on a cell of the JTable, and inside that method, you are updating the JComboBox by removing everything from it and then adding all the elements from the Vegetarian column to it?

Mostly correct, yes. I'm removing the elements from the ComboBoxModel and adding the contents of a List of entries that is mapped to the value of the Vegetarian column. So the Map contains one List for the value "true" and another for the value "false".

You could just as easily store two(or more) separate models in the map and not even bother with the clear/add part - just pull the model from the map and use setModel() to swap it directly.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, perhaps this chapter from Thinking In Java, 3rd ed will be helpful: http://www.codeguru.com/java/tij/tij0087.shtml
You might look through the info on Java Glossary as well: http://mindprod.com/jgloss/array.html

Salem commented: Sounds good to me +29
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Welcome to DaniWeb!

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, dumping your homework into 4 posts with no code tags and no specific questions is not likely to yield a lot of constructive advice.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You'll have to clarify a bit more what you mean by "value in map"?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Most likely the graphics context in the earlier version that you obtained from the getGraphics() call and drew on got updated by a repaint operation - so no more image. Overriding paintComponent() as you did in the second example is the proper way to do it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Perhaps this article will give you some ideas: http://www.developer.com/java/article.php/893471

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

What is drives the change in the combo box entries? You can change the values in the combo box model pretty easily as needed. Here is an example that updates the values in the combo based upon the value in another table column (the "Vegetarian" column in this case). The bulk of the code is Sun's TableRenderDemo code (hence the big copyright notice, sorry, I just wanted a chunk of table model code I could edit real quick for an example). I added the "ComboEditor" class and used that in place of the DefaultCellEditor. Relevant changes in bold:

/*
 * Copyright (c) 1995 - 2008 Sun Microsystems, Inc.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *
 *   - Neither the name of Sun Microsystems nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, …
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You might take a look at the tutorial on using object streams: http://java.sun.com/docs/books/tutorial/essential/io/objectstreams.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, take a look at ProcessBuilder.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I do not understand the way in which an array of type string can be associated with int values and double values in order for calculations, and therefore displays, to be credited correctly. Any help or insight would be greatly appreciated.

I'm not certain that I understand your question exactly, but it kind of sounds like you're wanting a HashMap (which is a implementation of the more generic Map collection interface). HashMap allows you to associate an Object key to an Object value: key->value.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Try this instead

function checkValues($postValues)
    {
        $valid = true;
        foreach($postValues as $key => $value)
        {
            if(!isset($key) || $value == "")
            {
                $valid = false;
            }
        }
        return $valid;
    }

Edit: Noticed that the && should be ||

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And if you don't like having to type so much to yell at the noobs, the Clippings add-on for Firefox can it effortless :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And what is your question? That's just a homework assignment you posted.

Salem commented: Well the implied question was "Is this a site which dishes out free answers to lazy noobs?" Which the answer is of course "no", and that's why they've gone to infest somewhere else +29
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I only used the if-else construct to compare the elements selected from the list with the contents of the file.

Then you're still hard-coding what to do with each item as it's selected and that negates the reason for storing them in a file at all. Here is a very small example of the design I mentioned above. You need an "Item" class to hold the data for each of those items and you can use that directly within the JList

import java.awt.BorderLayout;
import java.util.ArrayList;
import java.util.List;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

public class ListExample extends JFrame {
    JList itemListing;
    JLabel pathLabel;

    public ListExample() {
        getContentPane().setLayout(new BorderLayout());
        setDefaultCloseOperation(EXIT_ON_CLOSE);

        // Build your ListModel from the items list.
        // You could very easily make this custom
        // ListModel class to handle all of the data retrieval.
        DefaultListModel model = new DefaultListModel();
        List<ListItem> fileItems = getItemsFromFile();
        for (ListItem item : fileItems){
            model.addElement(item);
        }
        itemListing = new JList(model);
        itemListing.addListSelectionListener(new SelectionListener());
        getContentPane().add(itemListing, BorderLayout.NORTH);

        pathLabel = new JLabel();
        getContentPane().add(pathLabel, BorderLayout.SOUTH);

        setBounds(100,100,300,200);
    }

    /** Just an example, you would retrieve these items from
     * file, database, whatever.
     */
    private List<ListItem> getItemsFromFile() {
        List<ListItem> items = new ArrayList<ListItem>();
        items.add(new ListItem("One thing","c:\\someDir\\oneThing.jpg"));
        items.add(new ListItem("Another thing","c:\\someDir\\anotherThing.jpg"));
        items.add(new ListItem("Big shiny thing","c:\\someDir\\shiny.jpg"));
        return items;
    }

    /** This is your data class. It should hold all of the data that you need 
     * to display or work with for each item.
     */
    class ListItem {
        String description;
        String path;

        public ListItem(String description, String path){
            this.description …
Salem commented: Looks good (and shiny) to me. +29
BestJewSinceJC commented: Good advice, I doubt he will take it though. +4
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I think you're probably having a resource location issue. Take a look through this info on loading images with getResource():http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html#getresource

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You haven't set any bounds for the 'welcome' panel before you add it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Heh, that's pretty neat. Thanks for the link!

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

and... ?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

DaniWeb is an IT-related discussion site, not a site for "rants/debates/etc". The Geeks Lounge, which is just one of the forums of many, would be the only appropriate place for such postings. Perhaps a perusal of the FAQ would be useful. You'll find little in the way of sticky threads mentioning anarchy.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You're going to hard-code all of that data into an if-else structure in a production app? If there is any more than what you posted, you're making a real mess for yourself to maintain.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Looks like you already have instructions right there. So start coding and post it up when you have problems or specific questions.
"Send me a code to do my homework" is not a specific question.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You need to actually add 'dx' and 'dy' to the existing values of x and y. You have set them equal instead of adding.

Also, your constructor needs to set the values of your property variables equal to the parameter values that were passed. Your current constructor does not do anything as posted.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I would recommend making a class to represent those items that appear in the list. The toString() method of that class should return the description you wish to see in the list. On selection, you can access that object through getSelectedValue() and read the image path from that object.

HashMap would be another possibility if the only data needed for each item is simply the title and image.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Parkway Drive - Breaking Point