JFreeChart SplineRenderer code problem

I tried to write simple JFreeChart SplineRenderer code, but it don't work. Can sameone tell whats wrong with it? Netbeans say that error is in XYPlot plot = new XYPlot(dataset, xax, yax, spline); line. I'm newbie in java programming...
package kubas;
import org.jfree.chart.*;
import org.jfree.chart.axis.*;
import org.jfree.chart.plot.*;
import org.jfree.chart.renderer.xy.XYSplineRenderer;
import org.jfree.data.xy.*;
import org.jfree.ui.ApplicationFrame;
public class spausdink {
public static void main(String[] args) {
XYSeries series = new XYSeries("XY grafikas");
series.add(1, 2);
series.add(2, 4);
series.add(3, 8);
series.add(4, 16);
series.add(5, 32);
series.add(6, 64);
series.add(7, 128);
series.add(8, 256);
series.add(9, 512);
series.add(10, 1024);
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series);
ApplicationFrame frame = new ApplicationFrame("Mano grafikas");
XYSplineRenderer spline = new XYSplineRenderer();
NumberAxis xax = new NumberAxis("x");
NumberAxis yax = new NumberAxis("y");
XYPlot plot = new XYPlot(dataset, xax, yax, spline);
JFreeChart chart = new JFreeChart(plot);
ChartPanel chartPanel = new ChartPanel(chart);
frame.setContentPane(chartPanel);
frame.pack();
frame.setVisible(true);
Edited by: 987101 on 2013.2.8 17.48
Edited by: 987101 on 2013.2.8 17.53

I have another problem. I want to make graphs without points, but only higher graph is without points, what I should change in code to hide points in both graphs?
import java.awt.Color;
import org.jfree.chart.*;
import org.jfree.chart.axis.*;
import org.jfree.chart.plot.*;
import org.jfree.chart.renderer.xy.XYSplineRenderer;
import org.jfree.data.xy.*;
import org.jfree.ui.ApplicationFrame;
public class code {
public static void main(String[] args) {
XYSeries series1 = new XYSeries("XY graph first");
series1.add (0, 0);
series1.add (1, 20);
series1.add (2, 70);
series1.add (3, 140);
series1.add (4, 210);
series1.add (5, 280);
series1.add (6, 360);
series1.add (7, 600);
series1.add (8, 800);
series1.add (9, 1000);
series1.add (10, 1200);
XYSeries series2 = new XYSeries("XY graph second");
series2.add(0, 0);
series2.add(1, 2);
series2.add(2, 4);
series2.add(3, 8);
series2.add(4, 16);
series2.add(5, 32);
series2.add(6, 64);
series2.add(7, 128);
series2.add(8, 256);
series2.add(9, 512);
series2.add(10, 1024);
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series1);
dataset.addSeries(series2);
ApplicationFrame frame = new ApplicationFrame("Graph");
NumberAxis xax = new NumberAxis("X axis");
NumberAxis yax = new NumberAxis("Y axis");
XYSplineRenderer spline = new XYSplineRenderer();
spline.setPrecision(10);
XYPlot xyplot = new XYPlot(dataset, xax, yax, spline);
//Design
spline.setSeriesShapesVisible(0, false);
xyplot.setBackgroundPaint( Color.pink );
xyplot.setDomainGridlinePaint( Color.WHITE );
xyplot.setRangeGridlinePaint( Color.WHITE );
JFreeChart chart = new JFreeChart(xyplot);
ChartPanel chartPanel = new ChartPanel(chart);
frame.setContentPane(chartPanel);
frame.pack();
frame.setVisible(true);
Edited by: 987101 on 2013.2.14 17.05

Similar Messages

  • Messy code problem while translating XString to String in OfficeControl

    Hi Expert,
        I have messy code problem while translating XString to String in XML-Format Word Doc in OfficeControl.
    I upload an XML-Format template Word Doc to server as a MIME Object.
    When OfficeControl is started in Web Dynpro, OfficeControl automatically open the XML-Format template.
    For the first time, I get the XString-type Context attribute bind to the content of the Word Doc,
    then translate it to string, I got the XML-format content, it's great!
    However, after the first time, when I input any new contents in MS Word in Web Dynpro,
    no matter I execute "Ctrl + S" or click the "savedocument" button,
    when I translate the XString Context attribute to String, I got messy code. (but the first time, it is good plain text)
    I use the function module: ECATT_CONV_XSTRING_TO_STRING (good for first time, dump after first time),
    SCMS_XSTRING_TO_BINARY, SCMS_BINARY_TO_STRING (good for first time, messy code after first time).
    My Demo source code is in: (system) SMV --> (local object) zhaode --> (Dynpro Component) ztest_office_control
    core source code is as:
    clear itab.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
    BUFFER = lv_datas
    IMPORTING
    OUTPUT_LENGTH = lv_length
    TABLES
    binary_tab = itab.
    CALL FUNCTION 'SCMS_BINARY_TO_STRING'
    EXPORTING
    input_length = lv_length
    mimetype = 'text/plain; charset=utf-8'
    IMPORTING
    text_buffer = lv_datas_string
    output_length = lv_data_len
    TABLES
    binary_tab = itab.
    Can you give me some advice?
    Many thanks in advance.
    Best Regards,

    You have already posted this same question several times (and some very similiar questions) within the forum.  Please do NOT multiple post your questions. This is against the forum rules of engagement. SAP employee or not, you will find yourself banned from the forums if you don't follow the rules.

  • My iTunes won't detect my iPhone that has to be restored via iTunes *because if pass code problems* and its running iOS 7.2

    my iTunes won't detect my iPhone that has to be restored via iTunes *because if pass code problems* and its running iOS 7.0.4

    If itunes is comming up and saying it can't read the device because it's locked with a passcode, you may have to put your device into recovery mode first.
    To put your device in recovery mode: (Following these steps will erase your device and reset everything to factory defaults)
    1) press and hold the power button until you see the slide to power off option
    2) swipe to power off
    3) Press and hold the home button while the device is off and connect it to your computer. Continue holding the home button until you see a graphic with the iTunes logo with a picture of a USB cable below it.
    4) iTunes should give you a message that it has detected a device in recovery mode. Click ok and then select Restore iPhone. iTunes will download a fresh copy of iOS and then wipe the device and restore it. Depending on the speed of your computer's internet connection this may take a while. Just leave the iphone connected to your computer until it's finished.
    If itunes is not detecting it at all or is Not giving you the message that the phone is locked with a passcode, you may end up having to reinstall itunes. This seems to be a fairly common problem after the most recent itunes update (11.1.5)
    If this is the case and you happen to be running a windows based computer you will have to uninstall itunes in this order from your programs and features option in control panel:
    iTunes
    Apple Software Update
    Apple Mobile Device Support
    Bonjour
    Apple Application Support (iTunes 9 or later)
    Then download and reinstall itunes from itunes.com try putting your device into recovery mode again and restore.
    Hope this helps.
    Cheers.

  • Visual basic code problem

    Hello!
    I want to use visual basic to build a htm which can control labview throght datasocket, i set the switch
    as " Swithc until release " in visual basic, the code is
    Private Sub CWButton1_Click()
    CWDataSocket1.Data = CWButton1.Value
    End Sub
    but the led of labview can't light on.
    is the code problem?
    thanks!

    The problem is most likely because you have the code in the Click() event handler. The click event in VB is a left mouse down AND mouse up over the controls. If you are wanting it to send out the value when you press and hold the button down, change the event handler to the ValueChanged event.
    Best Regards,
    Chris Matthews
    National Instruments

  • KMS 9.0 trial code problem

    First of all i want so say sorry for my bad english.
    I,m from germany and i installed the file "kmsecurity9379eu2_129945.sis" from ovi store.
    My mobile phone is Nokia 5230 NAVI.
    After the trial i want to uninstall the app.
    But now i need a code to uninstall KMS 9.0.
    I've never set any code at installation and it's not my pin-code or something like 0000.
    I tried to ask the people from kaspersky to help me with that problem.
    At their forum there is an guy named Viktor "Head of Mobile Development" who want's the imei nummers from the people with that code-problem.
    But i cannot contact him, cause his inbox is always full.
    So what can i do?
    Don't want to hard reset my phone, cause there are many apps i payed for.
    And please remove the app from ovi store, cause many people have that problem.

    At first, I thought I have the same problem. I am trying to uninstall the App but it's asking for a code. But after searching for an answer online. It come to m mind that I entered an 8 digit code. I tried to enter the code. And bingo! I was able to remove it from my nokie e5-00.  Definitely, you entered a code as you cannot continue to install the trial version without creating your own code. No need to hard reset your phone.

  • JFreeChart Dual Axis Problem

    Hi:
    I've developed a Dual Axis Chart (bar and line char) using the JFreeChart library.
    However, when the chart is displayed in the screen the line chart appears always behind the bar chart. How can I solve this? I would like that the bar chart appears behind the line chart.
    Here you can find a little bit of code:
               final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
               final DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
    // Here I add values to the datasets
                JFreeChart chart;
                if(tres.isSelected()) chart = ChartFactory.createBarChart3D("EVOLUCI� DE LA PRODUCCI� DE RESIDUS MUNICIPALS ("+c+") "+dd1+" --> "+dd2+". QUANTITATS EXPRESADES EN KG. / HAB. * DIA", "MES", "KG. / HAB. * DIA", dataset, PlotOrientation.VERTICAL, true, true, false);
                else chart = ChartFactory.createBarChart("EVOLUCI� DE LA PRODUCCI� DE RESIDUS MUNICIPALS ("+c+") "+dd1+" --> "+dd2+". QUANTITATS EXPRESADES EN KG. / HAB. * DIA", "MES", "KG. / HAB. * DIA", dataset, PlotOrientation.VERTICAL, true, true, false);
                chart.setBackgroundPaint(new Color(204, 204, 255));
                final CategoryPlot plot = chart.getCategoryPlot();
                plot.setBackgroundPaint(Color.white);
                plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
                plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
                final CategoryItemRenderer renderer1 = plot.getRenderer();
                renderer1.setSeriesPaint(0, Color.RED);
                final ValueAxis axis2 = new NumberAxis3D("POBLACI�");
                plot.setRangeAxis(1, axis2);
                plot.setDataset(1, dataset2);
                plot.mapDatasetToRangeAxis(1, 1);
                final CategoryItemRenderer renderer2 = new LineAndShapeRenderer();
                renderer2.setSeriesPaint(0, Color.blue);
                plot.setRenderer(1, renderer2);
                plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);
                plot.setNoDataMessage("NO HI HA DADES");
                ChartFrame frame = new ChartFrame("COMPOSICI� DELS RESIDUS MUNICIPALS", chart);
                frame.setIconImage(new ImageIcon(getClass().getResource("/rsu/Imatges/reciclatge.gif")).getImage());
                frame.pack();
                Dimension dPan = Toolkit.getDefaultToolkit().getScreenSize();
                Dimension dFin = frame.getSize();
                Double x = new Double((dPan.getWidth()-dFin.getWidth())/2);
                Double y = new Double((dPan.height - dFin.height)/2);
                frame.setLocation(x.intValue(), y.intValue());
                frame.setVisible(true);Lots of thanks for your help.

    Hi, I'm new using Java and JFreeChart and I'm facing a problem. I need to draw a XY chart with 2 series and assign each one a choosen color, but I can only have them in the same color! I don't know what I'm doing wrong. Can anybody help me whit this?
    Thanks in advance,
    Freddy
    P.D: This is the code for what I'm trying to do (excuse my english)
    final TickUnits units = new TickUnits();
                   units.add(new NumberTickUnit(337.5, new CompassFormat()));
                   units.add(new NumberTickUnit(315.0, new CompassFormat()));
                   units.add(new NumberTickUnit(292.5, new CompassFormat()));
                   units.add(new NumberTickUnit(270.0, new CompassFormat()));
                   units.add(new NumberTickUnit(247.5, new CompassFormat()));
                   units.add(new NumberTickUnit(225.0, new CompassFormat()));
                   units.add(new NumberTickUnit(202.5, new CompassFormat()));
                   units.add(new NumberTickUnit(180.0, new CompassFormat()));
                   units.add(new NumberTickUnit(157.5, new CompassFormat()));
                   units.add(new NumberTickUnit(135.0, new CompassFormat()));
                   units.add(new NumberTickUnit(112.5, new CompassFormat()));
                   units.add(new NumberTickUnit(90.0, new CompassFormat()));
                   units.add(new NumberTickUnit(67.5, new CompassFormat()));
                   units.add(new NumberTickUnit(45.0, new CompassFormat()));
                   units.add(new NumberTickUnit(22.5, new CompassFormat()));
                   XYDataset dataset7 = createhourDataset(24,50,"Velocidad");
                   JFreeChart chart8 = ChartFactory.createTimeSeriesChart("Diaria", "Hora", "mps", dataset7, true, true, false);
                   XYPlot plot2wd1 = chart8.getXYPlot();
                   final XYItemRenderer r1 = plot2wd1.getRenderer();
                   r1.setSeriesPaint(0, Color.RED);
                   ValueAxis axis2wd1 = new NumberAxis("");
                   axis2wd1.setRange(0.0, 360.0);
                   plot2wd1.setRangeAxis(1, axis2wd1);
                   axis2wd1.setStandardTickUnits(units);
                   axis2wd1.setAxisLinePaint(Color.blue);
                   axis2wd1.setTickLabelPaint(Color.blue);
                   axis2wd1.setTickMarkPaint(Color.blue);
                   plot2wd1.setDataset(1, createhourDataset(24,50,"Direcci�n"));
                   final XYItemRenderer r2 = plot2wd1.getRenderer();
                   r2.setSeriesPaint(0, Color.blue);
                   plot2wd1.setRenderer(1, r2);
                   ChartPanel panel_D1 = new ChartPanel(chart8);

  • Tax code problem

    We are using Taxinj tax procedure with different tax codes as per the sale tax like VAT 4 % and VAT 12.5 % ,CST etc.
    Now somebody has made the changes in % of sale tax in JIN6 in existing tax code and save it.Then craete the sales order with that tax code(with wrong %) and do the cycle upto Billing.
    After knowing all this issue I have made that changes back in that tax code but now systen is not determing the sales tax conditions in pricing procedure.UTXJ condition type is picking the relevant tax code and it also picks the Excise values correctly but not tha sale tax conditions.
    In previous open sales orders system is picking the JIN6 but for new orders it is not picking.
    What should I do?
    Please help me.
    Regards

    Hi,
    Now I have deactivated the JIN6 field and put the original % and save it but still it is not showing the JIN6 percentage in new sales orders.
    It is still showing the correct % in old sales orders and even if I am putting the new line item in old sales order it is still working.
    There is validity problem I think.What should I do more?
    One more clarification I want.
    As per SAP notes in TAXINJ we can use VK19 for maintaining the Excise condition % like JMOD ,JECS and J1AX otherwise we need to remove stastical mark from Taxinj then only we can put % for Ecxise in Tax code.
    JIN6 and JIN7 we are directly maintaining in FTXP.
    If we are maintaining sale tax rate in FTXP we can see that values reflected in VK19 also for JIN6 and JIN7.
    Then why we cannot use VK19 in TAXINJ?
    I need your help Lakhsmi.
    Regards

  • JTable displays string in wrong order : my code problem or Java problem ?

    I have the following code that displays data in a JTable, most of the time it works fine, but I've realized when I have a cell with values like : "Snowboarding"+"[123456789]"
    It would display it as : [Snowboarding[123456789
    For a string like : "Chasing toddlers"+"<123456789>"
    It would display it as : <Chasing toddlers<123456789
    It not only moved the last bracket to the front, but also changed its direction from "]" to "[" and from ">" to "<"
    Is there anything wrong with my code ? Or is this a Java problem ?
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import java.util.List;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    public class Table_Panel extends JPanel implements ItemListener
      public static final long serialVersionUID=26362862L;
      static final int Row_Color_Style_Default=-1,Row_Color_Style_None=0,Row_Color_Style_Blue_Gray=1,Row_Color_Style_Cyan_Gray=2,Row_Color_Style_Blue=3,
                       Row_Color_Style_Gray=4,Row_Color_Style_Red_Green=5,Row_Color_Style_Green_Yellow=6,Row_Color_Style_Red_Yellow=7,
                       Max_Header_Cell_Width=0,Header_Width=1,Cell_Width=2;
      static int Row_Color_Style=Row_Color_Style_Cyan_Gray,Preffered_Width=Header_Width;
    //  static int Row_Color_Style=Row_Color_Style_None,Preffered_Width=Header_Width;
    //boolean        Debug=true,
      boolean        Debug=false,
    //               Use_Row_Colors=true,
                     Use_Row_Colors=false;
      JFrame Table_Frame;
      TableModel My_Model;
      JScrollPane scrollPane=new JScrollPane();
      public JTable Table;
      static String columnNames[],Default_Delimiter=\",\";
      Object[][] data;
      static Dimension Screen_Size=Toolkit.getDefaultToolkit().getScreenSize();
      int Column_Width[];
      static Color Default_Selection_Color=new Color(250,135,200);
      Color Selection_Color=Default_Selection_Color;
      public Table_Panel(ResultSet RS,String Table_Name,boolean Show_External_Table,int Row_Color_Style,int Preffered_Width,boolean In_Original_Order)
        String Value,Table_Column_Names[]=null;
        Object[][] Table_Data=null;
        int Row_Count,Index=0;
        try
          if (RS==null) return;
          else
            RS.last();
            Row_Count=RS.getRow();
            RS.beforeFirst();
          ResultSetMetaData rsmd=RS.getMetaData();
          int Column_Count=rsmd.getColumnCount();
          Table_Column_Names=new String[Column_Count];
          Table_Data=new Object[Row_Count][Column_Count];
          for (int i=1;i<=Column_Count;i++) Table_Column_Names[i-1]=rsmd.getColumnLabel(i);            // Get column names
    //Out("Row_Count="+Row_Count+"  Column_Count="+Column_Count);
          while (RS.next())                                                                            // Get all rows
            for (int i=1;i<=Column_Count;i++)
              Value=RS.getString(i);
              Table_Data[Index][i-1]=(Value==null)?"null":Value;
            Index++;
    //      if (Test_Ct++>300) break;
        catch (Exception e) { e.printStackTrace(); }
        scrollPane=new Table_Panel(Table_Name,Table_Column_Names,Table_Data,Table_Data.length,false,Show_External_Table,false,Row_Color_Style,Preffered_Width,Selection_Color,In_Original_Order).scrollPane;
      public Table_Panel(String[] Table_Column_Names,Object[][] Table_Data,Color Selection_Color,boolean In_Original_Order)
        this("",Table_Column_Names,Table_Data,Table_Data.length,false,false,false,Row_Color_Style,Preffered_Width,Selection_Color,In_Original_Order);
      public Table_Panel(String Table_Name,String[] Table_Column_Names,Object[][] Table_Data,boolean Show_External_Table,Color Selection_Color,boolean In_Original_Order)
        this(Table_Name,Table_Column_Names,Table_Data,Table_Data.length,false,Show_External_Table,false,Row_Color_Style,Preffered_Width,Selection_Color,In_Original_Order);
      public Table_Panel(String Table_Name,String[] Table_Column_Names,Object[][] Table_Data,int Row_Count,boolean Is_Child,boolean Show_External_Table,boolean Manage_Attachment,int Row_Color_Style,int Preffered_Width,Color Selection_Color,boolean In_Original_Order)
        columnNames=Table_Column_Names;
        if (In_Original_Order) data=Table_Data;
        else
          data=new Object[Table_Data.length][columnNames.length];
          for (int row=0;row<Table_Data.length;row++)
            data[row]=new Object[columnNames.length];
            for (int Column=0;Column<Table_Data[row].length;Column++) data[row][Column]=Table_Data[Table_Data.length-1-row][Column];
        Column_Width=new int[columnNames.length];
        this.Row_Color_Style=Row_Color_Style;
        Use_Row_Colors=(Row_Color_Style!=Row_Color_Style_None);
        this.Preffered_Width=Preffered_Width;
        if (Selection_Color!=null) this.Selection_Color=Selection_Color;
    //    Out("this.Selection_Color="+this.Selection_Color);
    //    TableModel My_Model=new DefaultTableModel(Table_Data,columnNames)
        TableModel My_Model=new DefaultTableModel(data,columnNames)
          public int getColumnCount() { return columnNames.length; }
          public int getRowCount() { return data.length; }
          public String getColumnName(int col) { return columnNames[col]; }
          public Object getValueAt(int row,int col)
    //      Out(row+","+col+"["+data[row][col]+"]   data.length="+data.length+"  data[0].length="+data[0].length);
            return (data[row][col]==null)?"":((data[row][col] instanceof Boolean)?data[row][col]:data[row][col].toString()); // Non-boolean values will have bgcolor
          public Class getColumnClass(int column)
            Class returnValue;
            if ((column>=0) && (column<getColumnCount())) returnValue=getValueAt(0,column).getClass();
            else returnValue=Object.class;
            return returnValue;
        // JTable uses this method to determine the default renderer/editor for each cell. If we didn't implement this method, then the last column would contain text ("true"/"false"), rather than a check box.
    //    public Class getColumnClass(int c) { return getValueAt(0,c).getClass(); }
          // Don't need to implement this method unless your table's editable.
          public boolean isCellEditable(int row,int col)
            //Note that the data/cell address is constant, no matter where the cell appears onscreen.
            if (col<0) return false;
            else return true;
          // Don't need to implement this method unless your table's data can change.
          public void setValueAt(Object value,int row,int col)
            String Execution_Dir=getClass().getProtectionDomain().getCodeSource().getLocation().toString();
            if (Debug) System.out.println("Execution_Dir="+Execution_Dir+"\nLast_Value="+Table_Grid_Cell_Renderer.Last_Value+"  Setting value at [ "+row+","+col+" ] to "+value+" (an instance of "+value.getClass()+")");
            if (Execution_Dir.toLowerCase().indexOf("c:/")!=-1 || value.getClass()==Boolean.class || !Use_Row_Colors) data[row][col]=value;
    //     else data[row][col]=(Table_Grid_CellRenderer.Last_Value==null)?value:value.toString().substring(Table_Grid_CellRenderer.Last_Value.toString().length());
            fireTableCellUpdated(row,col);
            if (Debug)
              System.out.println("New value of data :");
              printDebugData();
          private void printDebugData()
            int numRows=getRowCount();
            int numCols=getColumnCount();
            for (int i=0;i<numRows;i++)
              System.out.print("    row "+i+":");
              for (int j=0;j<numCols;j++) System.out.print("  "+data[i][j]);
              System.out.println();
            System.out.println("--------------------------------------------------------------------------");
        TableSorter sorter=new TableSorter(My_Model);
        Table=new JTable(sorter)
    //    Table=new JTable(My_Model)
          public static final long serialVersionUID=26362862L;
          public String getToolTipText(MouseEvent e)           // Implement table cell tool tips.
            Object Cell_Tip;
            String tip=null;
            java.awt.Point p=e.getPoint();
            int rowIndex=rowAtPoint(p);
            int colIndex=columnAtPoint(p);
            int realColumnIndex=convertColumnIndexToModel(colIndex);
            Cell_Tip=getValueAt(rowIndex,colIndex);
    //        if (realColumnIndex == 2)                         //Sport column
              tip=Cell_Tip.toString();
            else if (realColumnIndex == 4)                      //Veggie column
              TableModel model=getModel();
              String firstName=(String)model.getValueAt(rowIndex,0);
              String lastName=(String)model.getValueAt(rowIndex,1);
              Boolean veggie=(Boolean)model.getValueAt(rowIndex,4);
              if (Boolean.TRUE.equals(veggie)) tip=firstName+" "+lastName+" is a vegetarian";
              else tip=firstName+" "+lastName+" is not a vegetarian";
            else
              // You can omit this part if you know you don't have any renderers that supply their own tool tips.
              tip=super.getToolTipText(e);
            return tip;
    //    RowSorter<TableModel> sorter=new TableRowSorter<TableModel>(My_Model);
    //    Table.setRowSorter(sorter);
        Table.setSelectionBackground(this.Selection_Color);
        int Table_Height=Table.getRowHeight()*Row_Count;
        // sorter.addMouseListenerToHeaderInTable(Table);      // ADDED THIS
        sorter.setTableHeader(Table.getTableHeader());
        if (Table_Column_Names.length>20) Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        if (Manage_Attachment) Table.setPreferredScrollableViewportSize(new Dimension(500,(Table_Height>850)?850:Table_Height));
        else Table.setPreferredScrollableViewportSize(new Dimension(1000,(Table_Height>850)?850:Table_Height));
        if (Use_Row_Colors) Table.setDefaultRenderer(Object.class,new Table_Grid_Cell_Renderer());
        //Create the scroll pane and add the table to it.
        scrollPane=new JScrollPane(Table);
        //Set up column sizes.
        initColumnSizes(Table,My_Model);
        //Add the scroll pane to this window.
        if (Show_External_Table)
          Table_Frame=new JFrame(Table_Name);
          Table_Frame.getContentPane().add(scrollPane);
          Table_Frame.addWindowListener(new WindowAdapter()
            public void windowActivated(WindowEvent e) { }
            public void windowClosed(WindowEvent e) { }
            public void windowClosing(WindowEvent e)  { System.exit(0); }
            public void windowDeactivated(WindowEvent e)  { }
            public void windowDeiconified(WindowEvent e)  { scrollPane.repaint(); }
            public void windowGainedFocus(WindowEvent e)  { scrollPane.repaint(); }
            public void windowIconified(WindowEvent e)  { }
            public void windowLostFocus(WindowEvent e)  { }
            public void windowOpening(WindowEvent e) { scrollPane.repaint(); }
            public void windowOpened(WindowEvent e)  { }
            public void windowResized(WindowEvent e) { scrollPane.repaint(); } 
            public void windowStateChanged(WindowEvent e) { scrollPane.repaint(); }
          Table_Frame.pack();
          Table_Frame.setBounds((Screen_Size.width-Table_Frame.getWidth())/2,(Screen_Size.height-Table_Frame.getHeight())/2,Table_Frame.getWidth(),Table_Frame.getHeight());
          Table_Frame.setVisible(true);
          if (Is_Child) Table_Frame.addComponentListener(new ComponentAdapter() { public void componentClosing(ComponentEvent e) { System.exit(0); } });
        else add(scrollPane);
      public Table_Panel(String File_Name) { this(File_Name,false,Row_Color_Style_Cyan_Gray,Preffered_Width,null,Default_Selection_Color,true); }
      public Table_Panel(String File_Name,int Row_Color_Style,boolean In_Original_Order) { this(File_Name,false,Row_Color_Style,Preffered_Width,null,Default_Selection_Color,In_Original_Order); }
      public Table_Panel(String File_Name,String Delimiter,boolean In_Original_Order) { this(File_Name,false,Row_Color_Style_Cyan_Gray,Preffered_Width,Delimiter,Default_Selection_Color,In_Original_Order); }
      public Table_Panel(String File_Name,int Preffered_Width,String Delimiter,boolean In_Original_Order) { this(File_Name,false,Row_Color_Style,Preffered_Width,Delimiter,Default_Selection_Color,In_Original_Order); }
      public Table_Panel(String File_Name,int Row_Color_Style,int Preffered_Width,String Delimiter,boolean In_Original_Order) { this(File_Name,false,Row_Color_Style,Preffered_Width,Delimiter,Default_Selection_Color,In_Original_Order); }
      public Table_Panel(String File_Name,boolean Show_External_Table,boolean In_Original_Order) { this(File_Name,Show_External_Table,Row_Color_Style,Preffered_Width,null,Default_Selection_Color,In_Original_Order); }
      public Table_Panel(String File_Name,boolean Show_External_Table,String Delimiter,boolean In_Original_Order) { this(File_Name,Show_External_Table,Row_Color_Style,Preffered_Width,Delimiter,Default_Selection_Color,In_Original_Order); }
      public Table_Panel(String File_Name,boolean Show_External_Table,int Row_Color_Style,int Preffered_Width,String Delimiter,Color Selection_Color,boolean In_Original_Order)
        String Table_Column_Names[],Column_Name_Line="";
        int Row_Count=0,Index=0;
        boolean Is_Child=false,Manage_Attachment=false;
        StringTokenizer ST;
        if (Delimiter==null) Delimiter=Default_Delimiter;
        if (new File(File_Name).exists())
          try
            String Line,Str=Tool_Lib.Read_File(File_Name).toString();
            ST=new StringTokenizer(Str,"\n");
            Line=ST.nextToken();
            Row_Count=ST.countTokens();
            Object[][] Table_Data=new Object[Row_Count][];
            if (Delimiter.equals(" ")) Line=Line.replaceAll(" {2,}"," ").trim();     // Replace multiple spaces with the delimiter space
            Table_Column_Names=Line.split(Delimiter);
            columnNames=Table_Column_Names;
            for (int i=0;i<Table_Column_Names.length;i++) Column_Name_Line+=Table_Column_Names[i]+"  ";
    //Out("Column_Name_Line [ "+Table_Column_Names.length+" ]="+Column_Name_Line);
            while (ST.hasMoreTokens())
              Line=ST.nextToken();
    //Out(Line);
              if (Delimiter.equals(" ")) Line=Line.replaceAll(" {2,}"," ").trim();   // Replace multiple spaces with the delimiter space
              if (Line.indexOf(Delimiter)!=-1) Table_Data[Index]=Line.split(Delimiter);
              else
                Table_Data[Index]=new Object[Table_Column_Names.length];
                Table_Data[Index][0]=Line;
                for (int i=1;i<Table_Column_Names.length;i++) Table_Data[Index]="";
    Index++;
    Line="";
    for (int i=0;i<Table_Data.length;i++)
    Line+="[ "+Table_Data[i].length+" ] ";
    for (int j=0;j<Table_Data[i].length;j++) Line+=Table_Data[i][j]+" ";
    Line+="\n";
    Out(Line);
    Table_Panel A_Table_Panel=new Table_Panel(File_Name,Table_Column_Names,Table_Data,Row_Count,Is_Child,Show_External_Table,Manage_Attachment,Row_Color_Style,Preffered_Width,Selection_Color,In_Original_Order);
    Table=A_Table_Panel.Table;
    scrollPane=A_Table_Panel.scrollPane;
    Column_Width=A_Table_Panel.Column_Width;
    data=A_Table_Panel.data;
    catch (Exception e) { e.printStackTrace(); }
    public void setPreferredSize(Dimension A_Dimension) { scrollPane.setPreferredSize(A_Dimension); }
    // This method picks good column sizes. If all column heads are wider than the column's cells' contents, then you can just use column.sizeWidthToFit().
    void initColumnSizes(JTable table,TableModel model)
    TableColumn column=null;
    Component comp=null;
    int headerWidth=0,cellWidth=0;
    Object[] longValues=(data.length>0)?data[0]:null;
    TableCellRenderer headerRenderer=table.getTableHeader().getDefaultRenderer();
    if (data.length<1) return;
    for (int i=0;i<model.getColumnCount();i++)
    column=table.getColumnModel().getColumn(i);
    comp=headerRenderer.getTableCellRendererComponent(null,column.getHeaderValue(),false,false,0,0);
    headerWidth=comp.getPreferredSize().width;
    comp=table.getDefaultRenderer(model.getColumnClass(i)).
    getTableCellRendererComponent(table,longValues[i],false,false,0,i);
    cellWidth=comp.getPreferredSize().width;
    switch (Preffered_Width)
    case Max_Header_Cell_Width : column.setPreferredWidth(Math.max(headerWidth,cellWidth));break;
    case Header_Width : column.setPreferredWidth(headerWidth);break;
    case Cell_Width : column.setPreferredWidth(cellWidth);break;
    Column_Width[i]=column.getPreferredWidth();
    if (Debug) Out("Initializing width of column "+i+". "+"headerWidth="+headerWidth+"; cellWidth="+cellWidth+" Column_Width["+i+"]="+Column_Width[i]);
    // Detects a state change in any of the Lists. Resets the variable corresponding to the selected item in a particular List. Invokes changeFont with the currently selected fontname, style and size attributes.
    public void itemStateChanged(ItemEvent e)
    Out(e.toString());
    if (e.getStateChange() != ItemEvent.SELECTED) return;
    Object list=e.getSource();
    public static void Out(String message) { System.out.println(message); }
    // Create the GUI and show it. For thread safety, this method should be invoked from the event-dispatching thread.
    static void Create_And_Show_GUI()
    boolean Demo_External_Table=true;
    // boolean Demo_External_Table=false;
    final Table_Panel demo;
    String[] columnNames={"First Names","Last Names","Sport","Num of Years","Vegetarian"};
    Object[][] data={{"Mary","Campione","Snowboarding"+"[123456789]",new Integer(5),new Boolean(false)},
    {"Alison","Huml","Rowing"+":123456789]",new Integer(3),new Boolean(true)},
    {"Frank","Ni","Running"+":123456789", new Integer(12), new Boolean(false)},
    {"Kathy","Walrath","Chasing toddlers"+"<123456789>", new Integer(2), new Boolean(false)},
    {"Mark", "Andrews","Speed reading",new Integer(20),new Boolean(true)},
    {"Angela","Lih","Teaching high school",new Integer(36),new Boolean(false)} };
    // Row_Color_Style=Row_Color_Style_Default;
    // Row_Color_Style=Row_Color_Style_None;
    // Row_Color_Style=Row_Color_Style_Blue_Gray;
    Row_Color_Style=Row_Color_Style_Cyan_Gray;
    // Row_Color_Style=Row_Color_Style_Blue;
    // Row_Color_Style=Row_Color_Style_Gray;
    // Row_Color_Style=Row_Color_Style_Red_Green;
    // Row_Color_Style=Row_Color_Style_Green_Yellow;
    // Row_Color_Style=Row_Color_Style_Red_Yellow;
    Preffered_Width=Max_Header_Cell_Width;
    if (Demo_External_Table) demo=new Table_Panel("External Table Demo",columnNames,data,data.length,false,Demo_External_Table,false,Row_Color_Style,Max_Header_Cell_Width,Default_Selection_Color,true);
    else
    JFrame Table_Frame=new JFrame("Internal Table Demo");
    // demo=new Table_Panel(Nm_Lib.Dir_A_Test+"ELX.csv",false,Row_Color_Style,Preffered_Width,null);
    // demo=new Table_Panel(Nm_Lib.Dir_Stock_Data+"ABV_Data.txt",false,Row_Color_Style,Preffered_Width," ");
    demo=new Table_Panel("C:/Dir_Stock_Data/EOP.txt",",",false);
    // demo=new Table_Panel(Nm_Lib.Dir_Stock_Data+"ABV_Data.txt"," ",false);
    Table_Frame.getContentPane().add(demo.scrollPane);
    Table_Frame.addWindowListener(new WindowAdapter()
    public void windowActivated(WindowEvent e) { }
    public void windowClosed(WindowEvent e) { }
    public void windowClosing(WindowEvent e) { System.exit(0); }
    public void windowDeactivated(WindowEvent e) { }
    public void windowDeiconified(WindowEvent e) { demo.repaint(); }
    public void windowGainedFocus(WindowEvent e) { demo.repaint(); }
    public void windowIconified(WindowEvent e) { }
    public void windowLostFocus(WindowEvent e) { }
    public void windowOpening(WindowEvent e) { demo.repaint(); }
    public void windowOpened(WindowEvent e) { }
    public void windowResized(WindowEvent e) { demo.repaint(); }
    public void windowStateChanged(WindowEvent e) { demo.repaint(); }
    Table_Frame.pack();
    Table_Frame.setBounds((Screen_Size.width-Table_Frame.getWidth())/2,(Screen_Size.height-Table_Frame.getHeight())/2,Table_Frame.getWidth(),Table_Frame.getHeight());
    Table_Frame.setVisible(true);
    public static void main(String[] args)
    // Schedule a job for the event-dispatching thread : creating and showing this application's GUI.
    SwingUtilities.invokeLater(new Runnable() { public void run() { Create_And_Show_GUI(); } });
    * TableSorter is a decorator for TableModels; adding sorting functionality to a supplied TableModel. TableSorter does not store
    * or copy the data in its TableModel; instead it maintains a map from the row indexes of the view to the row indexes of the
    * model. As requests are made of the sorter (like getValueAt(row, col)) they are passed to the underlying model after the row numbers
    * have been translated via the internal mapping array. This way, the TableSorter appears to hold another copy of the table
    * with the rows in a different order.
    * <p/>
    * TableSorter registers itself as a listener to the underlying model, just as the JTable itself would. Events recieved from the model
    * are examined, sometimes manipulated (typically widened), and then passed on to the TableSorter's listeners (typically the JTable).
    * If a change to the model has invalidated the order of TableSorter's rows, a note of this is made and the sorter will resort the
    * rows the next time a value is requested.
    * <p/>
    * When the tableHeader property is set, either by using the setTableHeader() method or the two argument constructor, the table
    * header may be used as a complete UI for TableSorter. The default renderer of the tableHeader is decorated with a renderer
    * that indicates the sorting status of each column. In addition, a mouse listener is installed with the following behavior:
    * <ul>
    * <li>
    * Mouse-click: Clears the sorting status of all other columns and advances the sorting status of that column through three
    * values: {NOT_SORTED, ASCENDING, DESCENDING} (then back to NOT_SORTED again).
    * <li>
    * SHIFT-mouse-click: Clears the sorting status of all other columns and cycles the sorting status of the column through the same
    * three values, in the opposite order: {NOT_SORTED, DESCENDING, ASCENDING}.
    * <li>
    * CONTROL-mouse-click and CONTROL-SHIFT-mouse-click: as above except that the changes to the column do not cancel the statuses of columns
    * that are already sorting - giving a way to initiate a compound sort.
    * </ul>
    * <p/>
    * This is a long overdue rewrite of a class of the same name that first appeared in the swing table demos in 1997.
    * @author Philip Milne
    * @author Brendon McLean
    * @author Dan van Enckevort
    * @author Parwinder Sekhon
    * @version 2.0 02/27/04
    class TableSorter extends AbstractTableModel
    public static final long serialVersionUID=26362862L;
    protected TableModel tableModel;
    public static final int DESCENDING = -1;
    public static final int NOT_SORTED = 0;
    public static final int ASCENDING = 1;
    private static Directive EMPTY_DIRECTIVE = new Directive(-1, NOT_SORTED);
    public static final Comparator COMPARABLE_COMAPRATOR = new Comparator() { public int compare(Object o1, Object o2) { return ((Comparable) o1).compareTo(o2); } };
    public static final Comparator LEXICAL_COMPARATOR = new Comparator() { public int compare(Object o1, Object o2) { return o1.toString().compareTo(o2.toString()); } };
    private Row[] viewToModel;
    private int[] modelToView;
    private JTableHeader tableHeader;
    private MouseListener mouseListener;
    private TableModelListener tableModelListener;
    private Map<Class,Comparator> columnComparators = new HashMap<Class,Comparator>();
    private List<Directive> sortingColumns = new ArrayList<Directive>();
    public TableSorter()
    this.mouseListener = new MouseHandler();
    this.tableModelListener = new TableModelHandler();
    public TableSorter(TableModel tableModel)
    this();
    setTableModel(tableModel);
    public TableSorter(TableModel tableModel, JTableHeader tableHeader)
    this();
    setTableHeader(tableHeader);
    setTableModel(tableModel);
    private void clearSortingState()
    viewToModel = null;
    modelToView = null;
    public TableModel getTableModel() { return tableModel; }
    public void setTableModel(TableModel tableModel)
    if (this.tableModel != null) { this.tableModel.removeTableModelListener(tableModelListener); }
    this.tableModel = tableModel;
    if (this.tableModel != null) { this.tableModel.addTableModelListener(tableModelListener); }
    clearSortingState();
    fireTableStructureChanged();
    public JTableHeader getTableHeader() { return tableHeader; }
    public void setTableHeader(JTableHeader tableHeader)
    if (this.tableHeader != null)
    this.tableHeader.removeMouseListener(mouseListener);
    TableCellRenderer defaultRenderer = this.tableHeader.getDefaultRenderer();
    if (defaultRenderer instanceof SortableHeaderRenderer) this.tableHeader.setDefaultRenderer(((SortableHeaderRenderer) defaultRenderer).tableCellRenderer);
    this.tableHeader = tableHeader;
    if (this.tableHeader != null)
    this.tableHeader.addMouseListener(mouseListener);
    this.tableHeader.setDefaultRenderer(
    new SortableHeaderRenderer(this.tableHeader.getDefaultRenderer()));
    public boolean isSorting() { return sortingColumns.size() != 0; }
    private Directive getDirective(int column)
    for (int i = 0; i < sortingColumns.size(); i++)
    Directive directive = (Directive)sortingColumns.get(i);
    if (directive.column == column) { return directive; }
    return EMPTY_DIRECTIVE;
    public int getSortingStatus(int column) { return getDirective(column).direction; }
    private void sortingStatusChanged()
    clearSortingState();
    fireTableDataChanged();
    if (tableHeader != null) { tableHeader.repaint(); }
    public void setSortingStatus(int column, int status)
    Directive directive = getDirective(column);
    if (directive != EMPTY_DIRECTIVE) { sortingColumns.remove(directive); }
    if (status != NOT_SORTED) { sortingColumns.add(new Directive(column, status)); }
    sortingStatusChanged();
    protected Icon getHeaderRendererIcon(int column, int size)
    Directive directive = getDirective(column);
    if (directive == EMPTY_DIRECTIVE) { return null; }
    return new Arrow(directive.direction == DESCENDING, size, sortingColumns.indexOf(directive));
    private void cancelSorting()
    sortingColumns.clear();
    sortingStatusChanged();
    public void setColumnComparator(Class type, Comparator comparator)
    if (comparator == null) { columnComparators.remove(type); }
    else { columnComparators.put(type, comparator); }
    protected Comparator getComparator(int column)
    Class columnType = tableModel.getColumnClass(column);
    Comparator comparator = (Comparator) columnComparators.get(columnType);
    if (comparator != null) { return comparator; }
    if (Comparable.class.isAssignableFrom(columnType)) { return COMPARABLE_COMAPRATOR; }
    return LEXICAL_COMPARATOR;
    private Row[] getViewToModel()
    if (viewToModel == null)
    int tableModelRowCount = tableModel.getRowCount();
    viewToModel = new Row[tableModelRowCount];
    for (int row = 0; row < tableModelRowCount; row++) { viewToModel[row] = new Row(row); }
    if (isSorting()) { Arrays.sort(viewToModel); }
    return viewToModel;
    public int modelIndex(int viewIndex) { return getViewToModel()[viewIndex].modelIndex; }
    private int[] getModelToView()
    if (modelToView == null)
    int n = getViewToModel().length;
    modelToView = new int[n];
    for (int i = 0; i < n; i++) { modelToView[modelIndex(i)] = i; }
    return modelToView;
    // TableModel interface methods
    public int getRowCount() { return (tableModel == null) ? 0 : tableModel.getRowCount(); }
    public int getColumnCount() { return (tableModel == null) ? 0 : tableModel.getColumnCount(); }
    public String getColumnName(int column) { return tableModel.getColumnName(column); }
    public Class getColumnClass(int column) { return tableModel.getColumnClass(column); }
    public boolean isCellEditable(int row, int column) { return tableModel.isCellEditable(modelIndex(row), column); }
    public Object getValueAt(int row, int column) { return tableModel.getValueAt(modelIndex(row), column); }
    public void setValueAt(Object aValue, int row, int column) { tableModel.setValueAt(aValue, modelIndex(row), column); }
    // Helper classes
    private class Row implements Comparable
    private int modelIndex;
    public Row(int index) { this.modelIndex = index; }
    public int compareTo(Object o)
    int row1 = modelIndex;
    int row2 = ((Row) o).modelIndex;
    for (Iterator it = sortingColumns.iterator(); it.hasNext();)
    Directive directive = (Directive) it.next();
    int column = directive.column;
    Object o1 = tableModel.getValueAt(row1, column);
    Object o2 = tableModel.getValueAt(row2, column);
    int comparison = 0;
    // Define null less than everything, except null.

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import java.util.List;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    public class Table_Panel extends JPanel implements ItemListener
      public static final long serialVersionUID=26362862L;
      static final int Row_Color_Style_Default=-1,Row_Color_Style_None=0,Row_Color_Style_Blue_Gray=1,Row_Color_Style_Cyan_Gray=2,Row_Color_Style_Blue=3,
                       Row_Color_Style_Gray=4,Row_Color_Style_Red_Green=5,Row_Color_Style_Green_Yellow=6,Row_Color_Style_Red_Yellow=7,
                       Max_Header_Cell_Width=0,Header_Width=1,Cell_Width=2;
      static int Row_Color_Style=Row_Color_Style_Cyan_Gray,Preffered_Width=Header_Width;
    //  static int Row_Color_Style=Row_Color_Style_None,Preffered_Width=Header_Width;
    //boolean        Debug=true,
      boolean        Debug=false,
    //               Use_Row_Colors=true,
                     Use_Row_Colors=false;
      JFrame Table_Frame;
      TableModel My_Model;
      JScrollPane scrollPane=new JScrollPane();
      public JTable Table;
      static String columnNames[],Default_Delimiter=",";
      Object[][] data;
      static Dimension Screen_Size=Toolkit.getDefaultToolkit().getScreenSize();
      int Column_Width[];
      static Color Default_Selection_Color=new Color(250,135,200);
      Color Selection_Color=Default_Selection_Color;
      public Table_Panel(ResultSet RS,String Table_Name,boolean Show_External_Table,int Row_Color_Style,int Preffered_Width,boolean In_Original_Order)
        String Value,Table_Column_Names[]=null;
        Object[][] Table_Data=null;
        int Row_Count,Index=0;
        try
          if (RS==null) return;
          else
            RS.last();
            Row_Count=RS.getRow();
            RS.beforeFirst();
          ResultSetMetaData rsmd=RS.getMetaData();
          int Column_Count=rsmd.getColumnCount();
          Table_Column_Names=new String[Column_Count];
          Table_Data=new Object[Row_Count][Column_Count];
          for (int i=1;i<=Column_Count;i++) Table_Column_Names[i-1]=rsmd.getColumnLabel(i);            // Get column names
    //Out("Row_Count="+Row_Count+"  Column_Count="+Column_Count);
          while (RS.next())                                                                            // Get all rows
            for (int i=1;i<=Column_Count;i++)
              Value=RS.getString(i);
              Table_Data[Index][i-1]=(Value==null)?"null":Value;
            Index++;
    //      if (Test_Ct++>300) break;
        catch (Exception e) { e.printStackTrace(); }
        scrollPane=new Table_Panel(Table_Name,Table_Column_Names,Table_Data,Table_Data.length,false,Show_External_Table,false,Row_Color_Style,Preffered_Width,Selection_Color,In_Original_Order).scrollPane;
      public Table_Panel(String[] Table_Column_Names,Object[][] Table_Data,Color Selection_Color,boolean In_Original_Order)
        this("",Table_Column_Names,Table_Data,Table_Data.length,false,false,false,Row_Color_Style,Preffered_Width,Selection_Color,In_Original_Order);
      public Table_Panel(String Table_Name,String[] Table_Column_Names,Object[][] Table_Data,boolean Show_External_Table,Color Selection_Color,boolean In_Original_Order)
        this(Table_Name,Table_Column_Names,Table_Data,Table_Data.length,false,Show_External_Table,false,Row_Color_Style,Preffered_Width,Selection_Color,In_Original_Order);
      public Table_Panel(String Table_Name,String[] Table_Column_Names,Object[][] Table_Data,int Row_Count,boolean Is_Child,boolean Show_External_Table,boolean Manage_Attachment,int Row_Color_Style,int Preffered_Width,Color Selection_Color,boolean In_Original_Order)
        columnNames=Table_Column_Names;
        if (In_Original_Order) data=Table_Data;
        else
          data=new Object[Table_Data.length][columnNames.length];
          for (int row=0;row<Table_Data.length;row++)
            data[row]=new Object[columnNames.length];
            for (int Column=0;Column<Table_Data[row].length;Column++) data[row][Column]=Table_Data[Table_Data.length-1-row][Column];
        Column_Width=new int[columnNames.length];
        this.Row_Color_Style=Row_Color_Style;
        Use_Row_Colors=(Row_Color_Style!=Row_Color_Style_None);
        this.Preffered_Width=Preffered_Width;
        if (Selection_Color!=null) this.Selection_Color=Selection_Color;
    //    Out("this.Selection_Color="+this.Selection_Color);
    //    TableModel My_Model=new DefaultTableModel(Table_Data,columnNames)
        TableModel My_Model=new DefaultTableModel(data,columnNames)
          public int getColumnCount() { return columnNames.length; }
          public int getRowCount() { return data.length; }
          public String getColumnName(int col) { return columnNames[col]; }
          public Object getValueAt(int row,int col)
    //      Out(row+","+col+"["+data[row][col]+"]   data.length="+data.length+"  data[0].length="+data[0].length);
            return (data[row][col]==null)?"":((data[row][col] instanceof Boolean)?data[row][col]:data[row][col].toString()); // Non-boolean values will have bgcolor
          public Class getColumnClass(int column)
            Class returnValue;
            if ((column>=0) && (column<getColumnCount())) returnValue=getValueAt(0,column).getClass();
            else returnValue=Object.class;
            return returnValue;
        // JTable uses this method to determine the default renderer/editor for each cell. If we didn't implement this method, then the last column would contain text ("true"/"false"), rather than a check box.
    //    public Class getColumnClass(int c) { return getValueAt(0,c).getClass(); }
          // Don't need to implement this method unless your table's editable.
          public boolean isCellEditable(int row,int col)
            //Note that the data/cell address is constant, no matter where the cell appears onscreen.
            if (col<0) return false;
            else return true;
          // Don't need to implement this method unless your table's data can change.
          public void setValueAt(Object value,int row,int col)
            String Execution_Dir=getClass().getProtectionDomain().getCodeSource().getLocation().toString();
            if (Debug) System.out.println("Execution_Dir="+Execution_Dir+"\nLast_Value="+Table_Grid_Cell_Renderer.Last_Value+"  Setting value at [ "+row+","+col+" ] to "+value+" (an instance of "+value.getClass()+")");
            if (Execution_Dir.toLowerCase().indexOf("c:/")!=-1 || value.getClass()==Boolean.class || !Use_Row_Colors) data[row][col]=value;
    //     else data[row][col]=(Table_Grid_CellRenderer.Last_Value==null)?value:value.toString().substring(Table_Grid_CellRenderer.Last_Value.toString().length());
            fireTableCellUpdated(row,col);
            if (Debug)
              System.out.println("New value of data :");
              printDebugData();
          private void printDebugData()
            int numRows=getRowCount();
            int numCols=getColumnCount();
            for (int i=0;i<numRows;i++)
              System.out.print("    row "+i+":");
              for (int j=0;j<numCols;j++) System.out.print("  "+data[i][j]);
              System.out.println();
            System.out.println("--------------------------------------------------------------------------");
        TableSorter sorter=new TableSorter(My_Model);
        Table=new JTable(sorter)
    //    Table=new JTable(My_Model)
          public static final long serialVersionUID=26362862L;
          public String getToolTipText(MouseEvent e)           // Implement table cell tool tips.
            Object Cell_Tip;
            String tip=null;
            java.awt.Point p=e.getPoint();
            int rowIndex=rowAtPoint(p);
            int colIndex=columnAtPoint(p);
            int realColumnIndex=convertColumnIndexToModel(colIndex);
            Cell_Tip=getValueAt(rowIndex,colIndex);
    //        if (realColumnIndex == 2)                         //Sport column
              tip=Cell_Tip.toString();
            else if (realColumnIndex == 4)                      //Veggie column
              TableModel model=getModel();
              String firstName=(String)model.getValueAt(rowIndex,0);
              String lastName=(String)model.getValueAt(rowIndex,1);
              Boolean veggie=(Boolean)model.getValueAt(rowIndex,4);
              if (Boolean.TRUE.equals(veggie)) tip=firstName+" "+lastName+" is a vegetarian";
              else tip=firstName+" "+lastName+" is not a vegetarian";
            else
              // You can omit this part if you know you don't have any renderers that supply their own tool tips.
              tip=super.getToolTipText(e);
            return tip;
    //    RowSorter<TableModel> sorter=new TableRowSorter<TableModel>(My_Model);
    //    Table.setRowSorter(sorter);
        Table.setSelectionBackground(this.Selection_Color);
        int Table_Height=Table.getRowHeight()*Row_Count;
        // sorter.addMouseListenerToHeaderInTable(Table);      // ADDED THIS
        sorter.setTableHeader(Table.getTableHeader());
        if (Table_Column_Names.length>20) Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        if (Manage_Attachment) Table.setPreferredScrollableViewportSize(new Dimension(500,(Table_Height>850)?850:Table_Height));
        else Table.setPreferredScrollableViewportSize(new Dimension(1000,(Table_Height>850)?850:Table_Height));
        if (Use_Row_Colors) Table.setDefaultRenderer(Object.class,new Table_Grid_Cell_Renderer());
        //Create the scroll pane and add the table to it.
        scrollPane=new JScrollPane(Table);
        //Set up column sizes.
        initColumnSizes(Table,My_Model);
        //Add the scroll pane to this window.
        if (Show_External_Table)
          Table_Frame=new JFrame(Table_Name);
          Table_Frame.getContentPane().add(scrollPane);
          Table_Frame.addWindowListener(new WindowAdapter()
            public void windowActivated(WindowEvent e) { }
            public void windowClosed(WindowEvent e) { }
            public void windowClosing(WindowEvent e)  { System.exit(0); }
            public void windowDeactivated(WindowEvent e)  { }
            public void windowDeiconified(WindowEvent e)  { scrollPane.repaint(); }
            public void windowGainedFocus(WindowEvent e)  { scrollPane.repaint(); }
            public void windowIconified(WindowEvent e)  { }
            public void windowLostFocus(WindowEvent e)  { }
            public void windowOpening(WindowEvent e) { scrollPane.repaint(); }
            public void windowOpened(WindowEvent e)  { }
            public void windowResized(WindowEvent e) { scrollPane.repaint(); } 
            public void windowStateChanged(WindowEvent e) { scrollPane.repaint(); }
          Table_Frame.pack();
          Table_Frame.setBounds((Screen_Size.width-Table_Frame.getWidth())/2,(Screen_Size.height-Table_Frame.getHeight())/2,Table_Frame.getWidth(),Table_Frame.getHeight());
          Table_Frame.setVisible(true);
          if (Is_Child) Table_Frame.addComponentListener(new ComponentAdapter() { public void componentClosing(ComponentEvent e) { System.exit(0); } });
        else add(scrollPane);
      public Table_Panel(String File_Name) { this(File_Name,false,Row_Color_Style_Cyan_Gray,Preffered_Width,null,Default_Selection_Color,true); }
      public Table_Panel(String File_Name,int Row_Color_Style,boolean In_Original_Order) { this(File_Name,false,Row_Color_Style,Preffered_Width,null,Default_Selection_Color,In_Original_Order); }
      public Table_Panel(String File_Name,String Delimiter,boolean In_Original_Order) { this(File_Name,false,Row_Color_Style_Cyan_Gray,Preffered_Width,Delimiter,Default_Selection_Color,In_Original_Order); }
      public Table_Panel(String File_Name,int Preffered_Width,String Delimiter,boolean In_Original_Order) { this(File_Name,false,Row_Color_Style,Preffered_Width,Delimiter,Default_Selection_Color,In_Original_Order); }
      public Table_Panel(String File_Name,int Row_Color_Style,int Preffered_Width,String Delimiter,boolean In_Original_Order) { this(File_Name,false,Row_Color_Style,Preffered_Width,Delimiter,Default_Selection_Color,In_Original_Order); }
      public Table_Panel(String File_Name,boolean Show_External_Table,boolean In_Original_Order) { this(File_Name,Show_External_Table,Row_Color_Style,Preffered_Width,null,Default_Selection_Color,In_Original_Order); }
      public Table_Panel(String File_Name,boolean Show_External_Table,String Delimiter,boolean In_Original_Order) { this(File_Name,Show_External_Table,Row_Color_Style,Preffered_Width,Delimiter,Default_Selection_Color,In_Original_Order); }
      public Table_Panel(String File_Name,boolean Show_External_Table,int Row_Color_Style,int Preffered_Width,String Delimiter,Color Selection_Color,boolean In_Original_Order)
        String Table_Column_Names[],Column_Name_Line="";
        int Row_Count=0,Index=0;
        boolean Is_Child=false,Manage_Attachment=false;
        StringTokenizer ST;
        if (Delimiter==null) Delimiter=Default_Delimiter;
        if (new File(File_Name).exists())
          try
            String Line,Str=Tool_Lib.Read_File(File_Name).toString();
            ST=new StringTokenizer(Str,"\n");
            Line=ST.nextToken();
            Row_Count=ST.countTokens();
            Object[][] Table_Data=new Object[Row_Count][];
            if (Delimiter.equals(" ")) Line=Line.replaceAll(" {2,}"," ").trim();     // Replace multiple spaces with the delimiter space
            Table_Column_Names=Line.split(Delimiter);
            columnNames=Table_Column_Names;
            for (int i=0;i<Table_Column_Names.length;i++) Column_Name_Line+=Table_Column_Names[i]+"  ";
    //Out("Column_Name_Line [ "+Table_Column_Names.length+" ]="+Column_Name_Line);
            while (ST.hasMoreTokens())
              Line=ST.nextToken();
    //Out(Line);
              if (Delimiter.equals(" ")) Line=Line.replaceAll(" {2,}"," ").trim();   // Replace multiple spaces with the delimiter space
              if (Line.indexOf(Delimiter)!=-1) Table_Data[Index]=Line.split(Delimiter);
              else
                Table_Data[Index]=new Object[Table_Column_Names.length];
                Table_Data[Index][0]=Line;
                for (int i=1;i<Table_Column_Names.length;i++) Table_Data[Index]="";
    Index++;
    Line="";
    for (int i=0;i<Table_Data.length;i++)
    Line+="[ "+Table_Data[i].length+" ] ";
    for (int j=0;j<Table_Data[i].length;j++) Line+=Table_Data[i][j]+" ";
    Line+="\n";
    Out(Line);
    Table_Panel A_Table_Panel=new Table_Panel(File_Name,Table_Column_Names,Table_Data,Row_Count,Is_Child,Show_External_Table,Manage_Attachment,Row_Color_Style,Preffered_Width,Selection_Color,In_Original_Order);
    Table=A_Table_Panel.Table;
    scrollPane=A_Table_Panel.scrollPane;
    Column_Width=A_Table_Panel.Column_Width;
    data=A_Table_Panel.data;
    catch (Exception e) { e.printStackTrace(); }
    public void setPreferredSize(Dimension A_Dimension) { scrollPane.setPreferredSize(A_Dimension); }
    // This method picks good column sizes. If all column heads are wider than the column's cells' contents, then you can just use column.sizeWidthToFit().
    void initColumnSizes(JTable table,TableModel model)
    TableColumn column=null;
    Component comp=null;
    int headerWidth=0,cellWidth=0;
    Object[] longValues=(data.length>0)?data[0]:null;
    TableCellRenderer headerRenderer=table.getTableHeader().getDefaultRenderer();
    if (data.length<1) return;
    for (int i=0;i<model.getColumnCount();i++)
    column=table.getColumnModel().getColumn(i);
    comp=headerRenderer.getTableCellRendererComponent(null,column.getHeaderValue(),false,false,0,0);
    headerWidth=comp.getPreferredSize().width;
    comp=table.getDefaultRenderer(model.getColumnClass(i)).
    getTableCellRendererComponent(table,longValues[i],false,false,0,i);
    cellWidth=comp.getPreferredSize().width;
    switch (Preffered_Width)
    case Max_Header_Cell_Width : column.setPreferredWidth(Math.max(headerWidth,cellWidth));break;
    case Header_Width : column.setPreferredWidth(headerWidth);break;
    case Cell_Width : column.setPreferredWidth(cellWidth);break;
    Column_Width[i]=column.getPreferredWidth();
    if (Debug) Out("Initializing width of column "+i+". "+"headerWidth="+headerWidth+"; cellWidth="+cellWidth+" Column_Width["+i+"]="+Column_Width[i]);
    // Detects a state change in any of the Lists. Resets the variable corresponding to the selected item in a particular List. Invokes changeFont with the currently selected fontname, style and size attributes.
    public void itemStateChanged(ItemEvent e)
    Out(e.toString());
    if (e.getStateChange() != ItemEvent.SELECTED) return;
    Object list=e.getSource();
    public static void Out(String message) { System.out.println(message); }
    // Create the GUI and show it. For thread safety, this method should be invoked from the event-dispatching thread.
    static void Create_And_Show_GUI()
    boolean Demo_External_Table=true;
    // boolean Demo_External_Table=false;
    final Table_Panel demo;
    String[] columnNames={"First Names","Last Names","Sport","Num of Years","Vegetarian"};
    Object[][] data={{"Mary","Campione","Snowboarding"+"[123456789]",new Integer(5),new Boolean(false)},
    {"Alison","Huml","Rowing"+":123456789]",new Integer(3),new Boolean(true)},
    {"Frank","Ni","Running"+":123456789", new Integer(12), new Boolean(false)},
    {"Kathy","Walrath","Chasing toddlers"+"<123456789>", new Integer(2), new Boolean(false)},
    {"Mark", "Andrews","Speed reading",new Integer(20),new Boolean(true)},
    {"Angela","Lih","Teaching high school",new Integer(36),new Boolean(false)} };
    // Row_Color_Style=Row_Color_Style_Default;
    // Row_Color_Style=Row_Color_Style_None;
    // Row_Color_Style=Row_Color_Style_Blue_Gray;
    Row_Color_Style=Row_Color_Style_Cyan_Gray;
    // Row_Color_Style=Row_Color_Style_Blue;
    // Row_Color_Style=Row_Color_Style_Gray;
    // Row_Color_Style=Row_Color_Style_Red_Green;
    // Row_Color_Style=Row_Color_Style_Green_Yellow;
    // Row_Color_Style=Row_Color_Style_Red_Yellow;
    Preffered_Width=Max_Header_Cell_Width;
    if (Demo_External_Table) demo=new Table_Panel("External Table Demo",columnNames,data,data.length,false,Demo_External_Table,false,Row_Color_Style,Max_Header_Cell_Width,Default_Selection_Color,true);
    else
    JFrame Table_Frame=new JFrame("Internal Table Demo");
    // demo=new Table_Panel(Nm_Lib.Dir_A_Test+"ELX.csv",false,Row_Color_Style,Preffered_Width,null);
    // demo=new Table_Panel(Nm_Lib.Dir_Stock_Data+"ABV_Data.txt",false,Row_Color_Style,Preffered_Width," ");
    demo=new Table_Panel("C:/Dir_Stock_Data/EOP.txt",",",false);
    // demo=new Table_Panel(Nm_Lib.Dir_Stock_Data+"ABV_Data.txt"," ",false);
    Table_Frame.getContentPane().add(demo.scrollPane);
    Table_Frame.addWindowListener(new WindowAdapter()
    public void windowActivated(WindowEvent e) { }
    public void windowClosed(WindowEvent e) { }
    public void windowClosing(WindowEvent e) { System.exit(0); }
    public void windowDeactivated(WindowEvent e) { }
    public void windowDeiconified(WindowEvent e) { demo.repaint(); }
    public void windowGainedFocus(WindowEvent e) { demo.repaint(); }
    public void windowIconified(WindowEvent e) { }
    public void windowLostFocus(WindowEvent e) { }
    public void windowOpening(WindowEvent e) { demo.repaint(); }
    public void windowOpened(WindowEvent e) { }
    public void windowResized(WindowEvent e) { demo.repaint(); }
    public void windowStateChanged(WindowEvent e) { demo.repaint(); }
    Table_Frame.pack();
    Table_Frame.setBounds((Screen_Size.width-Table_Frame.getWidth())/2,(Screen_Size.height-Table_Frame.getHeight())/2,Table_Frame.getWidth(),Table_Frame.getHeight());
    Table_Frame.setVisible(true);
    public static void main(String[] args)
    // Schedule a job for the event-dispatching thread : creating and showing this application's GUI.
    SwingUtilities.invokeLater(new Runnable() { public void run() { Create_And_Show_GUI(); } });
    * TableSorter is a decorator for TableModels; adding sorting functionality to a supplied TableModel. TableSorter does not store
    * or copy the data in its TableModel; instead it maintains a map from the row indexes of the view to the row indexes of the
    * model. As requests are made of the sorter (like getValueAt(row, col)) they are passed to the underlying model after the row numbers
    * have been translated via the internal mapping array. This way, the TableSorter appears to hold another copy of the table
    * with the rows in a different order.
    * <p/>
    * TableSorter registers itself as a listener to the underlying model, just as the JTable itself would. Events recieved from the model
    * are examined, sometimes manipulated (typically widened), and then passed on to the TableSorter's listeners (typically the JTable).
    * If a change to the model has invalidated the order of TableSorter's rows, a note of this is made and the sorter will resort the
    * rows the next time a value is requested.
    * <p/>
    * When the tableHeader property is set, either by using the setTableHeader() method or the two argument constructor, the table
    * header may be used as a complete UI for TableSorter. The default renderer of the tableHeader is decorated with a renderer
    * that indicates the sorting status of each column. In addition, a mouse listener is installed with the following behavior:
    * <ul>
    * <li>
    * Mouse-click: Clears the sorting status of all other columns and advances the sorting status of that column through three
    * values: {NOT_SORTED, ASCENDING, DESCENDING} (then back to NOT_SORTED again).
    * <li>
    * SHIFT-mouse-click: Clears the sorting status of all other columns and cycles the sorting status of the column through the same
    * three values, in the opposite order: {NOT_SORTED, DESCENDING, ASCENDING}.
    * <li>
    * CONTROL-mouse-click and CONTROL-SHIFT-mouse-click: as above except that the changes to the column do not cancel the statuses of columns
    * that are already sorting - giving a way to initiate a compound sort.
    * </ul>
    * <p/>
    * This is a long overdue rewrite of a class of the same name that first appeared in the swing table demos in 1997.
    * @author Philip Milne
    * @author Brendon McLean
    * @author Dan van Enckevort
    * @author Parwinder Sekhon
    * @version 2.0 02/27/04
    class TableSorter extends AbstractTableModel
    public static final long serialVersionUID=26362862L;
    protected TableModel tableModel;
    public static final int DESCENDING = -1;
    public static final int NOT_SORTED = 0;
    public static final int ASCENDING = 1;
    private static Directive EMPTY_DIRECTIVE = new Directive(-1, NOT_SORTED);
    public static final Comparator COMPARABLE_COMAPRATOR = new Comparator() { public int compare(Object o1, Object o2) { return ((Comparable) o1).compareTo(o2); } };
    public static final Comparator LEXICAL_COMPARATOR = new Comparator() { public int compare(Object o1, Object o2) { return o1.toString().compareTo(o2.toString()); } };
    private Row[] viewToModel;
    private int[] modelToView;
    private JTableHeader tableHeader;
    private MouseListener mouseListener;
    private TableModelListener tableModelListener;
    private Map<Class,Comparator> columnComparators = new HashMap<Class,Comparator>();
    private List<Directive> sortingColumns = new ArrayList<Directive>();
    public TableSorter()
    this.mouseListener = new MouseHandler();
    this.tableModelListener = new TableModelHandler();
    public TableSorter(TableModel tableModel)
    this();
    setTableModel(tableModel);
    public TableSorter(TableModel tableModel, JTableHeader tableHeader)
    this();
    setTableHeader(tableHeader);
    setTableModel(tableModel);
    private void clearSortingState()
    viewToModel = null;
    modelToView = null;
    public TableModel getTableModel() { return tableModel; }
    public void setTableModel(TableModel tableModel)
    if (this.tableModel != null) { this.tableModel.removeTableModelListener(tableModelListener); }
    this.tableModel = tableModel;
    if (this.tableModel != null) { this.tableModel.addTableModelListener(tableModelListener); }
    clearSortingState();
    fireTableStructureChanged();
    public JTableHeader getTableHeader() { return tableHeader; }
    public void setTableHeader(JTableHeader tableHeader)
    if (this.tableHeader != null)
    this.tableHeader.removeMouseListener(mouseListener);
    TableCellRenderer defaultRenderer = this.tableHeader.getDefaultRenderer();
    if (defaultRenderer instanceof SortableHeaderRenderer) this.tableHeader.setDefaultRenderer(((SortableHeaderRenderer) defaultRenderer).tableCellRenderer);
    this.tableHeader = tableHeader;
    if (this.tableHeader != null)
    this.tableHeader.addMouseListener(mouseListener);
    this.tableHeader.setDefaultRenderer(
    new SortableHeaderRenderer(this.tableHeader.getDefaultRenderer()));
    public boolean isSorting() { return sortingColumns.size() != 0; }
    private Directive getDirective(int column)
    for (int i = 0; i < sortingColumns.size(); i++)
    Directive directive = (Directive)sortingColumns.get(i);
    if (directive.column == column) { return directive; }
    return EMPTY_DIRECTIVE;
    public int getSortingStatus(int column) { return getDirective(column).direction; }
    private void sortingStatusChanged()
    clearSortingState();
    fireTableDataChanged();
    if (tableHeader != null) { tableHeader.repaint(); }
    public void setSortingStatus(int column, int status)
    Directive directive = getDirective(column);
    if (directive != EMPTY_DIRECTIVE) { sortingColumns.remove(directive); }
    if (status != NOT_SORTED) { sortingColumns.add(new Directive(column, status)); }
    sortingStatusChanged();
    protected Icon getHeaderRendererIcon(int column, int size)
    Directive directive = getDirective(column);
    if (directive == EMPTY_DIRECTIVE) { return null; }
    return new Arrow(directive.direction == DESCENDING, size, sortingColumns.indexOf(directive));
    private void cancelSorting()
    sortingColumns.clear();
    sortingStatusChanged();
    public void setColumnComparator(Class type, Comparator comparator)
    if (comparator == null) { columnComparators.remove(type); }
    else { columnComparators.put(type, comparator); }
    protected Comparator getComparator(int column)
    Class columnType = tableModel.getColumnClass(column);
    Comparator comparator = (Comparator) columnComparators.get(columnType);
    if (comparator != null) { return comparator; }
    if (Comparable.class.isAssignableFrom(columnType)) { return COMPARABLE_COMAPRATOR; }
    return LEXICAL_COMPARATOR;
    private Row[] getViewToModel()
    if (viewToModel == null)
    int tableModelRowCount = tableModel.getRowCount();
    viewToModel = new Row[tableModelRowCount];
    for (int row = 0; row < tableModelRowCount; row++) { viewToModel[row] = new Row(row); }
    if (isSorting()) { Arrays.sort(viewToModel); }
    return viewToModel;
    public int modelIndex(int viewIndex) { return getViewToModel()[viewIndex].modelIndex; }
    private int[] getModelToView()
    if (modelToView == null)
    int n = getViewToModel().length;
    modelToView = new int[n];
    for (int i = 0; i < n; i++) { modelToView[modelIndex(i)] = i; }
    return modelToView;
    // TableModel interface methods
    public int getRowCount() { return (tableModel == null) ? 0 : tableModel.getRowCount(); }
    public int getColumnCount() { return (tableModel == null) ? 0 : tableModel.getColumnCount(); }
    public String getColumnName(int column) { return tableModel.getColumnName(column); }
    public Class getColumnClass(int column) { return tableModel.getColumnClass(column); }
    public boolean isCellEditable(int row, int column) { return tableModel.isCellEditable(modelIndex(row), column); }
    public Object getValueAt(int row, int column) { return tableModel.getValueAt(modelIndex(row), column); }
    public void setValueAt(Object aValue, int row, int column) { tableModel.setValueAt(aValue, modelIndex(row), column); }
    // Helper classes
    private class Row implements Comparable
    private int modelIndex;
    public Row(int index) { this.modelIndex = index; }
    public int compareTo(Object o)
    int row1 = modelIndex;
    int row2 = ((Row) o).modelIndex;
    for (Iterator it = sortingColumns.iterator(); it.hasNext();)
    Directive directive = (Directive) it.next();
    int column = directive.column;
    Object o1 = tableModel.getValueAt(row1, column);
    Object o2 = tableModel.getValueAt(row2, column);
    int comparison = 0;
    // Define null less than everything, except null.
    if (o1 == null && o2 == null) { comparison = 0; }
    else if (o1 == null) { comparison = -1; }
    else if (o2 == null) { comparison = 1; }
    else { comparison = getComparator(column).compare(o1, o2); }
    if (comparison != 0) { return directive.direction == DESCENDING ? -comparison : comparison; }
    return 0;
    private class TableModelHandler implements TableModelListener
    public void tableChanged(TableModelEvent e)
    // If we're not sorting by anything

  • Migration of ADF table selection code to Trinidad code problem with RowKeySet

    we found a conversion problem as described below in one of the java files related to Manual UI.
        public void setPsdTable(CoreTable psdTable) {
            this.psdTable = psdTable;
            if (globalBean.isResetCreateRequestPsdQuarters()){
       ADF -code         this.psdTable.setSelectionState(new RowKeySet());
       Trinidad code     this.psdTable.setSelectedRowKeys(new RowKeySet());
                globalBean.setResetCreateRequestPsdQuarters(false);
    In Trinidad RowKeySet is abstract class whereas in ADF the same is normal class. Hence I found the below error message.
    Error(364,45): org.apache.myfaces.trinidad.model.RowKeySet is abstract; cannot be instantiated
    Please guide me if you have an idea on how to change the adf statement to Trinidad code statement “this.psdTable.setSelectionState(new RowKeySet());”

    Hi,
    which "4. click on back button." ? If its the browser back button then this only navigates back the UI not the server state of an application.
    Frank

  • Code problem

    Hey i've this button on my applet that when clicked passes text entered in a textArea to a seperate class,then shows the result (after the class is finished with it), at least thats what its supposed to do. What happens is that a flock of errors occur. Can anyone spot the problem
    Here's the button code
    public boolean action (Event e, Object o)
         if (e.target == b1)
         first = text1.getText();
         ParseMe parser = new ParseMe(first);
            if( parser.answer()==1){
           showStatus("Answer was" + parser.answer());
           return true;
         }else{
           showStatus("Answer was" + parser.answer());
           return false;
       }and this is the class that the info's bein passed to
    package test.pkg;
    public final class ParseMe {
            //----------------- public interface ---------------------------------------
            public ParseMe(String definition) {
                    // Construct an expression, given its definition as a string.
                    // This will throw an IllegalArgumentException if the string
                    // does not contain a legal expression.
                    parse(definition);
            public double answer(){
              return this.value(1.0,1.0,1.0)+ this.computeStackUsage();
            public double value(double x) {
                    // Return the value of this expression, when the variable x
                    // has the specified value.  If the expression is undefined
                    // for the specified value of x, then Double.NaN is returned.
                    return eval(x, 0, 0);
            public double value(double x, double y) {
                    // Return the value of this expression, when the variable x
                    // has the specified value.  If the expression is undefined
                    // for the specified value of x, then Double.NaN is returned.
                    return eval(x, y, 0);
            public double value(double x, double y, double z) {
                    // Return the value of this expression, when the variable x
                    // has the specified value.  If the expression is undefined
                    // for the specified value of x, then Double.NaN is returned.
                    return eval(x, y, z);
            public String getDefinition() {
                    // Return the original definition string of this expression.  This
                    // is the same string that was provided in the constructor.
                    return definition;
            //------------------- private implementation details ----------------------------------
            private String definition;  // The original definition of the expression,
            // as passed to the constructor.
            private byte[] code;        // A translated version of the expression, containing
            //   stack operations that compute the value of the expression.
            private double[] stack;     // A stack to be used during the evaluation of the expression.
            private double[] constants; // An array containing all the constants found in the expression.
            private static final byte  // values for code array; values >= 0 are indices into constants array
                    PLUS = -1,   MINUS = -2,   TIMES = -3,   DIVIDE = -4,  POWER = -5,
                    UNARYMINUS = -6, VARIABLE_X = -7, VARIABLE_Y = -8, VARIABLE_Z = -9;
            private double eval(double variableX, double variableY, double variableZ) {
          // evaluate this expression for this value of the variable
                    try {
                            int top = 0;
                            for (int i = 0; i < codeSize; i++) {
                                    if (code[i] >= 0)
                                            stack[top++] = constants[code];
    else if (code[i] >= POWER) {
    double y = stack[--top];
    double x = stack[--top];
    double ans = Double.NaN;
    switch (code[i]) {
    case PLUS: ans = x + y; break;
    case MINUS: ans = x - y; break;
    case TIMES: ans = x * y; break;
    case DIVIDE: ans = x / y; break;
    case POWER: ans = Math.pow(x,y); break;
    if (Double.isNaN(ans))
    return ans;
    stack[top++] = ans;
    else if (code[i] == VARIABLE_X) {
    stack[top++] = variableX;
    else if (code[i] == VARIABLE_Y) {
    stack[top++] = variableY;
    else if (code[i] == VARIABLE_Z) {
    stack[top++] = variableZ;
    else {
    double x = stack[--top];
    double ans = Double.NaN;
    switch (code[i]) {
    case UNARYMINUS: ans = -x; break;
    if (Double.isNaN(ans))
    return ans;
    stack[top++] = ans;
    catch (Exception e) {
    return Double.NaN;
    if (Double.isInfinite(stack[0]))
    return Double.NaN;
    else
    return stack[0];
    private int pos = 0, constantCt = 0, codeSize = 0; // data for use during parsing
    private void error(String message) {  // called when an error occurs during parsing
    throw new IllegalArgumentException("Parse error: " + message + " (Position in data = " + pos + ".)");
    private int computeStackUsage() {  // call after code[] is computed
    int s = 0; // stack size after each operation
    int max = 0; // maximum stack size seen
    for (int i = 0; i < codeSize; i++) {
    if (code[i] >= 0 || code[i] == VARIABLE_X
    || code[i] == VARIABLE_Y || code[i] == VARIABLE_Z
    s++;
    if (s > max)
    max = s;
    else if (code[i] >= POWER)
    s--;
    return max;
    private void parse(String definition) {  // Parse the definition and produce all
    // the data that represents the expression
    // internally; can throw IllegalArgumentException
    if (definition == null || definition.trim().equals(""))
    error("No data provided to Expr constructor");
    this.definition = definition;
    code = new byte[definition.length()];
    constants = new double[definition.length()];
    parseExpression();
    skip();
    if (next() != 0)
    error("Extra data found after the end of the expression.");
    int stackSize = computeStackUsage();
    stack = new double[stackSize];
    byte[] c = new byte[codeSize];
    System.arraycopy(code,0,c,0,codeSize);
    code = c;
    double[] A = new double[constantCt];
    System.arraycopy(constants,0,A,0,constantCt);
    constants = A;
    private char next() {  // return next char in data or 0 if data is all used up
    if (pos >= definition.length())
    return 0;
    else
    return definition.charAt(pos);
    private void skip() {  // skip over white space in data
    while(Character.isWhitespace(next()))
    pos++;
    // remaining routines do a standard recursive parse of the expression
    private void parseExpression() {
    boolean neg = false;
    skip();
    if (next() == '+' || next() == '-') {
    neg = (next() == '-');
    pos++;
    skip();
    parseTerm();
    if (neg)
    code[codeSize++] = UNARYMINUS;
    skip();
    while (next() == '+' || next() == '-') {
    char op = next();
    pos++;
    parseTerm();
    if (op == '+')
    code[codeSize++] = PLUS;
    else
    code[codeSize++] = MINUS;
    skip();
    private void parseTerm() {
    parseFactor();
    skip();
    while (next() == '*' || next() == '/') {
    char op = next();
    pos++;
    parseFactor();
    if (op == '*')
    code[codeSize++] = TIMES;
    else
    code[codeSize++] = DIVIDE;
    skip();
    private void parseFactor() {
    parsePrimary();
    skip();
    while (next() == '^') {
    pos++;
    parsePrimary();
    code[codeSize++] = POWER;
    skip();
    private void parsePrimary() {
    skip();
    char ch = next();
    if (ch == 'x' || ch == 'X') {
    pos++;
    code[codeSize++] = VARIABLE_X;
    else if (ch == 'y' || ch == 'Y') {
    pos++;
    code[codeSize++] = VARIABLE_Y;
    else if (ch == 'z' || ch == 'Z') {
    pos++;
    code[codeSize++] = VARIABLE_Z;
    else if (Character.isDigit(ch) || ch == '.')
    parseNumber();
    else if (ch == '(') {
    pos++;
    parseExpression();
    skip();
    if (next() != ')')
    error("Exprected a right parenthesis.");
    pos++;
    else if (ch == ')')
    error("Unmatched right parenthesis.");
    else if (ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '^')
    error("Operator '" + ch + "' found in an unexpected position.");
    else if (ch == 0)
    error("Unexpected end of data in the middle of an expression.");
    else
    error("Illegal character '" + ch + "' found in data.");
    private void parseNumber() {
    String w = "";
    while (Character.isDigit(next())) {
    w += next();
    pos++;
    if (next() == '.') {
    w += next();
    pos++;
    while (Character.isDigit(next())) {
    w += next();
    pos++;
    if (w.equals("."))
    error("Illegal number found, consisting of decimal point only.");
    if (next() == 'E' || next() == 'e') {
    w += next();
    pos++;
    if (next() == '+' || next() == '-') {
    w += next();
    pos++;
    if (! Character.isDigit(next()))
    error("Illegal number found, with no digits in its exponent.");
    while (Character.isDigit(next())) {
    w += next();
    pos++;
    double d = Double.NaN;
    try {
    d = Double.valueOf(w).doubleValue();
    catch (Exception e) {
    if (Double.isNaN(d))
    error("Illegal number '" + w + "' found in data.");
    code[codeSize++] = (byte)constantCt;
    constants[constantCt++] = d;
    /*public static void main(String args[])
    ParseMe me = new ParseMe("1");
    System.out.println(me.value(1,1,1) + ", " + me.computeStackUsage());
    any help would be well appreciated.
    cheers
    podger

    It looks like it parses a mathematical expression represented as a String with up to three variables (x, y, z), and will substitute x, y, and z with whatever values you give it. What is your "text" (value of "first") that you are trying to parse?
    Eventually, you probably want to have text fields for the user to enter x, y, and z, parse those text values as doubles, and pass those to your ParseMe instance by calling: parser.value(x, y, z);
    What happens if you type the following in the text field named "text1"?
    x + y + z

  • Generating a new table based on user choices - Code Problems

    A while ago someone posted on one of the Adobe forums the following code (sorry I do not remember the name / link). This code is meant to generate a second table (an Object list in this case) according to the user’s choices at another table (in this case a dropdown list):
    form1.TableA.TableTitles.Row1.DropDownList1::change - (JavaScript, client)
    var str_itemtext = xfa.event.newText;
    var olist2 = xfa.resolveNode("form1.TableA.TableTitles.Row2.ListBox2");
    var arrayADVS = new Array("Acad", "Disp", "Advs");
    var arrayCD = new Array("Proj-", "HRS");
    if (str_itemtext == "ADVS") {
    makelist(olist2, arrayADVS);
    olist2.presence = "visible";
    else if (str_itemtext == "CD"){
    makelist(olist2, arrayCD);
    olist2.presence = "visible";
    function makelist(olist, arrayitem) {
    var i = 0;
    olist.clearItems();
    for (i = 0; i < arrayitem.length; i ++){
    olist.addItem(arrayitem[i], arrayitem[i]);
    I made a couple of minor changes but generally preserved the original code and it seemed to work fine. The problem arises after the completed form is saved:- the “object list” (second table) disappears even though I set it as visible. I tried changing the Type (from user entered required to read only) but to no avail.
    Could someone please help me figure out what is wrong with this code? Why does this Object List object disappears after the form is saved?
    Thanks.

    If you could post the form or send a copy to [email protected] I would be happy to take a look, otherwise, it is hard to diagnose.
    Steve

  • Photoshop CS2 and "Invalid Serial Code" Problem

    Well, I recently upgraded from Windows XP to Windows 7.
    Tonight I tried to install my Adobe Creative Suite CS2 (just the Reader and PS CS2)...
    I got the error "The serial code is missing or invalid and Photoshop must exit."
    And it did.
    So, I removed it and reinstalled it.
    Same error.
    So, I tried the cleaner (that comes in the extract file) that somebody suggested on here.
    I've tried various solutions from the knowledge base.
    Still no luck.
    I'm grateful I've read that others are having problems with CS3 and CS4....
    This will save me money... as I won't be purchasing Adobe products anytime soon.
    I won't bother calling tech support. They'll tell me they no longer support CS2 and that they're sorry about that and there's nothing they can do.
    Adobe took my money once.
    It won't happen again.
    Shame on you, Adobe.

    Hi Hunt,
    Thank you for the warm welcome.
    I believe I've read on these forums (and I could be very wrong) that I heard others with more recent incarnations of Photoshop (eg. CS 4) have also had problems with Windows 7. Again, I could be very mistaken.
    Trust me... I really do enjoy Photoshop and I WANT it to work... and perhaps I over-reacted... to think that such an "old" version would work on Windows 7. I guess after spending a few hundred dollars on a photo editing software just a few years ago, I had expectations that it would be useful for me for more than three years. (No sarcasm there... I really did hope that. )
    It's good to see that Adobe has loyal customers such as yourself that would (by your own admission) "spend the entire day on hold"... I wish I had that type of time. I simply don't.
    There are other photo-editing softwares out there and while I'll be disappointed to go to them... being a teacher, I just can't afford another two or three hundred dollars (and that's WITH the educators' discount) to plop down on Photoshop.
    I appreciate your taking the time to respond to my post.
    Respectfully,
    Ted

  • Tax code problem in Vendor clearing

    Hello,
    We have used Tax code V0 for zero input tax in vendor down payment as of zero tax . But due to some error problems tax code T0 got corrupted . We have created new tax code V0 ,
    Made changes according to it in transaction OBCL .
    But now while vendor clearing it is giving error 'Invalid Tax code ' in items which has Tax code T0.
    Please suggest me a solution .
    Regards
    Nilesh

    Yes the old  tax code is present in the FTXP
    the system is giving following error while clearing the vendor items .
    Tax code  in procedure  is invalid
    Message no. FF704
    Diagnosis
    The tax code entered is not defined in the company code country.
    System Response
    Procedure
    Check and, if necessary, correct the entry.
    Procedure for System Administration
    If it is not an input error, check and possibly change the system settings.
    To do this, choose Maintain entries (F5).
    1. Check whether the required tax procedure has been allocated to the company code country. The Procedure field is on the detailed screen.
    2. If you need a new tax code, you can create one yourself.

  • Company code problem in Controlling area Tcodes

    Hi All,
    We are following role based authorisation for creating roles for FI/CO module and we are seggregating roles as per the company codes.We are assigning Tcodes like KO01,KO02,KO03(Internal order) and KS01,KS02,KS03(cost center) which are connected with Controlling area in one role.We have 5 company codes and we are trying to create 5 roles with the above Tcodes for 5 different company codes.
    The problem we encountered is when we entered the Tcodes in the role, and we get to the 'Change authrisation data' option in the 'Authorisation' tab in PFCG, the system is not prompting for the Company code organisational level. Hence in this case, a user will be able to access the above mentined Tcodes for all the company codes. But we need to create a role in such a way that a user who is assigned this role is only able to access Tcode like KO01,02,03 etc for his company code only and should not be authorized to access these Tcodes for remaining 4 company codes.
    Can anybody please help me with a way to restrict these Tcodes to a particular company code in our scenario.
    Thanks and Regards,
    Abdul Khyoom A.

    Hi Ashok,
    Thanks for the response.
    Here in my case, when I insert the Tcodes related to conrolling like(KO01,KO02,KO03 etc) in a role, then I dont find any authorization objects(bukrs) which is related to the company code in the authorization genaration area in PFCG. So there is no way I can maintain values in them.
    Please suggest any alternate solution.
    Thanks and Regards,
    Abdul Khyoom A

  • Code problem, variable might not have been initialized..

    I have a program I'm working on, I have to seperate file classes.. I have one that is mainly just the class and its functions, the other I'm triing to get to use the previously mentioned class, but it keeps telling me that my variable might not have been initialized.. I have default constructor built in the first class file, but it doesn't seem to be using it when I try accessing it through the other class...
    Here is the code I just pasted it, so it kinda wrapped in some spots.
    class:
    public class Cat{
         private String color;
         private char gender;
         private boolean neutered;
         private String name;
         private int weight;
         public Cat(){
              color = "orange";
              gender = 'M';
              neutered = true;
              name = "Garfield";
              weight = 20;
         public void setColor(String catColor){
              color = catColor;
    public void setGender(char catGender){
              if ((catGender == 'f') || (catGender == 'F'))
              gender = 'F';
              else
         gender = 'M';
         public void setNeutered(char catNeutered){
         if ((catNeutered == 'Y') || (catNeutered == 'y'))
              neutered = true;
         else
                   neutered = false;
         public void setName(String catName){
              name = catName;
         public void setWeight(int catWeight){
              weight = catWeight;
         public void weigh(){
              System.out.println(name + " weighs " +
    weight + "lbs.");
         public void showColor(){
              System.out.println(name + " is " + color);
         public void eat(){
              System.out.println(name + " has eaten his food
    and is now full");
         public void yowl(){
              System.out.println(name + "yoowwwwllllll");
         public void fertility(){
              if (gender == 'F')
              if (neutered)
              System.out.println(name + "cannot have kittens.");
              else
                   System.out.println(name + "can have kittens.");
              else
         if (neutered)
         System.out.println(name + "cannot father kittens.");
    else
              System.out.println(name + "can father kittens.");
    This is what I'm triing to use it with:
    public class JailCats{
         public static void main (String[] args) {
              Cat meow1;
              meow1.weigh();
    }

    It is using the default c'tor. But since you didn't implement it, all it does is nothing.
    But that's not the (immediate) problem. Somewhere you're using a local variable without setting a value for it. Hint: look at the line the error message hints at. Because I can't, because you don't tell and your posted code is unreadable.
    Edit: yeah, here it is:
    Cat meow1;
    meow1.weigh();So where do you actually set the meow1 reference to point to a Cat instance?

Maybe you are looking for