Jgoodies bindings + shared frequent changes

I have a Java application that updates data at a variable speed (obtained from a fairly high speed data stream from my control, but up to 120 Kbytes / s), and I would like to display statistics such as the number of bytes / packets using the dialog box .

I look at JGoodies bindings and got something pre-working with artificial data obtained at a low speed.

What I would like to do, roughly speaking:

  • create a bean class something like this:

    public class Statistics
    {
      private int bytes;
      private int goodPackets;
      private int badPackets;
      private int totalPackets;
    
      public int getBytes() { return bytes; }
      public int getGoodPackets() { return goodPackets; }
      public int getBadPackets() { return badPackets; }
      public int getTotalPackets() { return totalPackets; }
    
      public void update(/* TBD */) { /* updates the fields appropriately */ }
      public Statistics() { bytes=goodPackets=badPackets=totalPackets=0; }
    }
    
    Statistics stats;
    
  • bind 4 fields to elements in my GUI

  • can be called stats.update()at any speed necessary in my main application thread, where the call to β€œupdate” is what causes the listeners to change the GUI.
  • "" , , 5-20 , .

, , ? JGoodies DelayedReadValueModel, , .

, , , , :

  • - , -
  • update(), , maybePropagate()
  • maybePropagate(): - , , ;
  • , ,
  • 4 , , GUI JAoodies BeanAdapter.

?

+3
2

JGoodies Binding Delayed *, Swing.

SwingWorker, EDT. SwingWorker EDT.

+2

, , :

ValueModel bytesModel = statsPresentationModel.getModel("bytes");
label = BasicComponentFactory.createLabel(bytesModel);

, , :

ValueModel bytesModel = new DelayedReadValueModel(statsPresentationModel.getModel("bytes"));
label = BasicComponentFactory.createLabel(bytesModel);
+1

Source: https://habr.com/ru/post/1704584/


All Articles