Thursday, May 1, 2014

Textfield not updating text value
































































































































So I've been working on an extensive java gui program that tracks inventory. At one point in my pprogram I have the user double click on a table and the program is supposed to automatically load a new jframe with several jTextFields that are to be filled out by the frame from which it was launched. However, the graphical part of the textboxes are not showing any change. I can use getText to obtain the correct value, but the value doesn't show in the actual textbox. I've tried repainting and established that it isn't a repaint problem. Also, if I try to access the value from outside the function, I get a NULL, and not the text I want. It seams that the text only lives within the functions called from the main jframe's mouseClicked method. I might also mention I'm using netbeans with it's gui editor, so these jframes are not overridden or anything.
































































































































the second frame is called from here:
































































































































@Override































































































































public void mouseClicked(MouseEvent me) {































































































































if(me.getComponent() == inventoryTable){































































































































if(me.getClickCount() == 2){//TODO make cells non-editable































































































































this.product1.setName("blob");































































































































System.out.println("Row: " + (inventoryTable.getSelectedRow()+1) + " was selected!");//starts with 0, not 1!































































































































final ProductEditView editWindow = new ProductEditView();































































































































Runnable r = new Runnable() {//start in new thread































































































































@Override































































































































public void run() {































































































































editWindow.showMe(product1);































































































































editWindow.setProduct(product1); <-------each jframe has a product which is another class that just stores the string values I need to transfer between frames!































































































































//editWindow.getProduct().setName("testVal");//passes through fine































































































































//editWindow.getProduct().setUnitsInStock(123);































































































































editWindow.setUIFromProduct(product1);
































































































































}































































































































};
































































































































new Thread(r).start();
































































































































}































































































































}































































































































}
































































































































that calls this in the second frame:
































































































































public void setUIFromProduct(Product product){//TODO set in design mode indevidually!































































































































//TODO everything in here is deleted!
































































































































System.out.println("here: " + product1.getName());<------gets the string value just fine































































































































productNameUI.setText(product1.getName());<-------text not shown here































































































































}
































































































































Does anyone have an idea? I've tried commenting out the runnable thinking it was a threadding problem, but no luck.































































































































































































































































No comments:

Post a Comment