Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I would have to disagree with AD there. That seems to be a guaranteed recipe for derailing other people's threads.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> or am I trying to do something that is either impossible or close to impossible
Not at all. You should definitely use a loop to create all of those components. They only differ by the player index. You could also use a for-each style loop

for(Player p : players){...}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> He might have fault too but he might be too careless to realise that
Sure, maybe he mistakenly checked the "Cut off my balls" box because it was directly below "Remove gallstones" and the form was single-spaced.
:-/

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'm wondering why you bother using the with clause here and then repeat your variable?

With Adodc5.Recordset
    Adodc5.Recordset.AddNew
    Adodc5.Recordset.Fields("Name") = txtsibling1.Text
    Adodc5.Recordset.Fields("Age") = txtage1.Text
    Adodc5.Recordset.Fields("Birthdate") = Format(txtbirth1.Text, "mm/dd/yyyy")
    Adodc5.Recordset.Update
    Adodc5.Refresh
End With

It defeats the entire point of the with statement

With Adodc5.Recordset
    .AddNew
    .Fields("Name") = txtsibling1.Text
    .Fields("Age") = txtage1.Text
    .Fields("Birthdate") = Format(txtbirth1.Text, "mm/dd/yyyy")
    .Update
    .Refresh
End With
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> I need a php code ...
Start writing then. When you have problems, post the code and specific questions.

This is not a homework completion service.

diafol commented: well said +8
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, that is the entire point of the argument array to main(). If you execute your class/jar with the following statement

java MyProgram A B C

your args array in main() will contain {"A","B","C"}

mangopearapples commented: Because I Love you for helping me! +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I would agree with the above suggestions to get the ImageIO.read() out of the paint() method and override paintComponent() instead of paint() unless this is an AWT Applet.

I'd also like to mention that you don't necessarily need to create another rotated instance of AffineTransform here

AffineTransform transform = (AffineTransform) (affTransform.clone());
            g2d.transform(transform.getRotateInstance(-this.getHeadingValue() / 57.29, centerX, centerY));

You should be able to simply call

g2d.rotate(-this.getHeadingValue() / 57.29, centerX, centerY)

and draw the image. Since you're restoring the original transform anyway, you can operate directly with the current transform of the graphics context.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Since they're not right triangles, using the dot product of the vectors may be easier.
Given the vectors (x1,y1) and (x2,y2):
angle in radians = arccos((x1*x2 + y1*y2) / ( sqrt(x1*x1 + y1*y1) * sqrt(x2*x2 + y2*y2) )

More wiki info here: http://en.wikipedia.org/wiki/Dot_product#Geometric_interpretation

Pretty decent vector algebra reference here:
http://emweb.unl.edu/math/mathweb/vectors/vectors.html#vec4

Edit: You may need to twiddle the signs a bit. I'm not a vector math genius and always have to "play" with the numbers a little.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Perhaps you misunderstood what Jon posted? I can't even understand what you're attempting to say here.

happygeek commented: my thoughts exactly +0
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Don't use == or != to compare Strings. Use the equals() method.

Also indent you loops and if() blocks. It makes the program flow much easier to follow.

thedalek commented: Very helpful. +0
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your touch method is a void return

public void touch(Kutia[][] k)

You can't assign that to your 'c' variable.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Let's take a look at one of the rules under the Keep It Organized section, shall we?
- Do provide evidence of having done some work yourself if posting questions from schoolwork assignments

How about some code or even just a specific question that indicates you made even the slightest effort on this yourself?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, bunny09 (that's your name on Cramster, right?), perhaps you should make an attempt to write your own code for your homework assignment and then you would know what the program would or would not do.

Edit: Hmm, no apparently 'bunny09' is just the user who posted this question in it's entirety in 2009 and you pasted it here? What exactly are you trying to accomplish?

jonsca commented: Good detective work! +7
Saith commented: 'That's what she said jonsca" .. but no, really. Good job. +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

@tasty: Please post your code and specific questions about the parts you are having trouble with.

@saruba: The point of the forums is to help people fix their code by themselves - not write it for them.

SARUBA commented: You right in a way, thanks. But some people ask questions without the knowledge of VB.NET. That's why I use that way. +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

His assignment, which he posted here, states that he is suppose to use the given Taylor series expansion.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I doubt the OP is going to return after six years to post his classes. ;)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> Now say!
Now say what? That you're a nut who is just rambling on in a barely coherent fashion about some ill-conceived fantasy?

Consider it said.

happygeek commented: Arf arf! +0
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Google was far from the first search engine. Look up Archie, Gopher, WebCrawler, Lycos, etc. There were many before Google came along and took the crown.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That will remove all zeros though, regardless of position. Is that what you intend? replaceAll("^0*", "") will remove just the leading ones.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Sounds like you're trying to scam a pay-per-click service. If that's not the case, perhaps you can explain further?

codeorder commented: good insight. +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Okay, this was scattered across 4 different threads. I have merged them into one. If you wonder why it seems a bit of a mess, that would be why.

Plang007, keep it in one thread in the future.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Put the println() statements after your while() loop if you just want to see the final result after the player turn.

private void waitForCompletePlayerSequence()
    {
        do
        {
            // these if you want to update as letters are clicked
            System.out.println("player sequence " + playerSequence);
            System.out.println("sequence length" + simonSequence.size());
            System.out.println("player length " + playerSequence.size());

            System.out.println("in waitForcompletePlayerSequence loop");
            Utility.pause(500);//note this is in the main thread
        }
        while (playerSequence.size() < simonSequence.size());

        // these if you want to see the final result
        System.out.println("player sequence " + playerSequence);
        System.out.println("sequence length" + simonSequence.size());
        System.out.println("player length " + playerSequence.size());
    }
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'm not sure why you are setting up all that other stuff with the values from args. It sounds like all you need to do is loop over the args, convert them to numbers and add them up.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So did you actually have a question about this code?

AndreRet commented: Nice HR here, thanks. +6
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> Hope I wasn't too harsh.....
Harsh? No, not really - just clueless.

Please stop interjecting useless comments into other people's threads. This "advice" you seem compelled to give on a topic that you don't understand is not helpful.

jonsca commented: Youda man +6
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your super.paint() call is causing to paintComponent() to get called again, hence the infinite loop and stack overflow.

You shouldn't really need a super.paint() call in your paintComponent() method if you are just painting the background. If anything, it would be a super.paintComponent() instead of paint(), since that is the one you are overriding.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, it's a JApplet

GameApplet extends [B]JApplet[/B]

.
I'd recommend changing

public void paint( Graphics graphics )

to

public void paintComponent( Graphics graphics )

so that you're only overriding the paint behavior of the panel itself and not affecting the the rendering of the other components.

In paintComponent() all you really should need are these

if (app.end)	{
  graphics.setColor( Color.BLACK ) ;
  graphics.fillRect (0, 0, 800, 600);
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> I want an answer for your reason.
And I want you to cease this completely useless and off-topic hijack of the thread. This isn't the place to discuss your hurt feelings.

Get it back on topic.

peter_budo commented: Thanx for stepping in, I was on bus and mobile is bad for moderator needs +16
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I suppose it's possible that someone could.

Not sure why they would want to really, but yeah, it's possible that they could.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I think Nick may have thought you were referring to your other thread, which had the domain scattered throughout the code and on many replies.

Nick Evan commented: I did indeed. +0
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Unfortunately it is a reality of the internet that you cannot always "undo" what you decide to share on it. The posts in question have already been public information for over 8 months.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> which i found in some book
That book being your course book and the problem being homework. Why not just say that?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Do you have multiple Panel elements defined under the root?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It's backwards. Your root element is the very first top-level element in a document. In the above, <Panel> is the root. You need the Panel elements to be children of the root, so there needs to be one more level above Panel. I just threw out Project or Locations as possibilities. You can call it whatever you want.

<someRoot>
  <Panel>
    ..
  </Panel>
</someRoot>
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, in the XML fragment you posted above, <Panel> is actually your root element rather than a child. If you add another element level above <Panel> called <Locations> or <Project> or whatever, your getChildren() code should work fine.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Here's an implementation of the rectangle click and drag. Determining what is within the box is up to you.

import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import javax.swing.JPanel;

public class SelectionDemo extends javax.swing.JFrame {

    public SelectionDemo() {
        initComponents();
        add(new DrawingPanel(),BorderLayout.CENTER);
        setSize(500,500);
    }

    class DrawingPanel extends JPanel implements MouseMotionListener, MouseListener{

        Rectangle selection;
        Point anchor;

        public DrawingPanel(){
            addMouseListener(this);
            addMouseMotionListener(this);
        }

        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            if (selection!=null){
                Graphics2D g2d = (Graphics2D)g;
                g2d.draw(selection);
            }
        }

        public void mousePressed(MouseEvent e) {
            anchor = e.getPoint();
            selection = new Rectangle(anchor);
        }

        public void mouseDragged(MouseEvent e) {
            selection.setBounds( (int)Math.min(anchor.x,e.getX()), (int)Math.min(anchor.y,e.getY()),
                    (int)Math.abs(e.getX()-anchor.x), (int)Math.abs(e.getY()-anchor.y));
            repaint();
        }

        public void mouseReleased(MouseEvent e) {
            selection = null;
            repaint();
        }

        // unused
        public void mouseMoved(MouseEvent e) {}
        public void mouseClicked(MouseEvent e) {}
        public void mouseEntered(MouseEvent e) {}
        public void mouseExited(MouseEvent e) {}
    }

    private void initComponents() {
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        pack();
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new SelectionDemo().setVisible(true);
            }
        });
    }
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, you could easily use XML to store the information about the currently open pictures/labels. JDOM is a very easy to work with DOM parser, which you can use to work with the XML doc.

Your doc structure could be as simple as

<panel x='10' y='35 name='Whatever' />

or as complex as you like.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I looked up JInternalFrame and I'd say akill10 was on the mark about using a panel to render the image. JInternalFrame does use a content pane to hold it's components, so that is what you would need to be drawing on and I don't think you can easily override that.

You should be able to just switch that class to extend JPanel instead and add that to your JInternal frame.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Did you have some point in posting this other than demonstrating that you cannot properly use BB code tags?

Some question perhaps or an error message?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I have no idea. I have not used Jasper Reports. You'll need to consult the documentation for that.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

^ Does that help wash down your pride?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

@vincentjohn:
That is just ridiculous. Please read up on the JVM and modern just-in-time compilers before you start tossing around nonsense like that.

The OP did not even supply enough information to begin to know why it is "slower" and how he can load his panes "fastly". My guess would be some recursive layout issues with how he is building the UI dynamically, but without code or more explanation, it's impossible to say.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It's a shame that we can't go their room and write garbage on their walls, which is essentially what they do to forums.

Such pathetically rude individuals.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The original question was from 2008 and I doubt he is still working on that code.

Mustaffa resurrected and hijacked this old thread with his vague, unrelated question, so I'm just going to close this to avoid further confusion.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The DefaultRowSorter is blowing up when it tries to determine the column class in your model, because you are using the value of the first element to determine the class here

@Override
  public Class getColumnClass(int col) {
    return getValueAt(0, col).getClass();
  }

That's all fine and well when there is an element at index 0 to examine - not so much when the vector is empty.

You could try to return either a null or Object.class in that case. I'm not sure which one will may the default row sorter happy. You'll have to experiment or dig into its code.

@Override
  public Class getColumnClass(int col) {
    return cache.size()>0 ? getValueAt(0, col).getClass() : null;
  }
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, you didn't post the relevant part of your QueryTableModel class: tableModel.setQuery() , but it looks like your default row sorter isn't very happy about an empty data vector.

I don't think you're handling an empty result set quite right in your model.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You need single quotes around the string value in your where clause, so that would be description='"+courseName+"'" A better way would be to use a PreparedStatement, which can re-used if you need to look up other course names

java.sql.PreparedStatement prepStmt = dbCon.prepareStatement("select * from emp where description=?");
prepStmt.setString(1, courseName);
ResultSet r = prepStmt.executeQuery();
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, I have an idea that I would Google it before asking others about it on a forum.

In fact, I did Google it and found a lot of results. Give it a try.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

GridLayout or GridBagLayout

GridLayout is much simpler, but not nearly as functional as GridBagLayout. It just depends on your needs.