Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So where's the high score on this game anyway? :P

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Perhaps, I guess it depends on how you decipher "then to start learning a programming code".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I would certainly consider it spam when she posts the same "viral marketing" message talking up Tori across a whole lot of random forums.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

"Gud Delhi Photo"

I vote for this. Or "Gud Phto 4 U"

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, that is completely unrelated to the fact that you are doing way too much that is not related to the rendering in your paint method, but you could opt to use labels to display the images instead of custom painting code: http://java.sun.com/docs/books/tutorial/uiswing/components/label.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So I would assume then that material was covered in your course. Review your notes.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Use [code]

[/code] tags around code that you post to retain formatting and preserve readability if you want other to take the time to read it.

That said, you are doing too much in your paint method. You should not be adding components to the frame or loading images in paint(). All of that should be done in some other method so that it is already available to be drawn in paint().

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No, it's not clear. Do you mean exceptions that are thrown or general programming errors made by programmers? And is this a homework or exam question that you have neglected to adequately prepare for?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Please clarify. The question makes little sense.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

well i think that it is easier to learn java then to start learning a programming code but it depends on which type of job your looking for i personally think C# is the best for a programming language

This statement makes little sense. Are you under the impression that Java is not a "real" programming language?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

A flat TV is, well, flatter. Persons who are unhappy with the less-flatness of the ordinary TV will appreciate the more-flatness of the flat TV, but of course even the flat TV still has some degree of not-flatness. Those seeking absolute flatness will likely still be unhappy with current flat TVs.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

i didnt know if to open a new thread .. but i'm having another problem .. probably casting will do it, but i'm not sure.

i'm filling a stack with many variable: Strings and int
when i pop, it returns me a value of type Object. so my Questions is: how can i know if that returned value is a string or an int !?

The question you should be asking is why you are putting strings and ints into a single stack? In most cases you should use an appropriate interface type for the collection that effectively represents what you expect to do with those objects. Obviously you are placing them in a collection for some reason - the interface should reflect that reason. If you have to use a lot of branched instanceof logic to process those items, you probably need to re-examine your abstraction of the operation for consistency and cohesion.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

There are quite a few file comparison utilities listed here, some of which are GPL: http://en.wikipedia.org/wiki/Comparison_of_file_comparison_tools

That might be a decent place to start, along with http://www.google.com/search?q=file+comparison+algorithms

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Post your code and specific questions.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Hey, thanks, but from exam point of view, what shall i write True or False? From examples it is clear that surely we can add, but it's not recommended, isn't it? So shall i go with option "True"?

You should answer your exam question based upon your understanding of the subject.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

One thing that i found quite funny, was that the media kept saying that CERN is a black hole machine, and will kill us all.

It would have been much more popular with the public at large if they had said it was an ice cream machine instead.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'd try to give an answer, but as a "beginner here at this ho-dunk little forum" I doubt I can offer any insight on the complexities of "REAL Java programming like the pros"...

(Is Princeton giving credit for Maryland State AP coursework now?)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Toy guns don't kill toy people, toy people do.

twomers commented: Always remember the thousands of innocents who gave their lives willingly to prove this. +6
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Actually, you pretty much are asking someone to solve it for you, since you didn't seem to read the link that Jasimp posted and you haven't asked any questions that would indicate you have tried anything or given it serious consideration.

Any advice given here is purely on a voluntary basis, so if you are unsatisfied with the advice, which you did receive, you're just out of luck I suppose.

(Also, this is not a chat room and we are certainly not your chat buddies. Read the forum rules and drop the IM-speak.)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I had no idea we started one in Texas. Do you know the name of the project? Is it going to be possible to continue the project, or is it forever abandoned? Thanks for filling me in GrimJack, I am gonna have to look into this!

http://en.wikipedia.org/wiki/Superconducting_Super_Collider

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

Here's a small example that should give you plenty to play around with:

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.event.ComponentEvent;
import java.util.HashMap;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

public class PaintNodes extends JFrame {

    private NodeLabel node1;
    private NodeLabel node2;
    private JPanel paintPanel;

    public PaintNodes() {
        initComponents();
    }

    private void paintNodeConnections(Graphics g) {
        Graphics2D g2d = (Graphics2D)g;
        // draw line between right connection point of node1
        // and the left connection point of node2
        Point p1 = node1.getConnectionPoint("RIGHT");
        Point p2 = node2.getConnectionPoint("LEFT");
        g2d.drawLine(p1.x, p1.y, p2.x, p2.y);
    }

    private void initComponents() {
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setMinimumSize(new Dimension(300, 300));

        // this just overrides the paintComponent() method 
        // of the created panel.
        paintPanel = new  JPanel() {
           public void paintComponent(Graphics g){
                super.paintComponent(g);
                paintNodeConnections(g);
            }
        };

        paintPanel.setLayout(null);

        node1 = new NodeLabel("Node 1");
        node1.setHorizontalAlignment(SwingConstants.CENTER);
        node1.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
        paintPanel.add(node1);
        node1.setBounds(54, 52, 56, 28);

        node2 = new NodeLabel("Node 2");
        node2.setHorizontalAlignment(SwingConstants.CENTER);
        node2.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
        paintPanel.add(node2);
        node2.setBounds(186, 52, 56, 28);

        getContentPane().add(paintPanel, BorderLayout.CENTER);

        pack();
    }

    /** Small class to add some additionial behavior for nodes */
    class NodeLabel extends JLabel {

        Map<String, Point> connectionPoints = new HashMap<String, Point>();

        public NodeLabel(String text) {
            super(text);
            addComponentListener(new java.awt.event.ComponentAdapter(){
                 public void componentResized(java.awt.event.ComponentEvent evt) {
                    mapConnectionPoints();
                }
                public void componentMoved(ComponentEvent e) {
                    mapConnectionPoints();
                }
                 
            });
        }
        
        // updates the mapped positions of the connection points
        // called whenever the component get's resized or moved
        private void mapConnectionPoints(){
            connectionPoints.clear();
            Point point = new Point(getX(),getY()+getHeight()/2);
            connectionPoints.put("LEFT", point);

            point = new Point(getX() + getWidth(), …
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

now,I found the problem,its not about the overriden method!

now there is something new,
You suggested me to use Jlabels ,but I used drawRectangle to draw nodes.Can these nodes(shapes) be clickable? Or do I have to use Jlabels?

Yes, you can simply draw the rectangles yourself, but then you will need to manage any interactions with them yourself as well. That would include things like keeping track of their bounds within the screen, determining mouse-over, rendering the text within them, etc. Using a JLabel saves you all of that work.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Call it how? It needs a graphic context, which is supplied by the paintComponent() method when the component is rendered to the screen.

Edit: Cross-post. I'm referring to the previous question on calling the method yourself.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I don't use Eclipse, but it's debugger should enter paintComponent() just fine.

I'd recommend starting with one of the basic drawing examples from the 2D tutorial that I linked above and then modifying the drawing code to draw the lines you want. Once you understand the rendering process of the components and the use of the Graphic2D class more clearly you'll be in better shape to apply that to your specific application needs.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

WSJ: Obama's Tax Cut for 95% of Americans Is an Illusion

Arguably, that graph portrays a bit of an illusion itself (or perhaps misdirection would be more accurate).
http://econ4obama.blogspot.com/2008/08/obamas-tax-plan-and-basic-honesty.html

It's worth noting the source of that graph and the analysis producing it is rather right-leaning American Enterprise Institute.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

paintComponent() is called automatically when your component needs to be rendered. If you haven't put anything on the panel then it's showing you exactly what is there: nothing.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You could use Scanner or a simple BufferedReader and the regex classes.

stephen84s commented: Short Sweet and to the Point +3
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Just use JLabels for the nodes and override paintComponent() on your panel to render the lines between them.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Vernon, can you post a simple example or two of what determines whether or not the objects blow up? You mentioned that it's not only a matter of the types themselves that determine the result, as in A + B always explodes while A + C never does.

If you can describe the determination of the result a bit more it would help.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, using x -= 1; to represent the much simpler and easier to read boolean found=true; isn't doing you any favors for one thing. You also need to read the API doc on the Scanner class, especially the general portion at the top and consider that in the context of what you see the program doing.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Read the section on work queues in the link that I posted above.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

What on earth is that supposed to accomplish?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I doubt that is the case. Either you are not describing your question clearly enough or you misunderstood the requirement.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No, that does not make any sense at all. A Map is not an int by any conceptualization. Why do you feel you need to store a map in an int?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I think you may have meant

Map<String, Integer> map = new HashMap<String, Integer>();
        map.put("ONE", 1);

        int value = map.get("ONE");

Missing type on declaration and redundant cast on map.get(). ;)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That still involves runtime instanceof checks. I would agree with Narue's suggestion.

Alex Edwards commented: Yeah, I do to! I was hoping my suggestion would be reasonable, though you make a good point. +4
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Perhaps, but again it all depends on the processes, the hardware, how you divide and synchronize the work, etc. There isn't a single global answer there.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I should actually qualify this part a little bit:

Additionally, if you are running on a single processor, starting 10 threads won't make it go faster - it will just have to time-slice the processing of each thread anyway.

If the process is CPU-bound, such as performing a lot of computations or loops, adding additional threads won't offer any improvement and may even make it slower due to the additional overhead of managing the threads themselves (synchronization, context switching, etc.). If the process performs some tasks that are constrained waiting on other resources like IO, multiple threads may offer improved performance even on single processor machines.

This article on thread pools and work queues covers some of these issues:
http://www.ibm.com/developerworks/library/j-jtp0730.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Exactly.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

num1 = generator.nextInt(90)+ 10; will add a random int between 0 and 89 to your base value of 10.
From the API doc:

Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive)

A little bit of experimentation would have quickly yielded the answer for you. If you had placed that code in a throwaway test class main() method, you could see the result pretty quickly. Don't be afraid to test little things like this in isolation to gain a better understanding of the API.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That constructor creates a new JTree with a DefaultTreeModel based upon the root node you supply. If you wish to modify the tree, you can either modify the contents of that tree model directly (by adding or removing nodes wherever you like) or you can construct a new TreeModel and set the JTree to use that model instead with JTree.setModel(javax.swing.tree.TreeModel).

This tutorial on How to Use Trees might be helpful.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Josh Bloch has an excellent article specifically on substitutes for C constructs here:
http://java.sun.com/developer/Books/shiftintojava/page1.html
It is an actually a chapter except from his book Effective Java Programming, which I would highly recommend for any Java programmer.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Obviously, this thread is a unique and special gem... just glance down to the bottom at the "Similar Threads" list if you have any doubt.
:yawn:

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Which is exactly what is in the link that Masijade already posted above. :-/

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You didn't read any of this thread at all, did you? :icon_rolleyes:

Salem commented: s'all right - so long as they can read a menu, and write down what people ask for, they'll be fine. +17
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you could focus on dropping the heavy usage of `............', perhaps you could realize that I lack the vocabulary and proper grammar correctness to be eloquent. But, thanks ;) I feel all lighten up already.

Completely off-topic and just out of curiosity, what is your native language? Your posts would indicate that you now live in the US and have a pretty strong grasp of the language (wider vocabulary than many native speakers I'd say - though that bar isn't so high in some cases :P ), just the occasional grammatical structure issues on more complex sentences.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Chil i just requested some info or ideas if you have any, so tha means you can think and calculate logical stuff.. etc. so if you can't think you shoudn't be posting at the first place

I'm the Java sections which propably means i would like to hear about ideas or projects that may be implemented in Java...I'm just looking for somthing medium skill and propably not in the networks section somethin up to date, i would like to use java applets and learn about them more but i don't have any other interest than that about a specific section. Thank you for your interest.

I don't think you actually understood a thing I said.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

In case you do want to pursue it, start with the Java concurrency tutorial trail: http://java.sun.com/docs/books/tutorial/essential/concurrency/index.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No, you have absolutely no synchronization there and will have all kinds of concurrency problems.

There are a lot of ways to structure what you are wanting to do, but you have to understand some basics about threading first. Additionally, if you are running on a single processor, starting 10 threads won't make it go faster - it will just have to time-slice the processing of each thread anyway.