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

Read data from barcode
Android GCM InstanceId.getToken() -> java.io.IOException: TIMEOUT
Cron expression for a particular date
Running debian packages in Scala
Java Button Full Screen
mySQL Subquery to Stored Procedure or JPA query
How to return SeekBar value to previous activity?
Special Characters with MYSQL JAVA Netbeans and JXL
Unable to get this method to work [closed]
How to extract an email address which is not in a regular expression format from a span text using selenium web driver?
Spring boot health check on existing webapp
How to optimise java pattern replace
How to authenticate with rest webservice using oauth2
Starting ActiveMQ with Stomp
Customized selenium Output
Sending a large data by Post between servlets [duplicate]

Categories

HOME
magnific-popup
push-notification
dictionary
lodash
iot
syntax
fme
webstorm
adb
maven-3
binary-tree
acquia
upload
nano-server
jplayer
alignment
decimal
invantive-sql
contextmenu
dbext
autoconf
arabic
google-search-api
language-agnostic
blazemeter
react-css-modules
pingfederate
buck
gsoap
skia
google-qpx-express-api
windows-dev-center
geopositioning
sequential
swisscomdev
hot-module-replacement
webix-treetable
impersonation
email-templates
nxlog
flickr-api
termination
pango
qsslsocket
jquery-nestable
jquery-validate
lowpass-filter
mplayer
diagnostics
crypt
media-player
minimization
topbeat
removechild
ado.net-entity-data-model
master-slave
dataview
suffix-tree
independentsoft
teamcity-8.0
wordml
browser-bugs
responsive-images
bridge.net
jsapi
truevault
lustre
directoryservices
geonetwork
camanjs
cctv
reactfx
doskey
picturefill
message-driven-bean
file-locking
gwt-rpc
interface-orientation
specification-pattern
venn-diagram
cascalog
javaspaces
qtkit
whoosh
mercurial-server
stage
zpt
yetanotherforum
datareader
vc90
ext3
multi-tier
audio-capture
port-number
mediarss
scripting-languages
django-notification
windows-live-messenger
ntvdm.exe

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App