Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That usage pattern does not really make any sense in the context of a table cell editor.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

>Someone please let me know if i can post an external link
External links are fine if they directly address the question and do not violate the community rules.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Like any other image comparison, it depends on what you are wanting to accomplish. Read through the wiki on Computer Vision and figure out which area you are trying to work in. Then seek out further information on that particular branch.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

A parser is an application that scans through text data and extracts certain pieces of information. Regular expressions are useful for that because they are extremely flexible in defining patterns for matching against that data and specifying what information is gathered when a match occurs.

You can read through a couple of tutorials on them here if you like:
http://java.sun.com/docs/books/tutorial/essential/regex/index.html
http://www.regular-expressions.info/java.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It is a full-time job and the ongoing expansion of business lines, data acquisition technology, and customer requirements has kept four developers busy for over five years. It does not show any signs of abating soon.

>Why do you spend so much time on daniweb helping people like myself?
I enjoy it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I am curious if anyone here is a java developer and actually makes good money at it?

Yes and yes.

Basically I would like to know what kind of stuff you do, where you work from, office, home, etc.

I work in a small office with three other developers on an internal data analysis desktop application.

PhiberOptik commented: Thanks! +2
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You need to use a different layout manager for that. The default is FlowLayout, but there are plenty of others available:
Laying Out Components Within a Container

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No.
The file name must match the name of your class.

This means

public class [B]MyClass[/B] {

}

must be saved in a file named "MyClass.java".

So you can save your class in a file named "CODE.java" or you can rename this class to "Main", so that it matches your file name of "Main.java".

This has nothing at all to do with the main() method that is defined in the class.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Why would you do that? It still wouldn't match your file name "Main" and it's not a valid class name.

Have you tried naming the class "Main"?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, I would certainly hope so. You can rename a class or a file so that they match, can't you?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your file name needs to match the class name. You can't save a class named "CODE" in a file named "main".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I fail to see why you would need both a PartID and a PartNumberID. Is it at all feasible that two parts would share the same part number?

I would ask the same of DescriptionID. Why not just a Description field on the Parts table? Unless two completely identical parts could vary by SpecifcationID?

Obviously I don't have the broader view of your table relationships and data domain, but I would think one table for Parts:
Parts
ID pk
Description
SpecificationID fk

and a separate table for quantity information/page info/etc :
Quantities
PartID
Qty
Remark

I would agree with your assessment of the "dozens of tables" ultra-normalized approach leading to a nightmare in production. You don't want a simple part query to involve 12 joins because every single piece of data is it's own table and you have nothing but 12 IDs in "Parts".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Oh, hehe! I never knew of that change and was stuck in my old school ways. Thanks for the update! :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Because you have to compare the correct types. So you can use the int value of that BigDecimal to compare with int 0, or you can compare to BigDecimal.valueOf(0).

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And also the value that you are outputting may not be the one you want.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'm not sure how you've tied in the JComboBox with your actual table model, but the JComboBox is merely an editor for a value, a String most likely and the value that was selected should be available just like any other table value with getValueAt(int,int). The editor is not the content, it's just a mechanism to change that content.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, there were just a few issues and you got pretty close to the solution based upon the commented-out things you tried. Here's an updated version of your constructor and component setup code with some comments added

public GuiWork(){
super("Gui Work!");
    setSize(1000, 750);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout());

    //GOAL::LACE MULTIPLE JPANELS INSIDE JSCROLLPANE !

    //Size TopPane on North Border
    topPane.setMaximumSize(new java.awt.Dimension(1000, 200));
    topPane.setMinimumSize((new java.awt.Dimension(1000, 200)));
    topPane.setPreferredSize(new java.awt.Dimension(1000, 200));
    topPane.setBorder(BorderFactory.createLineBorder(Color.black));
    topPane.add(nButton);
    topPane.add(sButton);
    // add to contentPane - not JFrame itself
    getContentPane().add(topPane, BorderLayout.NORTH);


    //Size RightPane on East Border
    rightPane.setMaximumSize(new java.awt.Dimension(500, 350));
    rightPane.setMinimumSize((new java.awt.Dimension(500, 350)));
    rightPane.setPreferredSize(new java.awt.Dimension(500, 350));
    rightPane.setBorder(BorderFactory.createLineBorder(Color.black));
    rightPane.add(eButton);
    getContentPane().add(rightPane, BorderLayout.EAST);


    // Size scrollPaneLeft - leftPane size doesn't matter since it's the scrollable view
    scrollPaneLeft.setMaximumSize(new java.awt.Dimension(500, 350));
    scrollPaneLeft.setMinimumSize((new java.awt.Dimension(500, 350)));
    scrollPaneLeft.setPreferredSize(new java.awt.Dimension(500, 350));
    scrollPaneLeft.setBorder(BorderFactory.createLineBorder(Color.black));
    scrollPaneLeft.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPaneLeft.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    // set leftPane as the scrollable component
    scrollPaneLeft.setViewportView(leftPane);

    //Place Components in Container
    wButton.setSize(50, 175);
    wButton.setPreferredSize(new java.awt.Dimension(300, 300));
    wButton2.setPreferredSize(new java.awt.Dimension(300, 300));
    wButton3.setPreferredSize(new java.awt.Dimension(300, 300));

    leftPane.add(wButton);
    leftPane.add(wButton2);
    leftPane.add(wButton3);
    leftPane.add(wButton4);
    // important to call revalidate here so leftPane will notify scrollPaneLeft to update accordingly
    leftPane.revalidate();
    getContentPane().add(scrollPaneLeft, BorderLayout.WEST);
}

The main things to note:
- Add components to the ContentPane - not the root of JFrame
- The scroll pane is essentially the component you size and place in your layout.
- The scrollable component that the scroll pane is viewing, the JPanel "leftPane" in your code, is the one that you add components to and it's size can vary (hence the reason for scroll bars). You set that component as the ViewportView of the scroll pane.
…

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The JComboBox is just an editor for a cell value. The cell value itself is an object in your data model just like any other column.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Remove this line

import Stats.*;

Stats is a class, not a package, and if you have these in the same directory there is no need to import.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Can you move the conditional portion into "C" and just leave the call as "ob.myMethod()"? You can't expect to upcast a "B" object to a "C". If you can't let the conditional be handled polymorphically, you'll have to add an "instanceof" test prior to the upcast and method invocation.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Perhaps this will help:
Creating an SSL Client Socket

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

By the way, I just noticed that the person who send me that PM has the flag "Banned" under his name.

That means the issue has been addressed :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

>Let me bring my face close that i may inhale the toner fumes of your papery printed essence.

I think perhaps you have had enough of the toner fumes.

jephthah commented: :D +11
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It sounds like you just want the x postions. Your y positions are fixed. Since you already capture startPoint and endPoint in your mouse listener routines, you have all of the coordinates you need.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

From your example, the start and end values just look like x values. I don't see where you have any other scale your trying to translate to. You say "not X and Y coordinates" but your example only shows x values and it would appear you are just trying to capture startPoint.x and endPoint.x, with no need for the ratio calculation.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you're only working with 1400-1500 lines I would read them into another structure for the comparisons or you could use random access files.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So you have some object start/end values for each rectangle (not screen x coordinates) that you need to compare against?

If that is the case, you'll need to test for containment of your start point and end point as you did in the mouseMoved() method. Once you know which rectangle contains a point, you can use the ratio of of the user drawn x to the containing rectangle's start and end x coordinates to calculate your "object start" value:

val=10               20
     #################
     #               #           < existing rect
     #################     
x=  30               80

new val= 12
          ###################       < rect drawn  by user
  user x=40
        
new val = val1 + ((userx-x)/(x2-x1) * (val2-val1)) = 10 + ((40-30)/(80-30) * (20-10)) = 12

Repeat for the end point rectangle.

Is that what you're looking for?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Just adding

class PaintPanel extends JPanel implements MouseMotionListener[B], MouseListener[/B] {

and the mouseClicked(), mouseEntered(), and mouseExited() method signatures (empty implementations) will get you a lot further along. The rectangle drag and paint code that you wrote does work. You just missed the additional listener to tie it in. Don't forget to add

addMouseListener(this);

as well, after your other listener registration.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You would probably need to reset() the stream to get that to work. After it's read all the way through the file, seLine=seReader.readLine() is going to remain null - it's done reading.

Unless your files are so large as to cause memory problems, you'd get a lot better performance reading those comparison values into a collection from the file and using that collection for your line item comparisons.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can use as many ANDs and ORs as you like, with as many parenthesis as you like to create as many logical sub-groupings as you like:

a AND b AND (c OR (d AND e) OR (f AND g)) ...

but be aware that at some point you cross a line where you should probably re-examine your join criteria and ask yourself why you're having to specify so much in a WHERE clause.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No, your class def only states that it implements MouseMotionListener. It also needs to implement MouseListener as adatapost says and it needs to register itself with addMouseListener().

edit: You'll need to add mouseClicked(), mouseEntered(), and mouseExited() methods as well to fulfill the implementation.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That was the thread he originally post this in. I can't really figure what the heck he is asking either, but he mentioned MS SQL so I dropped it in here.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'd say just let the timer keep running then. You can handle the delay before restart and the reset to 60 easily

class CountdownTimer implements ActionListener {
    final int TOTAL_TIME = 60;
    int counter = TOTAL_TIME;
    javax.swing.Timer refreshTimer;

    public CountdownTimer(){
        refreshTimer = new javax.swing.Timer(1000, this);
    }

    public void actionPerformed(ActionEvent e) {
        counter--;
        if (counter>=0){
            System.out.println(counter);
        }
        if (counter == -2){
            reset();
        }
    }

    public void start(){
        refreshTimer.start();
    }
    public void stop(){
        refreshTimer.stop();
    }
    public void reset(){
        counter = TOTAL_TIME;
    }
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

How are you wanting to reset it? Is there some action that should prompt the reset or should it just start counting from 60 again? You don't have to stop the timer if you don't want to when zero is reached.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I would second JamesCherill's suggestion of subdividing the pixel array into a smaller number of regions, perhaps 10x10, with each region assigned the average of those pixels. Then subtract the two arrays and compare the result against some tolerance threshold value to determine if they are "the same enough" for your purposes.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

CountdownTimer can just be a private inner class of StatusBar. It's only a helper object to manage your timer count down and doesn't need to be a top-level public class. As an inner class, it has access to everything in StatusBar so setting the label text is no problem.

Edit: You were already effectively using two anonymous inner classes to manage this functionality in your first version. This just combines them and encapsulates the function into one small helper class.

jasimp commented: It feels goood to be back, and see that you're still helping out. Maybe I can lighten the load a little again ;) +10
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You actually want to set the label's text from within your actionPerformed() method of the timer, so change the System.out.println() to

public void actionPerformed(ActionEvent e) {
        counter--;
        [B]countdown.setText(String.valueOf(counter));[/B]
        if (counter==0){
            stop();
            reset();
        }
    }
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If it's an inner class, it can still access your JLabel just fine.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It would be a bit cleaner if you just combined them into a small class

class CountdownTimer implements ActionListener {
    int counter = 60;
    javax.swing.Timer refreshTimer;

    public CountdownTimer(){
        refreshTimer = new javax.swing.Timer(1000, this);
    }

    public void actionPerformed(ActionEvent e) {
        counter--;
        System.out.println(counter);
        if (counter==0){
            stop();
            reset();
        }
    }

    public void start(){
        refreshTimer.start();
    }
    public void stop(){
        refreshTimer.stop();
    }
    public void reset(){
        counter = 60;
    }
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Math.abs(a-b) < 2

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, yes, if you put it outside the listener like that - so don't do that. Place the check and the reset in the actionPerformed() method. You can stop the timer there also.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

When your counter gets to zero, stop the timer and reset the counter to 60.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Did you add that refreshListener to something? Just glancing at it, what you wrote looks as though it should work fine (except for the syntax error "counteLimitr"), though it won't stop at zero.

KirkPatrick commented: You've been very helpful throughout the whole thread, I appreciate it very much +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can't write methods in the middle of other methods.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Check the date format that you are using to parse the input date. It looks like the format is reading month/day/year instead of your desired input format of day/month/year.

Note that 29 = 5 + 24. 24 months is two years and 5th month is May... now look at the output date with that in mind.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

... so, the game is to guess what error you got?

My guess is "NoSuchElementException".

If my guess wins, try

int count = 0;
while (myScanner.hasNextLine()) {
    strLine = myScanner.nextLine();
    count++;
    if (count % 2 == 1) {
        System.out.println(strLine);
    }
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I guess that would really depend on how you read and then wrote that date, wouldn't it?

Salem commented: Elementary, my dear Watson +34
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Then you'll need to move the label.