Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Window > Palette

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Probably conversion things.

Probably.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Just like any anonymous implemenation

return new Enumeration() {

            public boolean hasMoreElements() {
                throw new UnsupportedOperationException("Not supported yet.");
            }

            public Object nextElement() {
                throw new UnsupportedOperationException("Not supported yet.");
            }
        };

Creating a small private inner class for the enumeration and returning an instance of that would be better though. You can see that idiom used quite a lot in the JDK classes.

Also keep in mind that Iterator is generally preferred to Enumeration these days.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Agreed that this is more of a HTML/CSS question. Moving it over there. Carry on :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Sounds like you probably need to fail then if you cannot show that you learned the material. Failing can be a great learning experience.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The main frame implements SelectionListener but it also contains all of the objects implemented in the main frame (viewports, buttons, text fields etc.) this seems like a type incompatibility. Yes, the required type data is there, but how does java resolve that from all of the other things included in the this pointer?

The only requirement is that the parameter meet the type specified by the method declaration, which it does by implementing the interface. It doesn't care about anything else but the interface specified.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I agree that the "New" buttons are too large. I prefer the previous version that wasn't so intrusive.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Concatenate the string you want to print

println(year + " " + population)

or use printf.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Here is a "bare bones" mockup of how such an event model can be implemented. I've retained your names so it might be a little clearer

import java.util.ArrayList;
import java.util.List;

public class MainFrame implements SelectionListener {

    DataTable dataTable;
    String mainData;

    public MainFrame() {
        dataTable = new DataTable();
        // Add this as a listener to the DataTable objectd
        dataTable.addSelectionListener(this);
    }

    /** simulate the events and notification */
    public void run() {
        // initial state
        mainData = dataTable.getData();
        System.out.println(mainData);

        // data table gets updated (in reality this represents a user action,
        // but I have to simulate here)
        dataTable.updateSomeData();

        // verify our new data
        System.out.println(mainData);
    }

    /** implementation of SelectionListener interface */
    public void selectionChanged() {
        // get the updated data
        mainData = dataTable.getData();
    }

    public static void main(String[] args) {
        MainFrame mFrame = new MainFrame ();
        mFrame.run();
    }
}

class DataTable {

    private String someData = "initial data here";
    
    // list of listeners
    private List<SelectionListener> selectionListeners = new ArrayList<SelectionListener>();

    /** Add a SelectionListener */
    public void addSelectionListener(SelectionListener listener) {
        selectionListeners.add(listener);
    }

    /** notify SelectionListeners of change*/
    private void fireSelectionChanged() {
        for (SelectionListener listener : selectionListeners) {
            listener.selectionChanged();
        }
    }

    public String getData() {
        return someData;
    }

    /** This method just represents some operation that alters the data */
    public void updateSomeData() {
        // doing stuff...
        someData = "new data here now";
        
        // done, so let all the listeners know
        fireSelectionChanged();
    }
}

interface SelectionListener {

    void selectionChanged();
}
BestJewSinceJC commented: Very detailed and quality help +4
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
long pop = 6816330827;

Long is just another primitive data type.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That is exactly the point of the models I mentioned above. You need to implement a way that your main frame can register itself as a listener for the selection change.

With the small model I included above, your main frame would implement that SelectionListener interface and register itself with the data panel as a listener (calling addSelectionListener(this); ). Any method that made changes to the selection would use fireSelectionChanged() to notify that things had been changed. That is when your main frame would call the accessor to get it's data. So basically your main frame would have an implementation of the SelectionListener like this

public void selectionChanged(){
   dataTable.getSelections();  // or whatever
}

The listener models are there to handle that "let other things know things changed" part.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The max value for int is 2147483647, so you will need to use long for that value.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'm struggling a bit to understand the exact behavior you are aiming for, but if you're just saying that the "main frame" needs to take some action when the selection array changes, you can make a small listener model for this yourself very easily

interface SelectionListener {
    void selectionChanged();
}

/** These go in your DataTable class */
List<SelectionListener> selectionListeners = new ArrayList<SelectionListener>();

public void addSelectionListener(SelectionListener listener){
    selectionListeners.add(listener);
}   

private void fireSelectionChanged(){
    for (SelectionListener listener : selectionListeners){
        listener.selectionChanged();
    }
}

Your action listener would call fireSelectionChanged() to notify all listeners of a selection change. Your main frame can then query the info that it needs. If you wanted to send that data with the selection change event, you could make a small SelectionChangeEvent object to pass with that info.

You could also just wire up a ChangeListener or set up your selection list as a bound property of the DataTable.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You are executing this statement, exactly as is "INSERT INTO user VALUES (forename, surname, dob, add1, add2, county, postCode, telNumber)" That does not contain any of the information that you collected above it. It's just that string as written.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, that isn't exactly what I thought you wanted to do, but if it works for you, great :)
I thought you wanted to be able to draw multiple lines by clicking and dragging to stretch the line, like this:

import javax.swing.JPanel;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.Line2D;
import java.util.ArrayList;
import javax.swing.JFrame;

public class RubberLinesPanel extends JPanel {

    private static final long serialVersionUID = 1L;
    private Point point1 = null,  point2 = null;
    private ArrayList<Line2D.Double> lines;

    //-----------------------------------------------------------------
    //  Constructor: Sets up this panel to listen for mouse events.
    //-----------------------------------------------------------------
    public RubberLinesPanel() {
        lines = new ArrayList<Line2D.Double>();

        LineListener listener = new LineListener();
        addMouseListener(listener);
        addMouseMotionListener(listener);

        setBackground(Color.black);
        setPreferredSize(new Dimension(400, 200));
    }

    //-----------------------------------------------------------------
    //  Draws the current line from the intial mouse-pressed point to
    //  the current position of the mouse.
    //-----------------------------------------------------------------
    public void paintComponent(Graphics page) {
        super.paintComponent(page);

        if (point2 != null) {
            // draw the temporary "rubberband" line
            page.setColor(Color.GREEN);
            page.drawLine(point1.x, point1.y, point2.x, point2.y);
        }

        // draw all of the completed lines
        page.setColor(Color.yellow);
        for (int i = 0; i < lines.size(); i++) {
            if (lines.get(i) != null) {
                page.drawLine((int)lines.get(i).getX1(), (int)lines.get(i).getY1(),
                        (int)lines.get(i).getX2(), (int)lines.get(i).getY2());
            }
        }
    }

    //*****************************************************************
    //  Represents the listener for all mouse events.
    //*****************************************************************
    private class LineListener implements MouseListener,
            MouseMotionListener {
        //--------------------------------------------------------------
        //  Captures the initial position at which the mouse button is
        //  pressed.
        //--------------------------------------------------------------
        public void mousePressed(MouseEvent event) {
            point1 = event.getPoint();
        }

        //--------------------------------------------------------------
        //  Gets the current position of the mouse as it is dragged and
        //  redraws the line to create the rubberband effect.
        //--------------------------------------------------------------
        public void …
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Keep the point2 assignment and a repaint() in mouseDragged() . Leave mouseReleased() as you have it, but also set point2 to null. Then alter your paintComponent() method to draw a line from point1 to point2 if point2 is not null.

BestJewSinceJC commented: very helpful in this thread (acc. to OP) +4
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You're adding a new line for every mouseDragged() event. You only want to add a line when the mouse is released.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So examine your loop and the code in it and try to figure out how it could access an index that is too high for your collection.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

thanks Ezzaral : ) that problem is solved,but I got another error in the for loop, can you take a look for me please? thank you

I think you are getting more detailed information than "error message". I can guess what it is, but actually posting those error messages would be helpful. They are usually very specific in telling you the problem.

edit: posted while you were posting this most recent version.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

thanks , I revised my code but got a couple of error messages, which I indicated in the following code. what could my problems be? thanks again for any help : )

You're trying to access the elements of lineList like an array, but it's an ArrayList. Use lineList.get(i) instead.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, evidently you it's something that you cannot do because you are here asking how to do it. I'd say you lost the bet.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Read carefully what you are doing in the paintComponent() method. You are looping through every point in the array list and each time drawing a line between point1 and point2 - which are completely separate from your list of points.

Perhaps you want to loop the array list by it's index and for each pair of points draw a line and increment by two.

Alternately you could create a Line object when the mouse is released and add that to an ArrayList instead of points. Then your for:each loop could draw each line in the collection.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I have a free upgrade coming from PC purchase as well, but I think I may wait a few more months.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

There are existing wrapper classes for all of the primitive types.
Use Integer. Auto-boxing will handle the casting for you.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Use a scanner to get the input. Use a variable for "highest" and one for "lowest". Compare the input to those and alter as needed.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So the way I have it right now (through gridBagLayout) it automatically stacks them to the top would technically be sufficient if I add a boolean for isSelected?

Sure, which ever you want to work with.

I also have to remove whatever information is in the viewObject from a arraylist or vector depending on whether it is selected in this jPanel.

As long as you provide a method to determine if it's selected, you can process that however you like, i.e. a button action that removes all selected entries, etc.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

"Selection" is nothing more than a boolean. You can represent that however you choose.

The box layout just stacks the components vertically. You could use grid or grid bag as well. The point is that each entry is a JPanel component.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I can't figure why you would want to render it in a list. If you want to display a series of panel entries they you would be better off putting them in a vertical box layout in a scroll pane.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
JimD C++ Newb commented: Pointed me in just the right direction. Thank you! +2
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You cannot delete the account, but you can turn off all mechanisms for contacting you in your User Control Panel.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Para que se usa el string.value, ayudenme a crear una clase cuenta. Manda a pedir si quieres crear una cuenta de ahorro o una de credito...

Éste es cuatro años.

Read the forum rules regarding posting in English please.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

There are plenty of references on calculating the distance between two coordinates, but since you're only interested in an approximate 5 mile radius, you could just use the Pythagorean theorem and assume the curvature is negligible dist = sqrt( (x2-x1)^2 + (y2-y1)^2 ) edit: You might find this post helpful: http://www.daniweb.com/forums/thread151916.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

hello guys i need some help of you,
i m create a java project and i want to create a setup for this project so kindly give me answer.
any answer appreciated

Did you read the posts in this thread or are we supposed to re-type everything for you?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

<get> is also available, depending on the specifics of what you are trying to get remotely.

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

You have a few options to work with.
- Use a TableModelListener to respond to the model data value change. Your check box is just a renderer/editor for a column value in your data model. The check box is not the data.

- Use a custom cell editor that extends JCheckBox to respond however you like to changes in the component value.

You can find examples of both in the Swing tutorial for using JTable:
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you mean task instead of target, yes there is.
Read the documentation.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, dragging up a four-year-old thread in the wrong forum is not the way to go about it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Personally I'm surprised there aren't more sig link spamming "thanks for this informations!" posts in this thread yet.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Could you give me your mail id?

Please do not ask for help via email. Read the forum rules about Keeping it on the Site.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Do u still read today?

I mean, in today's world, do u still read books? The printed books?

Definitely. Especially authors that actually take the time to put all of the letters in their words.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, the look and feel could be different between the two perhaps.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

With your keyboard.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

First you need help understanding the definitions of the words "complex" and "simple" and their relationship.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can set the margin on the button with the following

button.setMargin(new Insets(0,0,0,0));
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You may just be missing a call to setVisible().

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Rubber bands?

Read the API for your scanner.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

making of game in java

Asking of coherent question in new thread.

BestJewSinceJC commented: hahaha. +4
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You just said that you already have an idea for doing a project on image processing. So why are you asking for project ideas?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Thanks for your enlightened insight, devin. I'm sure many will benefit from this advice.

~s.o.s~ commented: LOL, ROFL etc. :-) +0