Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And though it might seem brutal to some, that is how predators survive. It's life.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

A few well-placed System.out.println() statements to verify what you are trying to delete would be a good place to start.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

... and thus were the beginnings of SkyNet.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Perhaps you would like to explain which methods you are having trouble with in that wall of code? That's a lot of extraneous UI code to wade through to distill the relevant pieces you want to work with.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

First off, read the tutorial on using custom cell renders: http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#renderer
and here is another example: http://www.exampledepot.com/egs/javax.swing.table/CustRend.html?l=rel

The render will be called for each cell in the table that you have registered it for. Look at the parameters that are supplied when the render is requested:

getTableCellRendererComponent(JTable table, Object value,
                boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex)

You have plenty of information available there to alter how it gets rendered based upon the particulars of that cell value or other information available in your class.

Here's an example of a renderer I used to color cells red or green when a gap exceeds minimum or maximum thresholds which can be set by the user in a couple of text fields on the panel:

class GapColRenderer extends DefaultTableCellRenderer{
    private final Color MIN_COLOR = Color.GREEN;
    private final Color MAX_COLOR = Color.RED;

    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) {

        Component comp = super.getTableCellRendererComponent(table,value,isSelected,hasFocus,rowIndex,vColIndex);

        if (((Double)value).doubleValue() > maxGapThreshold){
            if (isSelected){
                comp.setBackground(new Color((MAX_COLOR.getRGB() ^ comp.getBackground().getRGB())));
                comp.setForeground(new Color(Color.BLACK.getRGB() ^ comp.getForeground().getRGB()));
            } else {
                comp.setBackground(MAX_COLOR);
                comp.setForeground(Color.BLACK);
            }
        } else if (((Double)value).doubleValue() < minGapThreshold){
            if (isSelected){
                comp.setBackground(new Color((MIN_COLOR.getRGB() ^ comp.getBackground().getRGB())));
                comp.setForeground(new Color(Color.BLACK.getRGB() ^ comp.getForeground().getRGB()));
            } else {
                comp.setBackground(MIN_COLOR);
                comp.setForeground(Color.BLACK);
            }
        } else {
            if (isSelected){

            } else {
                comp.setBackground(Color.WHITE);
                comp.setForeground(Color.BLACK);
            }
        }
        return comp;
    }
}
darkagn commented: Great info :) +3
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

For this reason, the only difference that I see between Creationism and Evolution is the supernatural aspect, otherwise they are on the same level of improbability.

Well, there's just a little bit more to it than that:
http://evolution.berkeley.edu/evolibrary/article/evo_01
http://www.natcenscied.org/evolution
http://en.wikipedia.org/wiki/List_of_misconceptions#Evolution
http://www.natcenscied.org/creationism

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It's amazing how many dirt-poor redneck Republicans cry out against Obama's supposed socialism (though most of them probably don't even know what socialism is), while the so-called "conservatives" they vote for continue to shovel more and more of that wealth they're so concerned about into the hands of mega corporations and politically connected cronies, fund the government on credit, and pass the bill on down to future generations.

Joe Sixpack "never did git 'rithmetic too good".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, it's possible to "add further functionality" by composing new classes of your own that use those classes internally to extend or alter the functionality (assuming there are not licensing issues). Of course, you do need to understand the API of the other classes if you expect to do much with them, which was s.o.s's point.

If you stop to think on it a moment, you do this any time you write a program with the JDK. You utilize the existing classes in the API to build new ones of your own that offer some intended functionality.

Alex Edwards commented: Very good point =) +4
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The constructor needs to declare that it throws that exception.

public TestScores(double[] s) throws InvalidTestScore {

You also need to:
- Use a constructor that actually exists for InvalidTestScore.
- Use an appropriate constructor for TestScores in ExTest.
- Check the spelling of your exception and use the right one.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Toss up between Iron Maiden and Metallica.

Runners up include Megadeth, Testament, Anthrax, Overkill, Helloween, and Queensryche.

Honorable mentions to Slayer, Ozzy, Exodus, Savatage, Rage, Annihilator, Death Angel, and Metal Church.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, if that component is in a single column it will. If you need it to span across multiple columns, set the gridwidth property to that number of columns.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Read the API for the Math class.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Weightx and weighty determine how extra horizontal and vertical space is allocated. It column 0 has a weightx of 0 and column 1 has weightx=1.0, then any extra horizontal space will be given to column 1.

You may need to anchor your components to the west as well, if you want them to remain left-aligned within the container.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Have you already read through the entire tutorial on Using the GridBagLayout? The layout you want isn't difficult to achieve, but getting used to the way the constraints work does take some time and experimentation.

For your particular question, try giving the text fields a weightx of 1.0. This will force any extra horizontal space to be allocated to that column.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

There is no reason you need to create an .exe from the jar file (and many reasons not to). Just read the tutorial on packaging applications as jar files: http://java.sun.com/docs/books/tutorial/deployment/jar/index.html

For your shortcut, you can simply use the same syntax that you would to run it from the command line. If you don't want the command window to persist while it's running, use "javaw" instead of "java"

javaw -jar MyApp.jar

. You can add any switches you might need.

If you want to provide an installer for the app, you might take a look at IzPack.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Or an even crazier suggestion:
Read your class notes and materials.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Perhaps you should do a project that will spider the internet and aggregate all the thousands and thousands of "Final Year Project" request threads that already exist on this and countless other forums. Then we could just point all of these identical threads to your project site.
:-/

Salem commented: Ha ha ha - nice one :) +23
ddanbe commented: Respect! +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
darkagn commented: As always, a source of great knowledge :) +3
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That wasn't very illuminating. :-)

See what I mean? ;)

~s.o.s~ commented: Haha :-) +23
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'm not certain if the browser will open an html file in a jar. You can use getClass().getResource() to obtain a URL for a resource in a jar, but whether the browser will open it may be another story. Firefox doesn't seem to want to.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Actually, if you're using JDK 6, I guess they've added a class that would take care of the browser part for you: http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html

(We're still stuck at SE5 here for a bit longer, so I'm not as familiar with all the additions that SE6 brought yet :( )

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

For launching the default browser, we use a small utility class called BrowserLauncher that one of the guys here found a few years back in a JavaWorld posting. I've pasted that into your example code as a static class (just for convenience - it should be a public class of its own) and altered your lower JEditorPane to display a hyperlink that opens Google in the default browser.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class HelpMain extends JFrame implements ActionListener, HyperlinkListener
{
    JPanel panel1;
    JPanel panel2;
    JEditorPane pane;
    JButton googleButton;
    JButton yahooButton;
 
    
    public static void main (String args[])
    {
        new HelpMain();
    }
  
    
    public HelpMain()
    {
        panel1 = new JPanel ();
        panel2 = new JPanel ();
        LayoutManager lm = new GridLayout (2,1);
        setLayout(lm);
        panel1.setBackground(Color.GREEN);
        googleButton = new JButton ("Google");
        yahooButton = new JButton ("Yahoo");
        googleButton.addActionListener(this);
        yahooButton.addActionListener (this);
        panel1.add (googleButton);
        panel1.add (yahooButton);
        panel2.setBackground(Color.CYAN);
        pane = new JEditorPane ();
        pane.setEditable(false);
        pane.addHyperlinkListener(this);
        
        // Added this part
        pane.setContentType("text/html");
        pane.setText("<A href='http://www.google.com'>Google</A>");
        
        panel2.add (pane);
        add (panel1);
        add (panel2);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(1000, 600);
        setVisible(true);        
    }

    public void actionPerformed(ActionEvent e)
    {
        if (e.getSource () == googleButton)
        {
            setHTMLPage ("http://www.google.com");
        }
        else if (e.getSource () == yahooButton)
        {
            setHTMLPage ("http://www.yahoo.com");
        }
    }
    
    public void setHTMLPage (String page)
    {
        try
        {
            pane.setPage(page);
        }
        catch (IOException ex)
        {
            System.out.println ("Problem setting page.");
        }
    }

    public void hyperlinkUpdate(HyperlinkEvent he)
    {
        System.out.println ("In Hyperlink Listener");
        if (he.getEventType() == HyperlinkEvent.EventType.ACTIVATED) 
        {
            try 
            {
                // …
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Im not really concerned and bothered by that! Im living programming not English

And it sounds like that isn't working out so well for you.
:-/

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The real loser in this continued discussion of Ayers is the poor dead horse.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Glad to hear it. I posted that example around the same time that you posted what you were trying, so there was a little overlap. It also went a little bit further than your stated goal of just using thread completion to increment progress, but the intent was to show a progress polling mechanism. Your own code basically uses the alternative mechanism I mentioned at the bottom of the post, with each thread calling back to a central method to report progress. Collectively those two mechanisms represent a push versus pull paradigm in the communication process.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

*adjusting tin foil hat*
Oh, it's already in place. The New World government and their alien puppeteers carefully control all of the information you receive....

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

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

i'm only learner . i need to know more ,about programing

You won't learn much asking others to complete things for you.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I learned that reading completely random things that others claim to have learned today is not extraordinarily illuminating.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No. That isn't how this forum works.
http://www.daniweb.com/forums/announcement9-2.html

There is also no one named "u" here, so drop the chat room speak.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I would just guess it stems from the fact you created a fixed size buffer image and rendered the red circle on it without anti-aliasing. You then draw that image in paintComponent. The image itself will be unchanged and I don't think turning on anti-aliasing in paintComponent will affect that image.

VernonDozier commented: Pinpointed the problem. +8
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Nope. Too many "e"s in the title.

(Also, you haven't explained precisely what trouble you are having with the program.)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I know you think I will post something mean and snide and anti-Palin but I will let her do that.

"word spray" :)
Very apt.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Here's one way you could monitor progress on the tasks. It involves timed polling of the progress of each task.

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.swing.ProgressMonitor;

public class ProgressDemo {

    public static void main(String[] args) {
        WorkQueue work = new WorkQueue();
        work.begin();
    }

    static class WorkQueue {

        final int NUM_THREADS = 5;
        ExecutorService execService = 
          Executors.newFixedThreadPool(NUM_THREADS);
        
        int totalThingsToDo = 0;
        int percentComplete = 0;

        public void begin() {
            totalThingsToDo = 100;
            List<LongTask> tasks = new ArrayList<LongTask>();
            
            // create and submit tasks to thread pool
            for (int i = 0; i < NUM_THREADS; i++) {
                LongTask task = 
                  new LongTask(totalThingsToDo/NUM_THREADS, i);
                tasks.add(task);
                execService.submit(task);
            }
            
            ProgressMonitor monitor = new ProgressMonitor(null, 
              "Doing stuff...", "", 0, 100);
            
            // monitor progress until done
            while (percentComplete < 100) {
                int partialProgress = 0;
                for (LongTask task : tasks) {
                    partialProgress += task.getProgress();
                }
                percentComplete = 
                  (int)(partialProgress / (float)tasks.size());
                
                try {
                    // wait one second between progress updates
                    Thread.sleep(1000);
                } catch (InterruptedException ie) {
                    Thread.currentThread().interrupt();
                }
                
                monitor.setNote(percentComplete+" %");
                monitor.setProgress(percentComplete);
            }
            // shutdown the thread pool
            execService.shutdown();
        }
    }

    /** Mock task that does an arbitrarty number
     * of "things" in a random amount of time.
     */
    static class LongTask implements Callable<Boolean> {

        int thingsToDo = 0;
        int thingsDone = 0;
        int taskId=0;

        public LongTask(int thingsToDo, int taskId) {
            this.thingsToDo = thingsToDo;
            this.taskId = taskId;
        }

        public Boolean call() throws Exception {
            boolean completed = false;
            while (thingsDone < thingsToDo) {
                // random pause to simulate "working" 
                Thread.sleep((int)(Math.random() * 3000));
                thingsDone++; …
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, with your method

public void UpdateTransaction(String q1, String q2, String q3, String q4, String q5, Connection con)

what happens when you only want to execute 2 statements or you need to execute 10 statements? Consider using a List as a parameter instead of coding in an arbitrary set of numbered parameters.

Also, you need to make sure you close your statement in the finally block. Always close statements when you are finished with them.

Alex Edwards commented: Yes, I sometimes forget to do that to with Databases @_@ +4
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

What it means is that you need identify exactly what you want to read and use appropriate APIs for that content. There are libraries for working with .doc files, .pdf files, etc., but there is not a "reading anything I might happen to come across" library because that is a completely unrealistic expectation.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Regardless of whether the elements have been separated by a split, regular expressions are the easiest way to provide a match pattern for the phone number that allows for the variability that was described.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So CRC32, Adler32, or MD5 checksums will not work for you?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Swing uses layout managers to control the size, position, re-sizing behavior, etc. of the components. You can find a tutorial on them here: http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html

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

HI
my package reads file from txt format only. it does not read .pdf or .doc file. is there any single java library that opens any kind of file format as stream and then reads or manipulates its contents.

The literal answer is yes: http://java.sun.com/javase/6/docs/api/java/io/package-summary.html

The actual answer to the question as you intend it:
No, and there never will be.
Any application could use anything it wanted for a file format and "manipulate its contents" depends completely on the nature of that application. You cannot expect to have a completely generic solution to an inherently non-generic problem.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It's very difficult to understand what you are asking for, but it sounds like you might want to look at these:
Netbeans
Eclipse

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

One operates on a byte stream from a reader, while the other operates on a String (from any source, not just an input stream).

You may want to read this for further clarification between the two: http://www.codeguru.com/java/tij/tij0113.shtml

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Take a look at the classes available in java.util.zip. They have implementations of CRC32 and Adler32 checksums that may be of use.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You might find that stacks are pretty handy for keeping track of those compound expressions.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'd recommend reading through these tutorials:
http://java.sun.com/developer/technicalArticles/javase/mvc/
http://java.sun.com/developer/onlineTraining/GUI/Swing2/shortcourse.html#DSGUI

It is not the GUI components that you are needing to update in most cases, but their data.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

There is certainly no reason to dispose of a frame and re-display it to update data, and main() should only be called once in a program as an entry point to minimally set up the object(s) your program needs to run.

To update data in a table, update the table model that is bound to that JTable. If you're using a DefaultTableModel, then you can simply call removeRow(int) and it will remove the row entry and fire the appropriate notification event. If you are using your own table model implementation then you will need to handle that yourself.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

What's wrong is that you posted that wall of code without code tags, creating an awful mess that no one is going to wade through to find this vague "event" you refer to.

Not urgent.

jasimp commented: Actually, I couldn't find any events that worked, out of the 15ish I tried in my quick run ;) +8
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Separate the number to the units you want to represent with division, mod, etc. Then use an array or map to translate the digits to words.