java


Refresh a jTable from another window but another window is opning [closed]


refresh a jTable from another window!
i tried this many times with different types like calling a fire method or calling your model again a simple code will be like this using it with an event like a bush button:
private void btn_add_updtActionPerformed(java.awt.event.ActionEvent evt) {
ItemsForm form = new ItemsForm();
//this:
form.mymodel();
//or this:
form.model.fireTableDataChanged();
//or this:
form.model.fireTableStructureChanged();
}
all of them refresh the the table.. but the problem it open another window so i got tow windows opend the new one is refreshed the old is not.. and why i got another window without calling it?
A guess based on incomplete data. Your problem is here:
private void btn_add_updtActionPerformed(java.awt.event.ActionEvent evt) {
ItemsForm form = new ItemsForm();
// update form's state here
}
You likely already have an ItemsForm instance in existence that is already displayed and showing its data. Creating a new one will have no effect on the one already displayed.
A wrong solution is to give ItemsForm static fields so that changes made to one are shown in another. Doing this will break OOPs rules and make your code very difficult to test, upgrade and enhance.
A much better solution is to be sure that the code that needs a reference to the active and displayed ItemsForm instance has one, either directly through constructor or setter/getter method calls, or better, indirectly through a M-V-C program structure.
Side recommendations:
Those fire methods, such as fireTableDataChanged() and fireTableStructureChanged() should be internal to the model itself -- only the model itself should make those calls, and an ActionListener should not be doing this.
Be sure to read: The Use of Multiple JFrames, Good/Bad Practice?

Related Links

How to update frame for more objects class Enemy in Array<Enemy>?
How to link many TextViews with their resources
How to Load and Use Structs and Functions from a C DLL in Java?
Get value from Hashmap by user object
How to deal with read/write function for others file type in Java
Press any key with BufferedReader
Simple instance variable issue
How to select a value from Kendo UI MVVM drop down in automated test?
Mongo DB Java Driver Cursor Doesn't contain full Collection
Method to shift array element forward but eventually needs to appear first
Android facebook crash
Glassfish error when Chrome send Request Method OPTION
How to get both HTML and plain text bodies with EWS in Java?
How to understand “synthetic” bean archive in weld?
How to install/uninstall android app in background?
HQL :Invalid Path in Multiple different Joins

Categories

HOME
maven
ibm-bluemix
pdf
comparison
include
dot
cplex
cvs
razor
youtube-api-v3
electronics
sqlite3
node-notifier
add
medical
google-translate
gnupg
adobe-analytics
orchardcms
clearcase-ucm
systemc
interop
autocad-plugin
xlsxwriter
one-hot-encoding
cloudhub
kvc
shopware
maquette
neo4j-spatial
elasticsearch-net
atlassian-crucible
vision
microsoft-chart-controls
sql-server-2012-express
socialengine
junit5
binary-data
subset-sum
restlet
abstract-class
objectlistview
cookiecutter-django
ruby-on-rails-3.1
jvm-languages
isbn
unixodbc
flashair
xml-documentation
termination
jquery-validate
blogengine.net
dotnetzip
mu
nsarray
query-performance
xcb
wdf
infix-notation
sts-springsourcetoolsuite
qpid
prettytensor
blackberry-10
superstack
apachebench
ipconfig
energy
phpcas
hsv
prerequisites
endeca-workbench
mutation-observers
feedback
jqgrid-formatter
angular-leaflet-directive
appfabric-cache
operation
apache-commons-fileupload
nsight
pretty-print
skos
gwidgets
cdt
qcodo
multiprocessor
commoncrypto
jmapviewer
xamlparseexception
sabredav
http-unit
robotics-studio
specification-pattern
cascalog
javaspaces
dotnethighcharts
bigcouch
cufon
gcj
coercion
xmemcached
datareader
fluent-interface
createwindow
infrastructure
asp.net-profiles
backcolor

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App