Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Please post a question. There is no question above.

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

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

Did you bother to read any of the sticky thread at the top of the forum?

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

Just don't install your custom renderer for that column. Since you're iterating all of the columns in the model and adding it, just skip the first one.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It states Unclosed String Literal. Check your String array initialization.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> Anyways I'm using Netbeans and it doesn't allow me to modify the declaration of my variables.(or I don't know how to)

You can customize the create/initialization code for components added through the designer by selecting the component and then selecting the "Code" tab in the Properties window. To override a method, you would add your code to the "Custom Creation Code" property.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

@mKorbel: Interesting link. Thanks for posting that, as I hadn't run across that way of doing it before.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You need to set it back to the normal default colors if the highlight condition is false.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I can't say for certain which character your file is actually using for the line break. A direct copy of your text above pasted into Word seems to have "vertical tab" (chr(11)) characters at the end of the lines.

Those can be replaced with the following loop

For i = 1 To ActiveDocument.Paragraphs.Count
    ActiveDocument.Paragraphs(i).Range.Text = Replace(ActiveDocument.Paragraphs(i).Range.Text, Chr(11), " ")
Next i

Those may not be the same characters coming in with your actual file though because copying and pasting into Word can vary depending on the copy source.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

In the for..each loop. Each paragraph is concatenated into 'str'. 'para.Range.Text' is the text of the current paragraph, in which I am replacing the carriage returns with a single space before I add it to the string.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

This code fragment worked for me on the paragraph that you posted. I seldom use VBA for anything either, so my knowledge of it is pretty limited. I'm just hacking something together here

Dim str As String
Dim para As Paragraph
For Each para In ActiveDocument.Paragraphs
    str = str & Replace(para.Range.Text, vbCr, " ")
Next para
ActiveDocument.Range.Text = str
End Sub

Word was treating every line as a paragraph when I opened your text from a simple text file, so I had to concatenate them together to form the single string. Your file may or may not contain vbCR or vbCrLf ofr the line breaks. You'll have to determine that for yourself by examination.

Perhaps someone else more versed in VBA in Word will chime in with some further advice.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The function I posted above replaces carriage return line feeds (CrLf) with a single space. The [yourStringHere] part should be whatever variable you use to hold that entire paragraph string.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Have you tried using Replace([yourStringHere], vbCrLf, " ") against the entire string?

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

You didn't say which line the error was on, but if I had to guess I would imagine one these

int row = jTable2.getSelectedRow();
        int col = jTable2.getSelectedColumn();

if you don't have a cell selected in the table. They both return -1 if no selection exists.

It doesn't look like you're even using those values. Try removing those two lines.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Moving to PHP.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Seems like the PHP forum might be a better audience for this. Moving it over there.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You should still be able to get the model in the same manner you did before. If you need to access the model often, you can also keep a reference to it as an instance variable and use it without having to use getModel() all the time.

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

What error did you receive in the previous code you posted?

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

You tried what? I wrote above what you need to do. Post your revised code.

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 think you need to read a little about what a List is.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

What's your question? Seems like you still need to work on this part

//Code goes here...
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The import part of that example code is the listener being added to the JTable

jTable2.getModel().addTableModelListener(new TableModelListener() {

          public void tableChanged(TableModelEvent e) {
             System.out.println(e+"  cacat");
             //jTable2.setValueAt("",0,0);
          }
        });

You need to put that in your code somewhere after you have initialized 'jTable2'. It only needs to be done once when you are setting up the table.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

"Does not work" is pretty vague. Using the TableModelListener as mKorbel linked to should work just fine.

Post the code that you used for your listener.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Did start at [nrrows] or [nrrows-1]?

Put in a println debug statement just before the line the error occurs on and figure out why it's sending too high an index value.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> in my case if I have a table with 20 rows I'd have 20 different highlight conditions.

It's really just two highlighting conditions that you mentioned:
- table.getValueAt(row, whateverColumnToCheck) < threshold => change font on component
- value < 0 => change color on component

The parameters to getTableCellRendererComponent() pass you all that info you need to check those conditions.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No, the note at the bottom about overriding getCellRenderer() is about how you set the renderer on the column. You can override that method to return an instance of your custom TableCellRenderer or you can set it explicitly through the column model with the TableColumn.setCellRenderer() method. Those two methods only deal with how you specify the renderer component to use.

Don't confuse that with the getTableCellRendererComponent() method of the TableCellRenderer interface, which is what you override to specify how the cell is rendered.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can add various selection intervals through the methods on ListSelectionModel, but setting multiple, non-contiguous single cells is tricky and not really that useful.

You are better off highlighting them and perhaps selecting the first.

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

I agree with web-guy's earlier suggestion that you probably need to outer join your customer table to your invoice table for the sums. I assume that the customers who have no orders have no records in the invoice table. If they aren't in the table, they aren't going to appear in your group by results.

Try using [customer table] left outer join [invoice table] on the customer Ids.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

My preference is H2, but JavaDB/Derby is a fine embedded database as well.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

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

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Javac.exe is used to compile a .java source file. Java.exe is used to run a compiled class file or jar file.

You can learn how to use those tools here.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Consider anchoring.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You'll be able to see the locations easier if you change all of those 9, 17, etc to simpler values like 0,1,2 to address the cells. There is no reason they need to be so large. Also remember that indexing begins at 0.

So your "+/-" button should be located at gridx=2, gridy=4 if you normalized those grid positions.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Consider that components don't fill their grid cells unless you specify that in the constraints. The default is no fill.

You also need to specify how "extra" space gets divided up horizontally and vertically with the weightx and weighty properties. The default is 0, so if you want a component to take some of that extra space you need to set a value for it 0 < weight <= 1.0 GridBag is just one of those layouts you have to work with on your own until you "get it" and that can take a little time.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you want the components to fill space horizontally or vertically, you need to set that with the 'fill', 'weightx' and 'weighty' properties.

'anchor' will let you set which side components are "stuck to".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I think you are confusing grid cells and pixel dimensions.

You only need to use setPreferredSize if you want to change the default size in pixels for a component. That is unrelated to how many grid cells that a component may occupy.

If your component are now on top of one another, then you have not placed them into the proper grid cells with 'gridx' and 'gridy'. You were pretty close with the layout posted above, but as I mentioned, you don't need to use multiples of 4 to specify the grid cells. 0,1,2, etc will suffice.

They are just cell locations in a grid of hypothetical squares - not actual heights/widths.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Sorry, the method is actually setPreferredSize(Dimension)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Why are you using widths/heights of 4 and 8, instead of simply 1 and 2?

> Also no matter what I change the button sizes to they stay the same size.
You can call setPreferredWidth() on your buttons to specify their preferred size to the layout manager.