Focus held hostage by JTable... send help.

Dear you,
I'm making a gui with a JTable, some textfields, buttons and comboboxes.
I'd like to have one of the buttons get the focus when I open the gui but everytime I end up with the JTable getting the focus.
I've used the requestfocus method everywhere I could fit it, in the main, in, around , before, and after making the button etc. I've used tired using the componentlistener too but didn't have any success.
Anybody got an idea what I can try?
Cheers.
Hilldog

You can only request focus on a component that is visible....make sure that you request the focus for the desired button only after the entire gui is visible.
;o)
V.V.

Similar Messages

  • BIG PROBLEM!  volume alias trashed files held hostage please help

    I have no idea how this happened but...
    somehow the Invisible Alias(s) to all of my internal HD's (except my boot disc)
    were placed in the trash.
    I discovered this when I was emptying the trash and a few of the files could not be
    trashed I looked at the names and they were my Internal HD volumes
    Needless to say this freaked me out
    so when looking inside the trash nothing was there.
    Doing a terminal command I made all invisible files visible and sure enough
    there is a folder in the trash entitled
    "Volumes"
    inside of Volumes lives alias(s) for all of my non boot disks
    to make matters worse when I go to the HD's which are still visible on my desktop
    all of the files give a " cannot be opened" message
    The files which are held hostage are for my Doc film I have been working on for
    1.5 years.
    I have tried to verify and repair the disks using both Disk Utility and Drive Genius
    but they both give a " Disk cannot be unmounted" error
    I have not restarted the computer (as I am afraid)
    and I don't know what to do
    it would appear that the info is there
    just help hostage...
    Please advise
    I have attached a couple of links to snaps so you can see what I mean.
    http://i11.photobucket.com/albums/a199/terraform/HDProblem2.jpg
    http://i11.photobucket.com/albums/a199/terraform/aliasMissingCannotUnmount.jpg
    any info is welcome
    thanks

    I found some help on another forum
    and basically I did need to move my volumes out of the trash via
    a terminal command that put them at the root level.
    I still have no idea how my invisible alias' for my HD's could have ended up there
    but at least things seem fine now
    thanks for your response by the way.

  • I switched to a samsung galaxy 5 AND MY friends w iphones cannot get my text because i message is holding them hostage!!! help

    I switched to a samsung galaxy 5 AND MY friends w iphones cannot get my text because i message is holding them hostage!!! help!
    Ive done everything that a t and t have told me to do. text 48369  ive turned off i message on all devices and i still can't recieve text from iphone friends

    ksfm3 wrote:
    I did all of those things prior to posting on how to fix it. None of these worked. I changed my password.
    For what silly reason would any intelligent person believe that changing an Apple ID password would have any affect on iMessage?
    From the link provided:
    If you can't access your iPhone, you no longer have it, or you can't deactivate iMessage after you try the above steps, please contact Apple Support.
    Performing these tasks won't deregister iMessage:
    Logging into My Support Profile and changing your password or removing your phone number
    Sending an SMS text message STOP to 48369
    Resetting your network settings
    Changing your Apple ID password

  • Are my numbers documents really being held hostage until I pay to download a new version of Numbers?

    I'm confused...are my numbers documents really being held hostage until I pay to upgrade for a system that I thought I already had/

    Figured it out.  I had downloaded the newest version in November and evidently had both versions in my dock and for some reason it was fine until today when it decided I had to delete the old version off the dock in order for it to work.  All is well.

  • I downloaded the whatsapp app to my new iphone, and when i wanted to create an account, i could not, it said, unable to send message. I downloaded it several times later, but i still could not create the account, it always said, unable to send, help

    I downloaded the whatsapp app to my new iphone, and when i wanted to create an account, i could not, it said, unable to send message. I downloaded it several times later, but i still could not create the account, it always said, unable to send, help

    I recommend reaching out to Citrix via their support system -
    http://www.citrix.com/products/receiver/resources-and-support.html
    The receiver app has a specific list of servers it's compatible with, if the server is not on the list the app won't work in OS X.
    http://support.citrix.com/servlet/KbServlet/download/28492-102-671726/Receiver%2 0for%20Mac%2011%204%20FAQ%20v1_1235.pdf
    Do you know what server you're connecting to?

  • POP3 Business E-Mail CANNOT SEND HELP PLEASE

    POP3 Business E-Mail CANNOT SEND HELP PLEASE
    PLEASE HELP I have two business email accounts an cannot send with either. Just lost a big contract because I answered contract questions and then I find out it did not send 3 days later. I have always had (hide sent emails enabled on all previous BlackBerry phones) We need help. FREE HELP NOT COST PER CALL BASIS. This is BlackBerry's problem not ours.

    Hey all,
    If you have your network service providers SMTP server inputted and still experiencing trouble.  Then we suggest contacting us so we can gather logs to find the root cause.
    Please contact your network service provider and ask to be transferred to BlackBerry.
    This will help us resolve this new issue.
    Thanks
    -ViciousFerret
    Come follow your BlackBerry Technical Team on Twitter! @BlackBerryHelp
    Be sure to click Like! for those who have helped you.
    Click  Accept as Solution for posts that have solved your issue(s)!

  • I forgot my security question answers, but the email address they send help to is wrong.  How can I change the recovery email address?

    I forgot the answers to my security questions.  When I go to the link for help remembering my security questions it sends the email to an email address that is not mine.  And I don't know how to make it send to one of the two correct email addresses I have entered.  Any suggestions?

    You need to ask Apple to reset your security questions; this can be done by clicking here and picking a method, or if your country isn't listed, filling out and submitting this form.
    They wouldn't be security questions if they could be bypassed without Apple verifying your identity.
    (108925)

  • How do I add a JCheckBox to a JTable - URGENT HELP NEEDED

    Hello All,
    This is kicking my butt. I need to create a JTable that I can dynamically add and delete rows of data to and this table must contain a JCheckBox which I can read the value of. I've been able to find examples out there that provides the ability to have a JCheckBox in the JTable, but do not also provide the function to add / delete rows from the JTable. I need to have both funtions in my table. Can somebody out there please help me with this?
    Here's a simple example that I'm working with as a test to figure this out. This example has the functionality to add rows of data.
    Thanks in advance.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.JFrame;
    import javax.swing.JTable;
    import javax.swing.table.*;
    public class TableTest extends JFrame implements ActionListener
         JButton btnAdd;
         BorderLayout layout;
         DefaultTableModel model;
         public static void main(String[] args)
              TableTest app = new TableTest();
              app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public TableTest()
              super("Table Example");
              layout = new BorderLayout();
              Container container = getContentPane();
              container.setLayout(layout);
              btnAdd = new JButton("Add");
              btnAdd.addActionListener(this);
              model = new DefaultTableModel();
              JTable table = new JTable(model);
              // Create a couple of columns
              model.addColumn("Col1");
              model.addColumn("Col2");
              // Append a row
              model.addRow(new Object[] { "v1", "v2" });
              model.addRow(new Object[] { "v3", "v4" });
              JScrollPane scrollPane = new JScrollPane(table);
              container.add(btnAdd, BorderLayout.NORTH);
              container.add(scrollPane,BorderLayout.CENTER);
              setSize(300, 200);
              setVisible(true);
         public void actionPerformed(ActionEvent e)
              if (e.getSource() == btnAdd)
                   model.addRow(new Object[]{"Test", new Boolean(true)});
    }

    I got it, I added the public Class getColumnClass to new DefaultTableModel(). Here it is for your viewing pleasure.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.JFrame;
    import javax.swing.JTable;
    import javax.swing.table.*;
    public class TableTest extends JFrame implements ActionListener
         JButton btnAdd;
         BorderLayout layout;
         DefaultTableModel model;
         JTable table;
         public static void main(String[] args)
              TableTest app = new TableTest();
              app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public TableTest()
              super("Table Example");
              layout = new BorderLayout();
              Container container = getContentPane();
              container.setLayout(layout);
              btnAdd = new JButton("Add");
              btnAdd.addActionListener(this);
              model = new DefaultTableModel()
                   public Class getColumnClass(int col)
                        switch (col)
                             case 1 :
                                  return Boolean.class;
                             default :
                                  return Object.class;
              table = new JTable(model);
              // Create a couple of columns
              model.addColumn("Col1");
              model.addColumn("Col2");
              // Append a row
              model.addRow(new Object[] { "v1", new Boolean(false)});
              model.addRow(new Object[] { "v3", new Boolean(false)});
              JScrollPane scrollPane = new JScrollPane(table);
              container.add(btnAdd, BorderLayout.NORTH);
              container.add(scrollPane, BorderLayout.CENTER);
              setSize(300, 200);
              setVisible(true);
         public void actionPerformed(ActionEvent e)
              if (e.getSource() == btnAdd)
                   model.addRow(new Object[] { "Karl", new Boolean(true)});

  • How can I surrend the focus of Jcombobox in Jtable?

    There are a jcombobox for each row of a jtable. I can click each cell to choose some value from the item list of jcombobox.
    The problem is, when I import data into the table by changing the values of tablemodel, if some cell still hold the focus, the table won't show the new imported data for this specific cell, but keep the old one. Others cells without focus work well.
    For example, originally I choose a "Monday" from the combobox with focus. When I import new data (by clicking some button), for instance "Tuesday", the new data doesn't show in the focused cell.
    So, how can I surrend the focus of this specific cell to other components, for instance, some button?

    In your action for your button, before you update your table with the imported information do the following:
    if (myTable.isEditing())
        myTable.getCellEditor().stopCellEditing();
    }

  • Small Problem in JTable,Please help me..

    hi ,i am doing college project & hv some problem
    Problem : (code is given below ) as i run program ,i am not able to edit cells of table one by one.when i write value in any cell & then if i edit other cell, then previous cell's value become come to initial value
    This problem is requires small modification ,plz help(unless my project will not exceed further )
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    //import javax.swing.JScrollPane;
    //import javax.swing.JTable;
    import java.util.*;
    import java.util.List;
    public class v_swing1 extends JFrame
         {     JButton b1;
              Container cont;
              JTable table ;
              TableModel myData ;
              TextField t1;
              private LocalTableModel theTableModel;                         //t1.setEditable(false);
              private List<Row> theRows;
         private class Row {
              private int theFirstField;
              private String theSecondField;
              public Row(int aFirstField, String aSecondField) {
                   theFirstField = aFirstField;
                   theSecondField = aSecondField;
              public int getFirstField() {
                   return theFirstField;
              public String getSecondField() {
                   return theSecondField;
         private class LocalTableModel extends AbstractTableModel {
              public String getColumnName(int column) {
                   if (column == 0) {return "name";}
                   else      {  return "age";}     }
              public Class getColumnClass(int columnIndex) {
              if (columnIndex == 0) { return Integer.class;}
                   else      {   return String.class;   }
              public boolean isCellEditable(int rowIndex, int columnIndex) {
                   return true;     }
              public int getRowCount() {
                   return theRows.size();
              public int getColumnCount() {
                   return 2;
              public Object getValueAt(int rowIndex, int columnIndex) {
                   Row row = theRows.get(rowIndex);
                   if (columnIndex == 0) { return row.getFirstField();}
                   else { return row.getSecondField(); }
         public v_swing1(String theLable)
              b1=new JButton();
              t1=new TextField(4);
              theRows = new LinkedList<Row>();
              theTableModel = new LocalTableModel();           
              table = new JTable(theTableModel);
              setLayout(new FlowLayout());
              JPanel thePan=new JPanel();
              thePan.add(t1);
              thePan.add(b1);
              Container cont= getContentPane();
              cont.setLayout(new FlowLayout());
              cont.add(thePan);
              b1.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent e)
                        load();
                        reload();
                             //x=Integer.parseInt(t1.getText());
                        //t1.setText(" ");          
                                            // table = new JTable(2,3);     
                                  //table.setRowSelectionAllowed(true);
                                  // table.setColumnSelectionAllowed(true);
                                  //table.setCellSelectionEnabled(true);
              cont.add(new JScrollPane(table));
              load();               
         private void reload(){
              int l =Integer.parseInt(t1.getText());
              for(int size = theRows.size();size<=l;size++)
              theRows.add(new Row(size, " "+size));
              theTableModel.fireTableRowsInserted(size, size);
         private void load(){
              int size = theRows.size();
              if (size > 0) {
                   theRows.clear();
                   theTableModel.fireTableRowsDeleted(0, size - 1);
              theRows.add(new Row(0, "" + 0));     
              theTableModel.fireTableRowsInserted(0, 1);
         public static void main(String args[])
              v_swing1 obj=new v_swing1("hay");
              obj.addWindowListener(new WindowAdapter(){
              public void windowClosing(WindowEvent e) {
              System.exit(0);
              obj.setSize(400,400);
              obj.setVisible(true);
         }

    Please cut and paste the exact message in a reply.
    Most likely, your CLASSPATH is wrong.
    Larry

  • Im having problems with Photobucket..sending my customized photos to friends on myspace. They claim it works for them But the albums freeze and i cannot send HELP...

    problem with photobucket..When i get ready to send out comments to myspace from my customized albums..it freezes and im not able to send. They say it works for them and gave me a long line of things to do..I have attempted that..it still doesnt work..Im aggravaded beyond belief..

    THANK YOU SO MUCH stussaar!
    My Mother did what you said for the Spam and my number was in there about 100 times. She deleted all them. Deleted me as a contact and then rebooted, then she text me and I text her back and I went right into the Spam again. I told her to tell TMobile this so then can maybe help and remove my number from Spam on their end.\
    Thanks you so much! you got us 99.999 % the way there!!
    I appreciate your help!!!!  I hope this worked also for your problem!!
    Thanks again!!!
    Mike

  • Problem About Focus transfer in swing JTable Cell

    I open a JDialog in KeyPressed Event of Cell of the JTable,when the JDialog closed, I cannot set the Focus to next Cell in my code. the focus was set on the ToolBar(I don't write it in my code).
    key pressed
    void this_keyPressed(KeyEvent e) {
    String text = this.getText().trim();
    if(e.getKeyCode()==10 && text.trim().length()>0)
    wzdlg = new JDialog();
    Dimension dlgSize = wzdlg.getPreferredSize();
    wzdlg.setLocation(0,0);
    wzdlg.setModal(true);
    wzdlg.pack();
    wzdlg.show();
    //When JDialog Closed,Focus move to next cell
                   //table.editAt(0,1); //cannot getFocus
                   //following cannot get focus too
         Component comp = ((DefaultCellEditor)table.getCellEditor(0,1)).getComponent();
         if (comp instanceof javax.swing.JTextField) comp.requestFocus();               
    Why? How Can I do?

    Try calling prepareEditor after your editCellAt method. It would be like
    JTable.editCellAt(row, col);
    JTable.prepareEditor(theTextFieldComponent, row, col);
    Here, the text field component would be from the component editor. I would recommend you holding a reference than doing a getComponent. But, both may work.

  • Problem in JTable,Kindly help very urgent

    I am trying to add /remove rows from JTable whose first column is JButton and others are JComboBox's.If no rows are selected,new row is added at the end.If user selects some row & then presses insert button,new row is added below it.Rows can only be deleted if user has made some selection.I am also using Icon for the button of currently active row.But i am getting exception(ArrayIndexBounds)when i try to add/delete.May be proper refreshing is not taking place.Kindly help me,where i am making mistake.If any function is to be used.My code is as follows....It is running code
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import javax.swing.border.*;
    import java.util.*;
    public class JButtonTableExample extends JFrame implements ActionListener,TableModelListener
    JComboBox mComboLHSType = new JComboBox();
    JComboBox mComboRHSType = new JComboBox();
    JLabel mLabelLHSType = new JLabel("LHS Type");
    JLabel mLabelRHSType = new JLabel("RHS Type");
    JButton mButtonDelete = new JButton("Delete");
    JButton mButtonInsert = new JButton("Insert");
    JButton check = new JButton("check");
    JPanel mPanelButton = new JPanel();
    JPanel mPanelScroll = new JPanel();
    JPanel mPanelCombo = new JPanel();
    DefaultTableModel dm ;
    TableColumnModel modelCol;
    JTable table;
    JScrollPane scroll;
    int currentRow = -1;
    static int mSelectedRow = -1;
    EachRowEditor rowEditor;
    public JButtonTableExample()
    super( "JButtonTable Example" );
    makeForm();
    setSize( 410, 222 );
    setVisible(true);
    private void makeForm()
         this.getContentPane().setLayout(null);
         mLabelLHSType.setBounds(new Rectangle(26,5,71,22));
         mComboLHSType.setBounds(new Rectangle(83,5,100,22));
         mLabelRHSType.setBounds(new Rectangle(232,5,71,22));
         mComboRHSType.setBounds(new Rectangle(292,5,100,22));
         mPanelCombo.setLayout(null);
         mPanelCombo.setBorder(new LineBorder(Color.red));
         mPanelCombo.setBounds(new Rectangle(1,1,400,30));
         mComboRHSType.addItem("Constant");
    mComboRHSType.addItem("Variable");
    mComboRHSType.setSelectedIndex(0);
    mComboRHSType.addActionListener(this);
    mPanelCombo.add(mLabelLHSType,null);
    mPanelCombo.add(mComboLHSType,null);
    mPanelCombo.add(mLabelRHSType,null);
    mPanelCombo.add(mComboRHSType,null);
         mPanelButton.setLayout(null);
         mPanelButton.setBorder(new LineBorder(Color.green));
         mPanelButton.setBounds(new Rectangle(1,165,400,30));
         mButtonInsert.setBounds(new Rectangle(120,5,71,22));
         mButtonDelete.setBounds(new Rectangle(202,5,71,22));
         mButtonDelete.addActionListener(this);
    mButtonInsert.addActionListener(this);
    check.setBounds(new Rectangle(3,3,71,22));
    check.addActionListener(this);
    mPanelButton.add(mButtonDelete,null);
    mPanelButton.add(mButtonInsert,null);
    mPanelButton.add(check,null);
         dm = new DefaultTableModel()
              public boolean isCellEditable(int row, int col)
              if(row == 0 && col ==1)
                   return false;
              return true;
         dm.addTableModelListener(this);
         //dm.setDataVector(null,
                             //new Object[]{"Button","Join","LHS","Operator","RHS"});
         dm.setDataVector(new Object[][]{{"","","","",""}},
                             new Object[]{"","Join","LHS","Operator","RHS"});
         table = new JTable(dm);
         table.getTableHeader().setReorderingAllowed(false);
         table.setRowHeight(25);
         table.setRowSelectionInterval(0,0);
         rowEditor = new EachRowEditor(table);
         int columnWidth[] = {20,45,95,95,95};
         mPanelScroll.setLayout(null);
         mPanelScroll.setBorder(new LineBorder(Color.blue));
         mPanelScroll.setBounds(new Rectangle(1,28,400,135));
         scroll = new JScrollPane(table);
    scroll.setBounds(new Rectangle(1,1,400,133));
    mPanelScroll.add(scroll,null);
         modelCol = table.getColumnModel();
         for (int i=0;i<5;i++)
         modelCol.getColumn(i).setPreferredWidth(columnWidth);
         setCellTypes();
    this.getContentPane().add(mPanelCombo,null);
    this.getContentPane().add(mPanelScroll,null);
    this.getContentPane().add(mPanelButton,null);
    }//end of makeForm()
    private void setCellTypes()
         modelCol.getColumn(0).setCellRenderer(new ButtonCR());
         modelCol.getColumn(0).setCellEditor(new ButtonCE(new JCheckBox()));
         modelCol.getColumn(0).setResizable(false);
         setUpJoinColumn(modelCol.getColumn(1));
         setUpLHSColumn(modelCol.getColumn(2));
         setUpOperColumn(modelCol.getColumn(3));
         setUpRHSColumn(modelCol.getColumn(4));//By Default contains JTextField
    public void actionPerformed(ActionEvent ae)
         if (ae.getSource() == mButtonInsert)
              int currentRow = table.getSelectedRow();
              if(currentRow == -1)
                   int rowCount = dm.getRowCount();
                   if(rowCount == 0)
                        table.clearSelection();
                        dm.insertRow(0,new Object[]{"","","","",""});
                        mComboRHSType.setEnabled(true);
                        mButtonDelete.setEnabled(true);
                        dm.fireTableDataChanged();
                        table.setRowSelectionInterval(0,0);
                   else
                        table.clearSelection();
                        dm.insertRow(rowCount,new Object[]{"","","","",""});
                        dm.fireTableDataChanged();
                        table.setRowSelectionInterval(rowCount,rowCount);
              else
                   table.clearSelection();
                   dm.insertRow(currentRow+1,new Object[]{"","","","",""});
                   dm.fireTableDataChanged();
                   table.setRowSelectionInterval(currentRow+1,currentRow+1);
    if(table.getRowCount()>0)
         table.setValueAt(new String(""),0,1);
         if(ae.getSource() == mButtonDelete)
    int currentRow = table.getSelectedRow();
    if(currentRow != -1)
    table.clearSelection();
                   dm.removeRow(currentRow);
                   if(dm.getRowCount() == 0)
                        mComboRHSType.setEnabled(false);
                        mButtonDelete.setEnabled(false);
                   dm.fireTableDataChanged();
              else
              JOptionPane.showMessageDialog(null, "Select row first", "alert", JOptionPane.ERROR_MESSAGE);
    //always the first cell is empty and disabled
    if(table.getRowCount()>0)
         table.setValueAt(new String(""),0,1);
         if(ae.getSource() == check)
              int r = table.getSelectedRow();
              for(int i=1;i<5;i++)
                   Object obj = table.getValueAt(r,i);
                   System.out.println("Value is"+obj.toString());
         if(ae.getSource()==mComboRHSType)
              System.out.println(mComboRHSType.getSelectedItem().toString());
              if(table.getSelectedRow() == -1)
                        JOptionPane.showMessageDialog(null, "Select row first", "alert", JOptionPane.ERROR_MESSAGE);
                        mComboRHSType.setSelectedIndex(0);
                   else
                        if((mComboRHSType.getSelectedItem().toString()).equalsIgnoreCase("Constant"))
                             rowEditor.stopCellEditing();
                             table.setValueAt("",table.getSelectedRow(),4);
                             rowEditor.setEditorAt(table.getSelectedRow(), new DefaultCellEditor(new JTextField()));
                             table.getColumn("RHS").setCellEditor(rowEditor);
                        else if((mComboRHSType.getSelectedItem().toString()).equalsIgnoreCase("Variable"))
                        JComboBox comboBox = new JComboBox();
                        comboBox.addItem("Variable1");
                        comboBox.addItem("Constant1");
                        comboBox.addItem("Constant2");
                        rowEditor.stopCellEditing();
                        table.setValueAt("",table.getSelectedRow(),4);
                        rowEditor.setEditorAt(table.getSelectedRow(), new DefaultCellEditor(comboBox));
                        table.getColumn("RHS").setCellEditor(rowEditor);
    }//end of actionPerformed()
    public void tableChanged(TableModelEvent e)
              if(e.getType()==e.DELETE)
                   System.out.println("DELETE CALEED called##################)");
              if(e.getType()==e.INSERT)
                   System.out.println("INSERT CALEED called##################)");
    public void setUpJoinColumn(TableColumn joinColumn)
    JComboBox comboBox = new JComboBox();
    comboBox.addItem("AND");
    comboBox.addItem("OR");
    comboBox.addItem("NOT");
    joinColumn.setCellEditor(new DefaultCellEditor(comboBox));
    //Set up tool tips
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    joinColumn.setCellRenderer(renderer);
    //Set up tool tip for the header.
    TableCellRenderer headerRenderer = joinColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer)
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText("Click to see list of Join Conditions");
    public void setUpLHSColumn(TableColumn LHSColumn)
    JComboBox comboBox = new JComboBox();
    comboBox.addItem("Participant1");
    comboBox.addItem("Participant2");
    comboBox.addItem("Variable1");
    LHSColumn.setCellEditor(new DefaultCellEditor(comboBox));
    //Set up tool tips
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    LHSColumn.setCellRenderer(renderer);
    //Set up tool tip for the header.
    TableCellRenderer headerRenderer = LHSColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer)
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText("Click the sport to see Participants or Variables");
    public void setUpOperColumn(TableColumn operColumn)
    JComboBox comboBox = new JComboBox();
    comboBox.addItem("=");
    comboBox.addItem("!=");
    comboBox.addItem("Contains");
    operColumn.setCellEditor(new DefaultCellEditor(comboBox));
    //Set up tool tips
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    operColumn.setCellRenderer(renderer);
    //Set up tool tip for header.
    TableCellRenderer headerRenderer = operColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer)
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click to see a list of operators");
    public void setUpRHSColumn(TableColumn rhsColumn)
              rowEditor.setEditorAt(table.getSelectedRow(), new DefaultCellEditor(new JTextField()));
              rhsColumn.setCellEditor(rowEditor);
    //Set up tool tips
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    rhsColumn.setCellRenderer(renderer);
    public static void main(String[] args)
    JButtonTableExample frame = new JButtonTableExample();
    frame.addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent e)
    System.exit(0);
    }//end of program
    //Button as a renderer for the table cells
    class ButtonCR implements TableCellRenderer
         JButton btnSelect;
         public ButtonCR()
              btnSelect = new JButton();
              btnSelect.setMargin(new Insets(0,0,0,0));
         public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected,boolean hasFocus,int row,int column)
              if (column != 0) return null; //meany !!!
              return btnSelect;
    }//end fo ButtonCR
    //Default Editor for table
    class ButtonCE extends DefaultCellEditor implements ActionListener
         JButton btnSelect;
         JTable table;
         static int selectedRow = -1;
         public ButtonCE(JCheckBox whoCares)
              super(whoCares);
              btnSelect = new JButton();
              btnSelect.setMargin(new Insets(0,0,0,0));
              btnSelect.addActionListener(this);
              setClickCountToStart(1);
         public Component getTableCellEditorComponent(JTable     table,Object value,boolean isSelected,int row,int column)
              if (column != 0) return null; //meany !!!
              this.selectedRow = row;
              this.table = table;
              System.out.println("Inside getTableCellEditorComponent");
              return btnSelect;
         //public Object getCellEditorValue()
              //return val;
         public void actionPerformed(ActionEvent e)
              // Your Code Here...
              System.out.println("Inside actionPerformed");
              System.out.println("Action performed Row selected "+selectedRow);
              btnSelect.setIcon(new ImageIcon("capsigma.gif"));
    }//end of ButtonCE
    class EachRowEditor implements TableCellEditor
         protected Hashtable editors;
    protected TableCellEditor editor, defaultEditor;
    JTable table;
    * Constructs a EachRowEditor.
    * create default editor
    * @see TableCellEditor
    * @see DefaultCellEditor
    public EachRowEditor(JTable table)
              this.table = table;
         editors = new Hashtable();
         defaultEditor = new DefaultCellEditor(new JTextField());
         editor = defaultEditor;
         * @param row table row
         * @param editor table cell editor
         public void setEditorAt(int row, TableCellEditor editor)
         editors.put(new Integer(row),editor);
    public Component getTableCellEditorComponent(JTable table,Object value, boolean isSelected, int row, int column)
         //editor = (TableCellEditor)editors.get(new Integer(row));
         //if (editor == null)
         //     editor = defaultEditor;
         return editor.getTableCellEditorComponent(table,value, isSelected, row, column);
         public Object getCellEditorValue()
         System.out.println("getCellEditoeValue");
         return editor.getCellEditorValue();
         public boolean stopCellEditing()
         System.out.println("stopCellEditing");
         return editor.stopCellEditing();
         public void cancelCellEditing()
         System.out.println("cancelCellEditing");
         editor.cancelCellEditing();
    public boolean isCellEditable(EventObject anEvent)
    System.out.println("isCellEditable");
    selectEditor((MouseEvent)anEvent);
    return editor.isCellEditable(anEvent);
    public void addCellEditorListener(CellEditorListener l)
    System.out.println("addCellEditorListener");
    editor.addCellEditorListener(l);
    public void removeCellEditorListener(CellEditorListener l)
         System.out.println("removeCellEditorListener");
    editor.removeCellEditorListener(l);
    public boolean shouldSelectCell(EventObject anEvent)
    System.out.println("shouldSelect");
    selectEditor((MouseEvent)anEvent);
    return editor.shouldSelectCell(anEvent);
    protected void selectEditor(MouseEvent e) {
    int row;
    if (e == null) {
    row = table.getSelectionModel().getAnchorSelectionIndex();
    } else {
    row = table.rowAtPoint(e.getPoint());
    editor = (TableCellEditor)editors.get(new Integer(row));
    if (editor == null) {
    editor = defaultEditor;
    }//end of EachRowEditor

    Hello!
    Catch the exception in your event handler:
    try {
    } catch(Exception ex) { ex.printStackTrace(); }
    You can now isolate the wrong line ^;
    Next time if you post such a large code please use code and /code
    enclosed in brackets : []; (See http://forum.java.sun.com/faq.jsp#format)
    class A extends B {
          public void niceCode() {

  • Web service send help

    I have a problem that I hope has a simple answer, but I
    cannot for the life of me figure it out, hopefully someone out
    there can help me!
    I am accessing the following section of a wsdl:
    <s:element name="Login">
    <s:complexType>
    <s:sequence>
    <s:element minOccurs="0" maxOccurs="1" name="sUserName"
    type="s:string"/>
    <s:element minOccurs="0" maxOccurs="1"
    name="sUserPassword" type="s:string"/>
    <s:element minOccurs="1" maxOccurs="1"
    name="enIdentifier" type="tns:EnLoginIdentifiers"/>
    </s:sequence>
    </s:complexType>
    </s:element>
    <s:simpleType name="EnLoginIdentifiers">
    <s:restriction base="s:string">
    <s:enumeration value="User"/>
    <s:enumeration value="Manager"/>
    </s:restriction>
    </s:simpleType>
    So I make the call with:
    myWS.Login("userIDgoeshere","passwordgoeshere", ???)
    I am at a loss for what to put for ???, if it were a complex
    data type, I could use a dto to send the correct value over, but
    with this setup I am stumped. (And no, I can't just change the
    WSDL, it's out of my hands, unfortunately)
    If anyone could give an example how to make this work I would
    be very grateful, and if there is any other information I can give
    to clarify my issue, please let me know!
    Thanks in advance for any help!

    We need observe the security classification of the service, if it isn’t a risk maybe you don’t need authentication.
    However if security is needed, you can user a rule like that: With your service is a process service you should use authentication and authorization, but with your web service is a simple search (small granularity) you can attribute the rights to the web server (consumer) using a certified (x-509 for example).

  • Dynamically Updating JTable, please help

    I am trying to create an GUI for a java program I wrote to interface with motes running TinyOS. I am having some serious problems creating this because in the JTable tutorial everything is static so I can't figure out how I'm supposed to modify the table from my code. I'm basically reading packets coming in from the serial port and updating several data fields based on what is contained in the packet. I want certain cells in the JTable to reflect the changes that occur in the variables I have, sort of like a debugger would display, but in real time and at full run speed. I tried using the setValueAt function but the problem is the JTable is created in a static method and so I cannot call it from main. I tried moving the section of code that monitors the serial port and updates my data to the createAndShowGUI function, but unfortunately the table will not display unless this function returns, but the program will never return from this function if I move the code there and so I just get a completely grey JTable displayed. I have included the code below, sorry for the length of it but I need some help on this one, I was never taught java and am trying to learn this on my own for research purposes. As it stands now the only error generated by this code is from the following line:
    newContentPane.DataTable.setValueAt("asdfsa",1,1);
    I am not allowed access to newContentPane because it has been dynamically instantiated by createAndShowGUI and I cannot access it through main.
    I'd appreciate any help on this, thank you.
    package net.tinyos.tools;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JComponent;
    import javax.swing.ListSelectionModel;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.util.Date;
    import java.io.*;
    import net.tinyos.packet.*;
    import net.tinyos.util.*;
    import net.tinyos.message.*;
    public class BeaconListen extends JPanel {
    private static int MAX_NODES = 10;
         JTable DataTable;
         public BeaconListen(){
         super(new GridLayout(1,0));     
         Object[] ColumnNames = {"Node","PPS","Average PPS","Time Elapsed"};
         Object[][] Data= {
         {"0","","",""},
         {"1","","",""},
         {"2","","",""},
         {"3","","",""},
         {"4","","",""},
         {"5","","",""},
         {"6","","",""},
         {"7","","",""},
         {"8","","",""},
         {"9","","",""},
         DataTable = new JTable(Data,ColumnNames);
         DataTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
         JScrollPane scrollPane = new JScrollPane(DataTable);
    add(scrollPane);
    * Create the GUI and show it. For thread safety,
    * this method should be invoked from the
    * event-dispatching thread.
    private static void createAndShowGUI(){
    //Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);
    //Create and set up the window.
    JFrame frame = new JFrame("MoteData");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Create and set up the content pane.
    BeaconListen newContentPane = new BeaconListen();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.setContentPane(newContentPane);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
         if (args.length > 0) {
         System.err.println("usage: java net.tinyos.tools.BeaconListen");
         System.exit(2);
         public static void main(String args[]) {
         //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
                   PacketSource reader = BuildSource.makePacketSource();
         if (reader == null) {
         System.err.println("Invalid packet source (check your MOTECOM environment variable)");
         System.exit(2);
              int i, total = 0;
         int reset =1;
         int packetcount[] = new int[MAX_NODES];
         int PL[] = new int[MAX_NODES];
         int counter[] = new int[MAX_NODES];
         double RSSI[]= new double[MAX_NODES];
         int signalStrength=0;
         double strengthUnsigned=0;
         int Transition=0;
         int PPS=0;
         int FirstRun=1;
         int packetHold=0;
         double avgPacketCount[] = new double[MAX_NODES];
         int secondsElapsed=0;
         int averageReset=1;
         int totalPacketsReceived[] = new int[MAX_NODES];
         System.out.println("Node Listening");
         try {
         reader.open(PrintStreamMessenger.err);
         for(;;){
              byte[] packet = reader.readPacket();
         if(reset==1)
         for(i=0; i<MAX_NODES; i++)
              packetcount=0;
              PL[i]=0;
              counter[i]=0;     
              if(averageReset==1)
              secondsElapsed=0;
              avgPacketCount[i]=0;
              totalPacketsReceived[i]=0;
         reset =0;
         if(FirstRun==0)
         packetcount[packetHold]++;
         totalPacketsReceived[packetHold]++;
         PPS++;
         FirstRun=0;
         averageReset=0;
         packetcount[packet[6]]++;
         totalPacketsReceived[packet[6]]++;
         PPS++;
         strengthUnsigned = ((int)packet[8])& 0xFF;
         RSSI[packet[6]]=RSSI[packet[6]]+strengthUnsigned;
    if((packet[10]==1 && Transition==1) || (packet[10]==0 && Transition==0))
         secondsElapsed++;
         if(Transition==1)
         Transition=0;
         else
         Transition=1;
         PPS--;
         packetcount[packet[6]]--;
         totalPacketsReceived[packet[6]]--;
         packetHold=packet[6];
         reset=1;
         for(i=0; i<MAX_NODES; i++)
         newContentPane.DataTable.setValueAt("asdfsa",1,1);
              System.out.println("Packet Count for Node " + i + "is: " + packetcount[i]);
              PL[i]=8 - packetcount[i];
              System.out.println("Packet Loss for Node " + i + "is: " + PL[i]);
              avgPacketCount[i]=1.0*totalPacketsReceived[i]/secondsElapsed;
              System.out.println("Avg Packet Count for " + secondsElapsed + " seconds is: " +avgPacketCount[i]);
              if(RSSI[i]!=0)
              RSSI[i]=RSSI[i]/packetcount[i];
              RSSI[i]=3*(RSSI[i]/1024);
              RSSI[i]=(-51.3*RSSI[i])-49.2;
              System.out.println("RSSI(dBm) for node " + i + "is: " + RSSI[i]);
              System.out.println();
              packetcount[i]=0;
              RSSI[i]=0;
         System.out.println("Total Packets Recieved: " + PPS);
         PPS=0;
                   System.out.println();
                   System.out.println();
         javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
         catch (IOException e) {
         System.err.println("Error on " + reader.getName() + ": " + e);

    The best way to update your data is using a TableModel :
    When you instantiate a JTable with an array of objects, it creates a DefaultTableModel which actualy stores your data.
    So, you should create your TableModel, and feed it with the data. Each time the data is updated, the TableModel must notify the JTable, so the new data can be shown :
    here's a simple example
    public class MyModel extends AbstractTableModel
    Object[][] data;
    //you must implement some abstract methods declared in AbstractTableModel
    //the method you use to update the data (you can give it the name you want)
    setData(Object[][] _data)
    data=_data;
    fireTableDataChanged();//method of AbstractTableModel that notifies the data has changed
    public void main(String[] s)
    MyModel tableModel = new MyModel();
    JTable table = new JTable(tableModel);
    JFrame frame = new JFrame();
    frame.getContentPane().add((new JScrollPane()).getViewport().add(table);
    frame.pack();
    frame.setVisible(true);
    tableModel.setData(new Object[][]{{"one", "two"}, {"three", "four"};
    thread.sleep(5000);
    tableModel.setData(new Object[][]{{"five", "six"}, {"seven", "eight};
    You will see the table displaying one, two, three, four, during 5 seconds, and then it will display five, six...

Maybe you are looking for

  • Testing for existence of a table - MySQL

    I'm using MySQL and I just want to see if a table exists so that I can either select data from it or if it does not exists, I want to pull the same fields from a table that I already know exists. Any help would be greatly appreciated. Thanks

  • Issue with multiple digital signatues in form

    Hello all- I'm having an issue with a form that has multiple digital signatures.  The form additionally has a listbox in which the user can select recipients to email the form to. My objective is to be able to send a form to various users by email to

  • Where are last documents in Mavericks finder?

    Hi There Firsty post on here but looking for advice on where (in the new finder on Mavericks) I can see my list of last documents. Previously it used to list them by day/week etc and it was a really convenient feature when I opened finder to see the

  • MR11 and F.19

    Hi GURUu2019S what is the different between MR11, F.19 and F.13 Could some one expalin me in details with examole value points will be assigned thanks sunitha Edited by: sunitha reddy on Mar 20, 2009 10:17 AM

  • I can't access iPhoto because of this message (sorry, it is in French) : "Votre bibliothèque est utilisée par une autre application ou est devenue illisible"

    Here is messaqge : "I can't access iPhoto because of this message (sorry, it is in French) : "Votre bibliothèque est utilisée par une autre application ou est devenue illisible"". I am on a iMac 27"with OS X Lion. The problem appeared while I was doi