Help with uneditable JTable - frustrated

can someone please give me WORKING code (not, oh it is easy do this and that) to make the whole JTable uneditable? if you give me the abstract model with cell renderer, i will put in the JTable using the:
JTable (yourAbstractModel)
my JTable is 100 percent purely DYNAMIC. i will have no idea how many columns there may be until after the user chooses the columns to see (which i have working).
when a user selects a row, i will set the column to a
light gray .
after a day, i was able to get the columns to stop shrinking and let the scoll bars work on the scroll pane (after going to some 20 web sites looking at code). i am very frustrated.
i do need to get the value of a cell to determine which record they are going to edit.
THANKS FOR ANY HELP!!!!!

SORRY
this >
when a user selects a row, i will set the column to a
light gray .
should READ >
when a user selects a row, i will set the ROW to a
light gray .

Similar Messages

  • Hoping for some help with a very frustrating issue!   I have been syncing my iPhone 5s and Outlook 2007 calendar and contacts with iCloud on my PC running Vista. All was well until the events I entered on the phone were showing up in Outlook, but not

    Hoping for some help with a very frustrating issue!
    I have been syncing calendar and contacts on my iPhone 5 and Outlook 2007 using iCloud  2.1.3 (my PC is running Vista). All was well until the events I entered on the phone were showing up in Outlook, but not the other way around. I’ve tried the usual recommended steps: deselecting calendar and contacts in the iCloud control panel and then re-selecting, signing out of the panel and back in, and repairing the Outlook installation in control panel.  I even uninstalled iCloud on the PC and downloaded it again (same version). 
    The furthest I’ve gotten is step 2 (and once, step 3) of 7 while performing “Outlook Setup For iCloud.” At that point I get, “Your setup couldn’t be started because of an unexpected error.”  After the first attempt at all this, all my calendar events disappeared from Outlook, although they are still in iCloud calendar and on my phone.
    Sound familiar?  Any ideas on how to solve this iCloud/Outlook issue?  Thanks much in advance!

    Hoping for some help with a very frustrating issue!
    I have been syncing calendar and contacts on my iPhone 5 and Outlook 2007 using iCloud  2.1.3 (my PC is running Vista). All was well until the events I entered on the phone were showing up in Outlook, but not the other way around. I’ve tried the usual recommended steps: deselecting calendar and contacts in the iCloud control panel and then re-selecting, signing out of the panel and back in, and repairing the Outlook installation in control panel.  I even uninstalled iCloud on the PC and downloaded it again (same version). 
    The furthest I’ve gotten is step 2 (and once, step 3) of 7 while performing “Outlook Setup For iCloud.” At that point I get, “Your setup couldn’t be started because of an unexpected error.”  After the first attempt at all this, all my calendar events disappeared from Outlook, although they are still in iCloud calendar and on my phone.
    Sound familiar?  Any ideas on how to solve this iCloud/Outlook issue?  Thanks much in advance!

  • Help with dispatching JTable event to underlying components in a cell.

    Hello..
    I have a JTable in which i show a panel with clickable labels.. I found that jTable by default doesnt dispatch or allow mouseevents to be caught by underlying elements..
    i need help with dispatching an event from jTable to a label on a panel in a jTable cell.. below is the code i have come up with after finding help with some websites. but i couldnt not get it right.. my dispatched event seems to go back to the jtable itself ..
    any help or suggestion is appreciated..
    Thanks
    'Harish.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.table.*;
    * @author  harish
    public class tableDemo extends javax.swing.JFrame {
        JTable jTable1;
        testpane dummyPane;
        /** Creates new form tableDemo */
        public tableDemo() {
            initComponents();
            //table settings
            String[] columnNames = {"Task", "Action"," "};
            Object[][] data = { };
            DefaultTableModel model = new DefaultTableModel(data, columnNames) {
              // This method returns the Class object of the first
              // cell in specified column in the table model.
            public Class getColumnClass(int mColIndex) {
                int rowIndex = 0;
                Object o = getValueAt(rowIndex, mColIndex);
                if (o == null)
                    return Object.class;
                } else
                    return o.getClass();
            jTable1 = new javax.swing.JTable(model);
            jTable1.addMouseListener(new MouseAdapter(){
              public void mouseClicked(MouseEvent e){
                  System.out.println("Clicked");
                  handleTableMouseEvents(e);
                 //invokeExternalApp("http://www.pixagogo.com");
              public void mouseEntered(MouseEvent e){
                  System.out.println("Entered");
                  //handleTableMouseEvents(e);
              public void mouseExited(MouseEvent e){
                  System.out.println("Exited");
                  //handleTableMouseEvents(e);
            jTable1.setRowHeight(100);
            jTable1.getTableHeader().setReorderingAllowed(false);
            jTable1.setBackground(new java.awt.Color(255, 255, 255));
            jTable1.setGridColor(new Color(250,250,250));
            jTable1.setShowGrid(true);
            jTable1.setShowVerticalLines(true);
            jTable1.setShowHorizontalLines(false);
            jTable1.setFont(new Font("Arial",0,11));
            jTable1.setMaximumSize(new java.awt.Dimension(32767, 32767));
            jTable1.setMinimumSize(new java.awt.Dimension(630, 255));
            jTable1.setPreferredSize(null);
            jTable1.setBackground(new Color(255,255,255));
            int vColIndex=0;
            TableColumn col = jTable1.getColumnModel().getColumn(vColIndex);
            int width = 100;
            col.setPreferredWidth(width);
            //add item to 2nd cell       
            Vector vec = new Vector();
            vec.addElement(null);
            dummyPane = new testpane();
            vec.addElement(dummyPane);
            ((DefaultTableModel)jTable1.getModel()).addRow(vec);
            jTable1.repaint();
            this.getContentPane().add(jTable1);
            jTable1.getColumn("Action").setCellRenderer(
              new MultiRenderer());
        protected void handleTableMouseEvents(MouseEvent e){
            TableColumnModel columnModel = jTable1.getColumnModel();
            int column = columnModel.getColumnIndexAtX(e.getX());
            int row    = e.getY() / jTable1.getRowHeight();
            testpane contentPane = (testpane)(jTable1.getModel().getValueAt(row, column));
            // get the mouse click point relative to the content pane
            Point containerPoint = SwingUtilities.convertPoint(jTable1, e.getPoint(),contentPane);
            if (column==1 && row==0)
            // so the user clicked on the cell that we are bothered about.         
            MouseEvent ev1 = (MouseEvent)SwingUtilities.convertMouseEvent(jTable1, e, contentPane);
            //once clicked on the cell.. we dispatch event to the object in that cell
         jTable1.dispatchEvent(ev1);
        private void initComponents() {
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            setBounds((screenSize.width-528)/2, (screenSize.height-423)/2, 528, 423);
        /** Exit the Application */
        private void exitForm(java.awt.event.WindowEvent evt) {
            System.exit(0);
         * @param args the command line arguments
        public static void main(String args[]) {
            new tableDemo().show();
        // Variables declaration - do not modify
        // End of variables declaration
        class testpane extends JPanel{
            public testpane(){
            GridBagConstraints gridBagConstraints;
            JPanel testpane = new JPanel(new GridBagLayout());
            testpane.setBackground(Color.CYAN);
            JLabel lblTest = new JLabel("test");
            lblTest.addMouseListener(new MouseAdapter(){
              public void mouseClicked(MouseEvent e){
                  System.out.println("panelClicked");
              public void mouseEntered(MouseEvent e){
                  System.out.println("panelEntered");
              public void mouseExited(MouseEvent e){
                  System.out.println("panelExited");
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.gridx = 0;
            gridBagConstraints.gridy = 0;
            gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
            testpane.add(lblTest,gridBagConstraints);
            this.add(testpane);
    class MultiRenderer extends DefaultTableCellRenderer {
      JCheckBox checkBox = new JCheckBox();
      public Component getTableCellRendererComponent(
                         JTable table, Object value,
                         boolean isSelected, boolean hasFocus,
                         int row, int column) {
        if (value instanceof Boolean) {                    // Boolean
          checkBox.setSelected(((Boolean)value).booleanValue());
          checkBox.setHorizontalAlignment(JLabel.CENTER);
          return checkBox;
        String str = (value == null) ? "" : value.toString();
        return super.getTableCellRendererComponent(
             table,str,isSelected,hasFocus,row,column);
        return (testpane)value;
    class MultiEditor implements TableCellEditor {
      public MultiEditor() {
      public boolean isCellEditable(EventObject anEvent) {return false;}
      public boolean stopCellEditing() {return true;}
      public Object getCellEditorValue() {return null;} 
      public void cancelCellEditing() {}
      public boolean shouldSelectCell(EventObject anEvent) {return false;}
      public Component getTableCellEditorComponent(JTable table, Object value,
                  boolean isSelected, int row, int column) {
        if (value instanceof testpane) {                       // ComboString
          System.out.println("yes instance");
        return null;
      public void addCellEditorListener(javax.swing.event.CellEditorListener l) {
      public void removeCellEditorListener(javax.swing.event.CellEditorListener l) {
    }

    any help on this.. anybody. ?

  • Help with JComboBox-JTable

    Hi there!
    I'll try to explain my problem the best I can, I hope you can understand me so you may get to help me, I'd really appreciate it. I'm trying to make a JTable to render a cell as a JComboBox, that's ok and it's working fine. The problem comes when I try to change the combo value. The itemStateChanged method is supposed to get some values from a database, if the first is bigger than the second it shows an alert, else it makes an update to the database. Now, the problem is that, if the combobox default value is blank (""), it works fine, but if it's filled with something as a name ("anything") it automatically shows the alert, even if I'm not changing the combo value. The second problem is that it shows the alert twice, I'll try to explain with code:
    class Cambia_Cita extends javax.swing.AbstractCellEditor implements javax.swing.table.TableCellEditor ,java.awt.event.ItemListener{
        protected EventListenerList listenerList = new EventListenerList();
        protected ChangeEvent changeEvent = new ChangeEvent(this);   
        protected javax.swing.JComboBox combo = new javax.swing.JComboBox();
        int i;
        String valor = "";
        int j;
        javax.swing.JTable tabla = new javax.swing.JTable();
        public Cambia_Cita() {
            super();
            combo.addItemListener(this);
            Base base = new Base();
            Statement sta = base.conectar();
            try {
                ResultSet rs = sta.executeQuery("SELECT DISTINCT Nombre_Completo FROM Pacientes WHERE Alta = 'n'");
                combo.addItem("");
                while(rs.next())
                    combo.addItem(rs.getString("Nombre_Completo"));
            }catch(SQLException e) {
                System.out.println (e.getMessage());
            } finally {
                base.cerrar(sta);
            combo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent event) {
                    System.out.println("algo");
                    tabla.setValueAt(valor,i,j);
        public Object getCellEditorValue() {
            return(combo.getSelectedItem());
        public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, Object value, boolean isSelected, int row, int column) {
            i = row;
            j = column;
            tabla = table;
            valor = value.toString();
            combo.setSelectedItem(tabla.getValueAt(i,j));
            System.out.println (i + "," + j);
            java.awt.Component c = table.getDefaultRenderer(String.class).getTableCellRendererComponent(table, value, isSelected, false, row, column);
            if (c != null) {
                combo.setBackground(c.getBackground());
            return combo;
        public void itemStateChanged(java.awt.event.ItemEvent e) {
            Base base = new Base();
            Statement sta = base.conectar();
            try {
                String asist;
                if (tabla.getValueAt(i,3).equals(new Boolean(true))) {
                    asist = "s";
                } else {
                    asist = "n";
                ResultSet rs = sta.executeQuery("SELECT COUNT(ID_Cita) FROM Cita JOIN Pacientes ON Cita.RFC_Paciente " +
                        "= Pacientes.RFC_Paciente WHERE Nombre_Completo = '" + combo.getSelectedItem() + "'");
                rs.next();
                int result = rs.getInt("COUNT(ID_Cita)");
                rs = sta.executeQuery("SELECT Consultas FROM Ciclo JOIN Pacientes ON Ciclo.RFC_Paciente = Pacientes." +
                        "RFC_Paciente WHERE Nombre_Completo = '"+ combo.getSelectedItem() +"' AND Ciclo.Numero_Ciclo = " +
                        "Pacientes.Ciclo");
                rs.next();
                int maximo = rs.getInt("Consultas");
                /* if maximo is bigger than result plus 1, then it shows the alert, but it is shown even if I don't change the combo value!!!, this part only works if the default value of the combo is blank */
                if (maximo >= result +1 ) {
                    sta.executeUpdate("UPDATE Cita,Pacientes SET Cita.RFC_Paciente = Pacientes.RFC_Paciente WHERE " +
                            "Nombre_Completo = '" + combo.getSelectedItem() + "' AND ID_Cita = " + tabla.getValueAt(i,0));
                }else
                    javax.swing.JOptionPane.showMessageDialog(null,"No se puede agregar otra cita...");
            }catch (ArrayIndexOutOfBoundsException ex) {
                System.out.println (ex.getMessage());
            } catch (SQLException ex) {
                System.out.println (ex.getMessage());
            } finally {
                base.cerrar(sta);
    }So, I'd like to know why the alert appears twice when it works and why it appears even if the combo value ain't changed. I really hope anyone can help me. Thank you!

    if the first is bigger than the second it shows an alertIf you want to know when data is changed in the table then you use a TableModelListener, not an ItemListener. Here is a simple example:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=566133
    If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program (SSCCE) that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting.

  • Hi, i need help with a jtable

    hi, iam new here, i try to read an excel file, and put the rows and columns in a jtable, i dont have the code exactly but maybe someone can help me.

    You can use this
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    //String myDB ="myExcel";
    String myDB =  "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=c:/book.xls;"
        + "DriverID=22;READONLY=false";
    //con=DriverManager.getConnection("jdbc:odbc:myExcel");
    con=DriverManager.getConnection(myDB,"","");
    dbmd=con.getMetaData();
    stat=con.createStatement();
    rs=stat.executeQuery("Select * from `Sheet1$`");//[Sheet1$]
    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();
    while (rs.next()) {
    for (int i = 1; i <= numberOfColumns; i++) {
    if (i > 1) System.out.print(", ");
    String columnValue = rs.getString(i);
    System.out.print(columnValue);
    System.out.println("");
    for (int j = 1; j <= numberOfColumns; j++)
      System.out.println(rsmd.getColumnName(j));
    rsTable=dbmd.getTables(null,null,"%",null);
    while (rsTable.next())
    //String tableCatalog = rsTable.getString(1);
    //String tableSchema = rsTable.getString(2);
    System.out.println("Table Name "+rsTable.getString(3)+" Table catalog "+rsTable.getString(1)+" Table Schema "+rsTable.getString(2));
    rsTable.close();You can store Column Names,data in the String Array.
    To generate a JTable with this check this
    http://www.codetoad.com/java_JTable.asp.
    There at method createBlankElement()
    put values from the data array or if you want, from the database.
    For the Columns, pass columnNames array to addColumns method.

  • Need help with advanced JTable

    The application I am converting to Java has a string grid (table) with special behavior that I need to be able to bring to the Java version. It let's users filter the column data (that I know how to do) using a locked first row (just below the column header) that always stays in place and that shows what filter is applied to each column (by showing a combo box).
    I usually write server apps and have only been trying to grasp Swing for about a week, and I find myself stuck :(
    Is this at all possible in Java? If not, can I make the header respond to mouse events and show a popup menu for each column? If so how?
    Please help!

    I have made an attempt as follows (to show where I am stuck).
    I have two TableModels that contain rows and data;
    a) the grid data that's coming from our EJB session facade
    b) the filter settings (a String[] with initially empty strings) which show what filter is used for each column.
    The two table models are shown in two tables that share a common TableColumnModel so that whenever i move or resize a column both tables are updated.
    The filter table shows it's header and the row of empty cells. The Table Model I've used for it is ripped from the Sorted Table example from Sun, so that I can capture mouse events, set the sort order for each column and notify the grid table that it needs to update accordingly.
    I attempted to use the filter table as a header view in a JScrollPane, which would keep it in place all the time while the user would be able to scroll and resize the grid table.
    This is where I fail - I can't even get it to show up in the header. And if I only put the two tables on a JPanel it seems impossible to get them to stick together when the pane is resized (aside from the fact that I no longer can capture the mouse events).
    I'd be happy to send someone the code fragments if you think you have a solution to this - that will allow users to resize, edit and move columns in a table where you initially have no clue as to how many columns it will contain.
    Please please continue to help me :)

  • Help with tables for frustrated newbie

    Could someone look at the starters of a site I'm trying to
    get up and going? The link is here:
    http://canyoncrestfoundation.org/newhomepage.htm
    The site is a table with five rows. I would like to be able
    to use the basic design on other pages, and change the fourth row
    down on different pages. It's the row with the image of the
    teenagers, and it has the text what "if I try to type here...". I'm
    using Dreamweaver 8 and if I move click on the draw table button in
    Layout mode, and then try to move the cursor over that row, I get a
    circle with a line diagonally across the middle. I really wanted to
    be able to have varying layouts in that center part. Also, what do
    I do to move the top text in that row over-- where it says,
    "Partnering with..." Thank you! I'm feeling very frustrated with
    this.
    Please be kind and gentle. I'm figuring this out on
    my own, and am just a volunteer for the foundation.

    Looks exactly like the problem I faced....
    Thilak.
    quote:
    Originally posted by:
    Newsgroup User
    First things first, get out of layout mode - you'll end up
    doing yourself an
    injury ;-)
    Do not 'draw' tables, insert them. copy and paste the
    following into a new
    DW window and see how I've put the various elements
    together. Use separate
    tables for each of your elements - it should get you on the
    right track:
    PS: This may be a good tutorial to have a read through
    before you go any
    further too:
    http://www.dwfaq.com/Tutorials/Tables/flexible_tables.asp
    It will show you how to 'nest' tables, so that adjacent
    cells don't 'blow'
    out as you add content....
    Code here:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN"
    http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <HEAD>
    <TITLE>Canyon Crest Academy Foundation fundraising
    volunteer
    support</TITLE>
    <META NAME="DESCRIPTION" CONTENT="Canyon Crest Academy
    Foundation
    provides monetary and volunteer support to the school.
    Budget information,
    upcoming events, contact information for the board,
    volunteer opportunities
    all listed at the site.">
    <META NAME="KEYWORDS" CONTENT="Canyon Crest Academy,
    fundraising,
    volunteer, contact board, donors, giving">
    <meta http-equiv="Content-Type" content="text/html;
    charset=ISO-8859-1">
    <title>newhomepage</title>
    <style type="text/css">
    <!--
    body {
    background-image: url(../../Library/Application
    Support/Macromedia/Dreamweaver
    8/Configuration/ServerConnections/CCAF//htdocs/images/eostilework1f.gif);
    margin-left: 30px;
    margin-top: 30px;
    margin-right: 30px;
    margin-bottom: 30px;
    background-image: url(images/eostilework1f.gif);
    body,td,th {
    font-family: "Times New Roman", Times, serif;
    font-size: 10px;
    color: #111111;
    a:link {
    color: #880000;
    a:visited {
    color: #555555;
    a:hover {
    color: #220000;
    a:active {
    color: #440000;
    .style4 {
    font-family: "Times New Roman", Times, serif;
    font-size: 12px;
    -->
    </style>
    </head>
    <body>
    <div align="center">
    <table width="900" border="0" cellspacing="0"
    cellpadding="0">
    <tr>
    <td><img src="images/top.jpg" width="900"
    height="105"></td>
    </tr>
    <tr>
    <td><img src="images/view1.jpg" width="900"
    height="89"></td>
    </tr>
    </table>
    <table width="900" border="0" cellspacing="0"
    cellpadding="0">
    <tr>
    <td>Home</td>
    <td><a
    href="../../htdocs/Giving1.html">Giving</a></td>
    <td>Volunteers</td>
    <td>Board</td>
    <td>Successes</td>
    <td>something else </td>
    </tr>
    </table>
    <table width="900" border="0" cellspacing="0"
    cellpadding="0">
    <tr>
    <td><span class="style4">...partnering with
    students, parents and staff to
    facilitate community involvement and provide financial
    support for CCA
    educational programs and priorities.</span></td>
    </tr>
    </table>
    <table width="900" border="0" cellspacing="0"
    cellpadding="0">
    <tr>
    <td><table width="900" border="0" cellspacing="0"
    cellpadding="0">
    <tr>
    <td valign="top"><p><img
    src="images/highschoolkids_000.jpg" width="216"
    height="144" align="top"></p>
    <p> </p></td>
    <td valign="top"><p>What if I try to type here?
    That works, so why can't the
    table? </p>
    <p>type as much as you want in this cell
    </p></td>
    </tr>
    </table></td>
    </tr>
    </table>
    <table width="900" border="0" cellspacing="0"
    cellpadding="0">
    <tr>
    <td><img src="images/bottom.jpg" width="900"
    height="95"></td>
    </tr>
    </table>
    </div>
    </body>
    </html>
    Nadia
    Adobe? Community Expert : Dreamweaver
    CSS Templates |Tutorials |SEO Articles
    http://www.DreamweaverResources.com
    Customisation Service Available:
    http://www.csstemplates.com.au
    CSS Tutorials for Dreamweaver
    http://www.adobe.com/devnet/dreamweaver/css.html
    "Sootica" <[email protected]> wrote in
    message
    news:[email protected]...
    > Could someone look at the starters of a site I'm trying
    to get up and
    > going?
    > The link is here:
    >
    http://canyoncrestfoundation.org/newhomepage.htm
    >
    > The site is a table with five rows. I would like to be
    able to use the
    > basic
    > design on other pages, and change the fourth row down
    on different pages.
    > It's
    > the row with the image of the teenagers, and it has the
    text what "if I
    > try to
    > type here...". I'm using Dreamweaver 8 and if I move
    click on the draw
    > table
    > button in Layout mode, and then try to move the cursor
    over that row, I
    > get a
    > circle with a line diagonally across the middle. I
    really wanted to be
    > able to
    > have varying layouts in that center part. Also, what do
    I do to move the
    > top
    > text in that row over-- where it says, "Partnering
    with..." Thank you! I'm
    > feeling very frustrated with this.
    Please be kind and
    > gentle.
    > I'm figuring this out on my own, and am just a
    volunteer for the
    > foundation.
    >

  • Help with TableRowSorter , JTable and JList

    Hello,
    I�m developing an application in which I�m using a Jtable and Jlist to display data from a database. Jtable and Jlist share the same model.
    public class DBSharedModel extends DefaultListModel implements TableModelFor the Jtable I set a sorter and an filter
    DBSharedModel dataModel = new DBSharedModel();
    Jtable jTable = new JTable(dataModel) ;
    jTable.createDefaultColumnsFromModel();
    jTable.setRowSelectionAllowed(true);
    TableRowSorter<DBSharedModel> sorter = new TableRowSorter <DBSharedModel> (dataModel);
    jTable.setRowSorter(sorter);From what I read until now JavaSE 6 has NOT a sorter for JList (like one for JTable).
    So, I am using one from a this article http://java.sun.com/developer/technicalArticles/J2SE/Desktop/sorted_jlist/index.html
    When I sort the data from the table, I need to sort the data from the list, too.
    My ideea is to make the Jlist an Observer for the Jtable.
    My questions are:
    1.     How can I find if the sorter makes an ASCENDING or DESCENDING ordering?
    2.     How can I find what the column that is ordered?
    Or if you have any idea on how can I do the ordering on Jlist to be simultaneous to Jtable .
    Please help!
    Thank you

    Oh what the hell:
    Sun's basic Java tutorial
    Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    http://javaalmanac.com. A couple dozen code examples that supplement The Java Developers Almanac.
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's Thinking in Java (Available online.)
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java. This one has been getting a lot of very positive comments lately.

  • Help with connecting JTable to northWind database

    hi
    actually i want to connect to products table then display it on JTable automatically.
    Now i've got the connecting code , but i'm not sure how and where code for displaying that data from the northwind table onto a Jtable with
    all the calumnNames and rows should be
    Thanks in advance

    this a re-arrangment of the code, i've tried this from one of the posts
    but still, it doesn't show nothing
    <code>
    tableData = new Vector();
    Vector titles = new Vector();
    int currentRow = 0;
    try
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); // load the driver
    conn = DriverManager.getConnection ("jdbc:microsoft:sqlserver://213.107.6.45;user=foo;password=foobar");
    // connect to SQL server
    conn.setCatalog("Northwind");
    // choose the database
    Statement stmt = conn.createStatement();
    // create an SQL statement
    String query = "SELECT * FROM Products;";
    table = stmt.executeQuery(query);
    ResultSetMetaData md = table.getMetaData();
    // get the meta data
    final int numberOfColumns = md.getColumnCount();
    // Vector columnNames = new Vector();
    // for(int i = 0; i < numberOfColumns; i++)
    // columnNames.add(md.getColumnName(i+1)); //indexed from 1, not 0
    // Iterator it = columnNames.iterator();
    // int i = 30;
    if(table.next())
    //rowData(table.getObject(1).toString());
    //jTextFieldField2.setText(table.getObject(2).toString());
    Vector rowVector = new Vector();
    for (int currentCol = 1; currentCol < numCols; currentCol++)
    Object obj = table.getObject(currentCol);
    rowVector.addElement(obj);
    //rowVector.add(table.getString (currentCol + 1));
    tableData.addAll(rowVector);
    //tableData.addElement(rowVector);
    //currentRow++;
    for (int currentCol=1; currentCol<= numCols ; currentCol++)
    titles.addElement(md.getColumnLabel(currentCol));
    // Close connection to database
    stmt.close();
    conn.close();
    }//end try
    catch (Exception ex)
    JOptionPane.showMessageDialog(null, ex.getMessage());
    }// end catch
    JTable table = new JTable(tableData,titles);
    JScrollPane scrollpane = new JScrollPane(table);
    this.getContentPane().add(scrollpane);

  • Help with editing a cell in a JTable. DESPERATE

    Hi! Is there someone out there that could help with some source code for editing a cell in my JTable when I run it as an applet??
    It works fine when I run it as an application.
    I manage to select the row and write a number in it, but I can't get out of the cell (it seems that the program stops??). I want to enter an integer in a cell and when I click enter or with the mouse in an other cell the value that I enter should update some other cell( multiply the entered value with some fixed number and update a cell in a second coloumn)
    I am really desperate now..... I have thought about using a MouseListener....
    I am using a tablemodel that is from AbstractTableModel.

    Are you using some cell editors?
    While converting inside them, you might be getting some exceptions (like parseexception)which is stopping you from proceeding further.
    Are you using your own tablemodel with custom datatypes?
    Hope this helps,
    Ramkumar

  • Can't remove second display with 8800 GT. please help! this is frustrating!

    I have dealt with this problem for a long time now, but having just bought a wacom tablet, I need to finally resolve it and I hope someone here can help because I am at my end with it. I just can't think of anything else.
    I have a 8800 GT video card in a Mac Pro. All software is updated.
    I have a 30inch apple cinema display, and was using it solo for a long time, then for a project, I hooked an old LCD monitor vida the VGA to DVI adapter to the second monitor slot on the card, and had both monitors running in the extended desktop mode. Everything worked fine.
    The problem is, now that I want to get rid of the other monitor, my cinema display does not want to run solo anymore. I have tried rebooting with only the cinema display plugged in, I have tried switching ports on the card (both with and without rebooting), and I have tried unplugging the unwanted monitor. When I do ANY of these, the cinema display goes blue, then black, and the light on the front blinks three times over and over.
    It is as tho the video card does not want to autodetect the displays, nor does it want to reset any settings and run without both monitors in extended mode. And since OSX does not give specific software for the video card, I am limited in displays to make any real changes. There is no option for turning off extended desktop, only mirroring the displays (which, yes, when I choose it then unplug the other display results in the same problem of no picture).
    My wacom tablet uses the tablet as being the screen from corner to corner, so obviously with the extended display, the center of the tablet is not the center of the monitor and it makes it impossible to use easily.
    Please, if anyone has any ideas for me, I am begging for help. This is frustrating to no end!!
    Thanks in advance.

    Buzz,
    thanks for the help. I especially want to thank you for being the first person to reply a post of mine on this subject ever (on multiple help boards as well).
    Unfortunately what you told me to do still didn't work.
    When I re-mirror and then un-mirror the displays it puts it back into extended mode. and when I unplug the second monitor, the HD display shuts down and goes black. it will not turn back on (even with a reboot) until I have something plugged into the other port, at which time it goes back to extended mode.
    This is really frustrating, and the first time I have felt helpless with my mac. I try support and they of course tell me they can not help me since the monitor's extended warranty ran out...even tho the computer's warranty is still up and this is of course a video card problem, not monitor.
    I'm about to give up and either reinstall EVERYTHING on this **** computer (which will result in me losing a lot of editing add-ons and other programs I bought but stupidly can't remember where I got them from) or just throw the whole thing in the trash. (heh yes, I am that frustrated). :/

  • Help with Filtering a JTable by multiple columns

    Hi everyone, I need some help with filtering a JTable.
    Basically I have five columns in my table and five text fields for Username, First Name, Last Name, Address and Phone Number.
    What I need to do is have each text field filter the column it is assigned to. So if the table was
    So if I put 'foo' into the username field and two users have a username containing 'foo' they stay on the table, but if i also enter text in first name, say 'john' and only one of those entries has a first name of 'john', the other disappears.
    I'm probably not explaining that very well so let me know if you need clarification.
    I found this code (which I assume works correctly) but I don't know how to interface it with my other class that displays the JTable
    import javax.swing.RowFilter;
    public class UsersFilter extends RowFilter {
         private String[] filters;
         public UsersFilter(String uName, String fName, String lName, String address, String phone) {
              filters = new String[]{uName, fName, lName, address, phone};
        public void setFilter(int column, String filter) {
            if(column < filters.length)
                filters[column] = filter;
        public boolean include(Entry entry) {
            boolean result = true;
            for (int i = 0; i < filters.length; i++) {
                if (result && !(filters.equals("")) ) {
    String v = entry.getValue(i).toString();
    result = v.startsWith(filters[i]);
    return result;

    dbuvid wrote:
    Hi everyone, I need some help with filtering a JTable.For 1.6+, set a RowSorter (which can also do filtering). Details in the 1.6 JavaDocs for JTable.

  • JTable - Help with updating a Text File

    Hi all,
    I've been fighting this for a few days. I am trying to update a Text File with my JTable.... Displaying the data works great but when I try to edit a cell/field on the gui, I'm bombing out...... My text fiel is a small user control file with Id, Name,
    Date, etc etc with the fields delimited with a "|".... I have built an Abstract Data Model (see below).... and I think my problem is in the setValueAt method.......
    Thanks so much in advance!!!!
    Mike
    code:
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    import java.io.*;
    import java.util.*;
    public class DataFileTableModel extends AbstractTableModel {
    protected Vector data;
    protected Vector columnNames ;
    protected String datafile;
    public DataFileTableModel(String f){
    datafile = f;
    initVectors();
    public void initVectors() {
    String aLine ;
    data = new Vector();
    columnNames = new Vector();
    try {
    FileInputStream fin = new FileInputStream(datafile);
    BufferedReader br = new BufferedReader(new InputStreamReader(fin));
    // extract column names
    StringTokenizer st1 =
    new StringTokenizer(br.readLine(), "|");
    while(st1.hasMoreTokens())
    columnNames.addElement(st1.nextToken());
    // extract data
    while ((aLine = br.readLine()) != null) { 
    StringTokenizer st2 =
    new StringTokenizer(aLine, "|");
    while(st2.hasMoreTokens())
    data.addElement(st2.nextToken());
    br.close();
    catch (Exception e) {
    e.printStackTrace();
    public int getRowCount() {
    return data.size() / getColumnCount();
    public int getColumnCount(){
    return columnNames.size();
    public String getColumnName(int columnIndex) {
    String colName = "";
    if (columnIndex <= getColumnCount())
    colName = (String)columnNames.elementAt(columnIndex);
    return colName;
    public Class getColumnClass(int columnIndex){
    return String.class;
    public boolean isCellEditable(int rowIndex, int columnIndex) {
    return true;
    public Object getValueAt(int rowIndex, int columnIndex) {
    return (String)data.elementAt( (rowIndex * getColumnCount()) + columnIndex);
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    Vector rowVector=(Vector)data.elementAt(rowIndex);
    rowVector.setElementAt(aValue, columnIndex);
    fireTableCellUpdated(rowIndex,columnIndex);
    // return;
    }

    No, the DefaultDataModel does not update the physical data file. It is just used to store the data as you type in the table cells.
    The code from above is used to read data from a file and populate the DataModel.
    Now you need to write another routine that will take the data from the DataModel and write it to your file. I have never actually done this but I think the code would be something like:
    int rows = table.getModel().getRowCount();
    int columns = table.getModel().getColumnCount();
    //  Write column headers
    for (int j = 0; j < columns; j++)
         TableColumn column = table.getColumnModel().getColumn(j);
            Object o = column.getHeaderValue();
         writeToFile( o.toString() + "|" );
    writeToFile( "\n" );
    // Write each row
    for (int i = 0, i < rows; i++)
        for (int j = 0, j < columns; j++)
            Object o = table.getValueAt(i, j);
            writeToFile( o.toString + "|" );
        writeToFile( "\n" );
    }If you need to update the file whenever data in a cell changes, then you could extend the DefaultTableModel and override the setValueAt() method to also write the contents of the DataModel to a file. But this is a lot of overhead since it rewrite the entire file for every cell change.

  • Help with add file name problem with Photoshop CS4

    Frustrating problem: Help with add file name problem with Photoshop CS4. What happens is this. When I am in PS CS4 or CS3 and run the following script it runs fine. When I am in Bridge and go to tools/photoshop/batch and run the same script it runs until it wants interaction with preference.rulerunits. How do I get it to quit doing this so I can run in batch mode? Any help is appreciated. HLower
    Script follows:
    // this script is another variation of the script addTimeStamp.js that is installed with PS7
    //Check if a document is open
    if ( documents.length > 0 )
    var originalRulerUnits = preferences.rulerUnits;
    preferences.rulerUnits = Units.INCHES;
    try
    var docRef = activeDocument;
    // Create a text layer at the front
    var myLayerRef = docRef.artLayers.add();
    myLayerRef.kind = LayerKind.TEXT;
    myLayerRef.name = "Filename";
    var myTextRef = myLayerRef.textItem;
    //Set your parameters below this line
    //If you wish to show the file extension, change the n to y in the line below, if not use n.
    var ShowExtension = "n";
    // Insert any text to appear before the filename, such as your name and copyright info between the quotes.
    //If you do not want extra text, delete between the quotes (but leave the quotes in).
    var TextBefore = "Lower© ";
    // Insert any text to appear after the filename between the quotes.
    //If you do not want extra text, delete between the quotes (but leave the quotes in).
    var TextAfter = " ";
    // Set font size in Points
    myTextRef.size = 10;
    //Set font - use GetFontName.jsx to get exact name
    myTextRef.font = "Arial";
    //Set text colour in RGB values
    var newColor = new SolidColor();
    newColor.rgb.red = 0;
    newColor.rgb.green = 0;
    newColor.rgb.blue = 0;
    myTextRef.color = newColor;
    // Set the position of the text - percentages from left first, then from top.
    myTextRef.position = new Array( 10, 99);
    // Set the Blend Mode of the Text Layer. The name must be in CAPITALS - ie change NORMAL to DIFFERENCE.
    myLayerRef.blendMode = BlendMode.NORMAL;
    // select opacity in percentage
    myLayerRef.opacity = 100;
    // The following code strips the extension and writes tha text layer. fname = file name only
    di=(docRef.name).indexOf(".");
    fname = (docRef.name).substr(0, di);
    //use extension if set
    if ( ShowExtension == "y" )
    fname = docRef.name
    myTextRef.contents = TextBefore + " " + fname + " " + TextAfter;
    catch( e )
    // An error occurred. Restore ruler units, then propagate the error back
    // to the user
    preferences.rulerUnits = originalRulerUnits;
    throw e;
    // Everything went Ok. Restore ruler units
    preferences.rulerUnits = originalRulerUnits;
    else
    alert( "You must have a document open to add the filename!" );

    you might want to try the scripting forum howard:
    http://www.adobeforums.com/webx?13@@.ef7f2cb

  • The best way to get help with logic

    I was posting in a thread on support for logic which appears to have been deleted. anyway, what I was going to say I think is useful info for people, so I'm going to post it anyway. to the mods - it doesn't contain any speculation about policies or anything like that. just an explanation of my views on the best way to deal with issues people have with logic, which I think is a valuable contribution to this forum.
    I think there's a need for perspective. when you buy an apple product you get 90 days of free phone support to get everything working nice and neat. you can call them whenever, and you could actually keep them on the phone all day if you wanted, making them explain to you how to copy a file, install microsoft office, or any number of little questions no matter how simple - what is that red button thingy in my window for?.. on top of that, you've got a 14 day dead on arrival period (or 10 days I can't remember) in which if your machine has any kind of hardware fault whatsoever it's exchanged for a totally new one, no questions asked. a lot of people complain that applecare is overpriced.. and if you think of it just as an extended warranty, then it is a little pricey. but if you are someone that could use a lot of phone support, then it's actually potentially a total bargain. the fact that 2 or more years after you bought a computer, you could still be calling them every single day, asking for any kind of advice on how to use anything on the machine, is quite something. many people on this forum have had problems when they made the mistake of upgrading to 10.4.9 without first creating a system clone or checking first with their 3rd party plug in vendors to make sure it was ok. so, with apple care, you could call them and keep a technician on the phone _all day_ talking you through step-by-step how to back up all of your user data, how to go through and preserve your preferences and any other specific settings you might not want to lose, and then how to rollback to an earlier OS version.. they'll hold your hand through the whole thing if you need them to.
    as for applecare support for pro apps like logic, I'd be the first person to agree that it's not great for anyone except beginners and first time users. if you look at what it takes to get even the highest level of logic certification, it's all pretty basic stuff. and logic doesn't exist in a vacuum, there is an entire universe of 3rd party software and hardware, as well as studio culture and advanced user techniques that are going to be totally invisible to some poor phone support guy at apple that did a logic 101. but it's not hard to see that apple are trying to promote a different kind of support culture, it's up to you to decide whether you want to buy into it or not.
    the idea is that they are able to provide basic setup support for new users, including troubleshooting. because it's a simpler level of support, at least they can do this well. so there's no reason why any new user with say a new imac and logic can't get up and running with the 90 days of phone support they get for free.
    but the thing is, for extremely high end pro users it's a different matter altogether. pro use of logic within the context of say, a studio or a film composition scenario is a very different world. it's almost a nonsense to imagine that apple could even hire people capable of giving useful support for this end of the spectrum, over the phone. there are so many variables, and so many things that require a very experienced studio person or in-work composer to even begin to understand the setup, let alone troubleshoot it. and it's a constantly evolving world, you actually have to be working in it and aware of developments on 3rd party fronts as well as changes in hardware.. not to mention even changes in the culture of studio production and the changed expectations that come from that. there's no way some poor little guy sitting at a help desk at apple can even hope to be privy to that kind of knowledge. it's already good enough that they don't outsource their support staff to india, let alone go out to studios and hire the very people with the skills that should be staying in the studio! not answering phones for apple.
    so, given this reality.. companies have two choices. they can either offer an email based support ticket system, which others do. but in my opinion.. this can just be frustrating and only a half-solution. sure you 'feel' like you are getting a response from the people that make the software and therefore must know it.. but it's not really the case due to what I said above. DAWs don't exist in a vacuum, and so much of what you need to understand to help people requires an intimate knowledge of the music industry in which they are working. you still won't get that from steinberg, even if they sort of answer your emails. the other problem is that this kind of system can mean sporadic answers, a lot of tail-chasing, and quite often you won't get an answer that helps you in the end anyway.
    the other model is to foster a strong user support culture. some people react in the wrong way to this idea.. they just think it's a big brush off from the manufacturer, saying we don't care, go sort it out yourselves.. but this isn't true. apple has a classification for pro resellers called 'apple solutions expert - audio'. what this means is that these dealers are recognised as audio specialists and they can receive extra support and training from apple for this. but more importantly than this.. most of them are music stores, or pro gear dealerships that are also mac and logic dealers. they already employ people that have worked or do work in the music industry, and are constantly on top of all of this stuff. apple encourages these dealers to run workshops, and to provide expert sales advice in the very niche area that logic is in, which they can do far better than some generic apple store ever could. but most importantly, they are encouraged to offer their own expert after-sales support and whatever other value-adding expertise they can, to get sales. because margins in computer gear are so tight nowadays, discounting is not really a viable option for these dealers to guarantee getting musicians to buy computers and logic setups from them. the only companies that can entice people with a lower price a big online wholesalers or big chain stores. so the best idea for these niche expert stores to get sales is to offer you their own experts to help with configuration, ongoing support and to generally make it a better idea that you bought your system from them rather than from some anonymous online store. I can see the wisdom of this.. it puts the support back out there on the ground where it's needed, and also where it can work best. apple could never hope to offer the same level of expertise in helping a film composer work through some issues with a specific interface or some highly specific issue they have with getting a task done. no big software manufacturer could do this anywhere near as well as people out there that have worked in studios or currently do work in studios. so in my opinion it's a far better model to foster this kind of support culture, along with training courses, books and training video support. also user forums like this one are possibly one of the most valuable ports of call anyone could ask for. apple couldn't replicate this with their own staff, even if they tried. and even if they made a system where some of the people close to logic development were able to answer emails, it would still be nowhere near as useful, as rapid or as capable of being up to speed with logic use out in the real world with 3rd pary gear, as any of these other methods are.
    the only thing I think they could do better would be to publish a list of known bugs which are officially recognised. this would help everyone and put an end to a lot of wasted time and speculation on if something is a bug totally to do with logic, or if it's a specific issue raised by a particular configuration.
    but really, in my view, a 3rd party support and training culture through a combination of specialist dealers, consultants that literally run a business setting up computers for pro-users and helping them keep it all working, online user-to-user forums and published materials really are the way forward.

    In all honesty this is currently the 3rd "logicboard" (motherboard)
    in my powerbook due to a design flaw regarding the 2nd memory slot....
    Yep. Mine failed five weeks after I bought it. However, I bought it for work and couldn't afford being without it for four weeks while they fixed it, so I had to live with it. My serial number did not entitle me to a replacement either, post Applecare.
    My firewire ports have burnt out from a third-party defective device (no hot-plugging involved)
    My screen is blotchy (my PW serial number did not entitle me to a replacement).
    My battery serial number did not entitle me to a replacement, and is not that good these days.
    My guaranteed Powerbook-compatible RAM is actually not, causing RAM related problems, most notably these days meaning that as soon as I switch to battery power, the laptop crashes, so I can only use mains power. The company I bought it from stopped taking my calls and wouldn't replace it after they replaced it once, so I'm stuck with it. And of course, only one ram slot is working, so I can't even use my original stick in the first slot, which would shift the dodgy stuff away from the lower system area.
    My power supply failed at the weak spot and caught fire. I managed to break apart the power supply and recable it so I didn't have to buy a new power supply, although the connection at the laptop end is loose (all the more fun that as soon as power is lost, the laptop crashes - see above). The power supply is held together with gaffa tape. Silver gaffer tape though, so it's still kind of 'Appley"...
    My internal hard drive is dying - four or five times now it clicks and won't power up, causing the laptop to die.
    One foot has fallen off (but glued back on).
    The lid is warped.
    The hinge is loosish.
    The S-Video adaptor cable is intermittent.
    But aside from all that, I have looked after it well, and I love it to death. Just as well, because it doesn't look like it will be that long...
    But it still "just works". Apart from the battery power obviously. And the ram slot. And the ram. And the screen. And the hard drive. And the firewire ports. And the feet.
    But everything apart from the main board, the screen, the case, the hard drive and the power supply works fine. So thats... er..
    Hmm.

Maybe you are looking for