Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

@Curt1337: No, no one here will convert the chat server that you copied directly from Rose India to UDP so you can turn it in as a work product.

As Norm said, hire a programmer if you want someone to do your work for you.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You really should not stuff all that GUI code into your main() method, but that's another discussion altogether.

You can still get a reference to the class statically and use getResource like this

Main.class.getResource(...)
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I never bothered with it myself. Perhaps it may help you get that first real job, but beyond that your working experience will be more of a factor than certs in future work. I only know one person who bothered with the JCP and that was only because he was between contracts at the time and just looking for something to do.

If you do decide you'd like to take it, don't pay some prep company a bunch of money to train you for it. There are plenty of reference and practice exams available on the net.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

What Java version are you running this on?

mKorbel commented: new battery included +9
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Please clarify exactly what you are having trouble with.

diafol commented: That was incredibly polite of you +13
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you want to pass an instance of your MyDate class as a parameter, you'll need to create it with 'new' keyword: new MyDate(...) .

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Compare your use of the Student constructor in your main() method with the constructor that you defined in the Student class. The compiler is telling you they are quite different.

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

So now you know that 'cnn' is null. The next step is to figure out why it's null.

mKorbel commented: i love similair answerer, not joke +1 +9
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

MySql would need to be installed locally on their machine.

It would be much easier if you used an embedded database like H2 or JavaDB (Derby) instead.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You code needs to be in a method. You currently have it in the body of the class itself.

Look at your other programs or examples and note how they declare a main() method and put the code in there.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can also rotate the current graphics context with the .rotate() method of the Graphics2D class.

This part of the Java tutorial discusses these transformations.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

@TheDumbestOne: Don't hijack old threads to ask vague questions. If you have something to inquire about, start a new thread and state your question more clearly.

Closing this old thread.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That is exactly what your args parameter to the main method is for.

In the example you mentioned,"java test 2 3", args would include {2,3}.

You can simply access them by index.

int a = args[0];
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Can you help me or tell me what to do? I don't want explinations because i don't UNDERSTAND ANY of it!

Please, can you just help me....

The forums are for helping you work out your programming problems. They aren't a "code on demand" service.

If you aren't willing to put any effort into it, post in the Web Development Jobs sections and pay someone to write it for you.

diafol commented: Nicely put +13
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Take a look at the anchor property.

Edit: You'll also need to look at the weightx property. You can read about it in the general notes for the GridBagLayout class.

masijade commented: I love GBL. ;-) +15
mKorbel commented: both contstrains +1 +9
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Unrelated to your question, but a general advice: do not do this

public class Frame extends JFrame{

JFrame itself extends java.awt.Frame . You're just asking for confusion and possible bugs by naming your class Frame.

mKorbel commented: very good point +9
Anuradha Mandal commented: Good post. +0
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> PS how do you up vote a reply, i can only see how to close the question

Each post has a pair of arrows on the right side. These allow you to up or down vote the post and optionally leave a reputation comment.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You could also use something like this example with a JList: http://www.java2s.com/Code/Java/Swing-Components/TableRowHeaderExample.htm

Majestics commented: Thanx........ +6
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Just add the data to your table model. If you want to render it differently, you can create a custom table cell renderer for that.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Have you tried just specifying "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"?

Majestics commented: Thanx a million. +6
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You're going to need to increment y and repaint() at some point.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The easiest way is to use a label with the icon. Here's a tutorial on that: http://download.oracle.com/javase/tutorial/uiswing/components/icon.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You still didn't post the errors.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That's your assignment, not a specific question. What are you having trouble with specifically? If you're receiving errors, post the stack traces.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Perhaps no one has any useful recommendations for you?

I found this with a quick search, but I don't know a thing about it.

It's a rather esoteric request that you've made, so you can't necessarily assume that people are simply ignoring your post. Most probably just don't have the information you're seeking.

peter_budo commented: Interesting result +16
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Start with this.

When you have some basics in place, post back with your code and specific questions about the parts that are giving you trouble.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

A few possibilities:
You could extend JLabel to maintain a reference to the object, in which case the listener could retrieve it directly from the clicked label.
You could create a listener that keeps a reference to the object and create a new instance for each JLabel.
You could use a Map to store the label to object mappings.

mKorbel commented: still don't undestand OP's reason +1 +9
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I don't see where you specify the table name anywhere in that function, just the column.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

First, I would recommend fixing your indentation in the posted code fragment. People are more willing to read well-formatted code.

Second, I would check the procedure itself. Sounds like it's unhappy about an aggregate function or group clause.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I told you explicitly: update "previousX" in your listener.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> If it is only a handful of times, what does it hurt having it and not using it?
Because any extra feature/button adds an element of confusion (& frustration) for everyone who doesn't know what it is or how to use it.

Tooltips can go a long way towards mitigating that confusion.

WaltP commented: Seems that's what they are for, so why not? With an option to turn them off... +0
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can use any means you wish to load and save the elements with a DefaultListModel. You aren't limited to an array for that.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I don't think you want to just group by last name though. Different families could have the same last name. I would stick to family id.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You could use group_concat() and group by student id.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Nah. I have other more pressing things to work on.

Perhaps you should give it a try yourself. When you have some code or specific questions about the parts you are stuck on, come back and post them and perhaps someone can offer some assistance.

bbman commented: Reaching the goal is important...but not the path... -1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> 99% of "SEO spammers" are people who would really make excellent contributing members of our community

I would say closer to 5% at best. The other 95% are blathering idiots that only sign up to parrot useless "advice" they copied from a poster above or some article farm content in an effort to spread their signatures around.

If they actually want to learn and have productive discussions about SEO and internet marketing then they should be willing to do it without any signatures. Turn off signatures completely for a month and see what happens. Just consider it an experiment.

iamthwee commented: No signatures is a good idea. +0
WaltP commented: I agree. 99%? Get real! +0
diafol commented: Sigs suck anyway - pointless nonsense - put crud in your profile if you want to - no need for sigs :) +0
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, I would say your thread is the problem. It will repaint just like you want it to - once. There is no loop. You get one repaint and you're done.

You could either add a loop with a sleep() in it or switch to a Swing Timer and put your current run() code into an ActionListener.

mKorbel commented: that's right +9
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The get() method will return an element by index from a Vector.

I'd recommend using ArrayList instead of Vector unless you need a synchronized collection (and I doubt that you do). The get() method is still the same.

You might also consider using Point objects instead of keeping separate lists for the x and y values.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And where are you initializing your jTable2 instance?

Edit: cross-post. I knew you would see it eventually :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The statement you added would work, though I would imagine it's giving you fits about a null pointer. You can't assign a model to a table you haven't created yet.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, the trouble is in your constructor. You declare a variable 'tableModel', initialize it, and add a listener to it - and then you don't do anything with it. It goes out of scope.

Your JTable is still using whatever default model it had in initComponents(). If you want to use the 'tableModel' you created, you can use the JTable.setModel(); method or pass that model to the JTable constructor when you create the table.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I don't think the OP is still working on this 2 years later. Closing.

Killer_Typo commented: if he is working on this 2yrs later there might be something wrong! :) +9
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You should ask for a refund.

katmai539 commented: And sue them for being "not very helpful" +4
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Then you will need to loop the cells and find it before you can select it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ah, yes, selection is different. You can use the methods on JTable to select both the row and column setRowSelectionInterval(int index0, int index1) and
setColumnSelectionInterval(int index0, int index1).

You'll still need the highlight renderer if you want to make a cell red.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I just posted an example of this over in a similar thread about JTable here. Perhaps it will help.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

There is not a row renderer per se, so you have to install a cell renderer on all columns that will check the particular column values and apply the formatting as necessary.

Here is a skeletal highlight renderer to give you an idea to work from

class HighlightRenderer extends DefaultTableCellRenderer {

    private final Color HIGHLIGHT_COLOR = Color.YELLOW;

    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {

        Component comp = super.getTableCellRendererComponent(table, value, isSelected,
                hasFocus, row, column);

        if ( [highlight condition] ) {
            if (isSelected) {
                comp.setBackground(new Color((HIGHLIGHT_COLOR.getRGB() 
                        ^ comp.getBackground().getRGB())));
                comp.setForeground(new Color(Color.BLACK.getRGB() 
                        ^ comp.getForeground().getRGB()));
            } else {
                comp.setBackground(HIGHLIGHT_COLOR);
                comp.setForeground(Color.BLACK);
            }
        } else {
            if (isSelected) {
            } else {
                comp.setBackground(Color.WHITE);
                comp.setForeground(Color.BLACK);
            }
        }
        return comp;
    }
}

You can install the renderer directly on the columns

TableColumnModel colModel = table.getColumnModel();
            for (Enumeration<TableColumn> colEnum = colModel.getColumns(); colEnum.hasMoreElements();) {
                TableColumn c = colEnum.nextElement();
                c.setCellRenderer(new HighlightRenderer());
            }

or override getCellRenderer() on the JTable as noted in the JTable tutorial here.

mKorbel commented: that job for prepareRenderer, don't do it that this way +8
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can try replaceAll("<.+?\\>", "")

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The problem is that the GridLayout sizes each grid cell the same, so when you increased the height of your textfield by changing the font size, you increased the height of all rows in the grid.

To get around that you could use a BorderLayout of two panels, one with your text field at the top and another for all of your other buttons in the center.

That would allow you to separate the sizing of the two sections. Take a glance at this change to your layout code

//Setting the layout
JPanel upper = new JPanel();
upper.setLayout(new GridLayout(1,1));
upper.add(jtfTxt);

JPanel lower = new JPanel();
lower.setLayout(new GridLayout (13, 1, 2, 2) );
lower.add(p1);
lower.add(p2);
lower.add(p3);
lower.add(p4);
lower.add(p12);
lower.add(p5);
lower.add(p11);
lower.add(p6);
lower.add(p7);
lower.add(p8);
lower.add(p9);
lower.add(p10);

f.setLayout(new BorderLayout());
f.add(upper, BorderLayout.NORTH);
f.add(lower,BorderLayout.CENTER);
f.setJMenuBar(mb);
f.setResizable(false);
f.setBackground(Color.black);
f.pack();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
mKorbel commented: good suggestion +1 +8