Java Swing UI elements not updating all the time -


i trying make simple gui few tools have cli interface. figured having 1 window multiple tabs best way go this. problem running of ui elements not being updated when filling in information/making selections. in particular combo boxes have been biggest pain.

it displays options , can select different options, after selecting gui not update combo box show new selection. example starts off "1" selected change "3", event trigger sees "3" has been selected combo box still shows "1".

i have tried adding in repaints , validates frames tabs , combo box no luck of forcing update. appreciated.

as note happens text fields have display file paths after selecting file/folder file chooser, not anywhere near often

package com.test.javaswing;  import java.awt.borderlayout; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.util.arraylist; import java.util.list;  import javax.swing.jcombobox; import javax.swing.jcomponent; import javax.swing.jframe; import javax.swing.jlabel; import javax.swing.jpanel; import javax.swing.jtabbedpane; import javax.swing.springlayout; import javax.swing.swingutilities;  public class testswing_main {     /**      * start here      * @param args      */     public static void main(string[] args) {         try {             // run gui construction in event-dispatching thread thread-safety             swingutilities.invokelater(new runnable() {                 @override                 public void run() {                     control_gui.createandshowgui(); // let constructor job                 }             });         } catch(exception e) {             //bad times         }     } }   class control_gui extends jpanel {      private static final long serialversionuid = 1l;      public static taba tab1 = new taba();      public control_gui() {         super(new gridlayout(1, 1));          jtabbedpane tabbedpane = new jtabbedpane();          jcomponent panel4 = tab1.maketabpanel();         tabbedpane.addtab("tab name", null, panel4, "tool tip");          //add tabbed pane panel.         add(tabbedpane);          //the following line enables use scrolling tabs.         tabbedpane.settablayoutpolicy(jtabbedpane.scroll_tab_layout);     }      /**      * create gui , show it.  thread safety,      * method should invoked      * event dispatch thread.      */     public static void createandshowgui() {         //create , set window.         jframe frame = new jframe("tool manager");         frame.setdefaultcloseoperation(jframe.exit_on_close);          //add content window.         frame.add(new control_gui(), borderlayout.center);          //display window.         frame.setsize(700, 400);         frame.setvisible(true);     } }  class taba {      private jcombobox<string> process = new jcombobox<>(             new string[] {"1","2","3","4"});      /**      * empty constructor      */     public taba() {}      /**      * values text fields , check boxes      * , convert them arguments       * @return list<string>      */     public list<string> toolargs() {         list<string> temp = new arraylist<string>();          return temp;     }      /**      * makes contents of tool tab      *       * @return jcomponent      */     public jcomponent maketabpanel() {         /*          * set panel , define layout          */         final jpanel panel = new jpanel(false);         springlayout layout = new springlayout();         panel.setlayout(layout);          /*          * define , set components          */         //choose process         jlabel processlabel = new jlabel("process:");         process.seteditable(false);          /*          * add components panel          */         panel.add(processlabel);         panel.add(process);          /*          * define positioning of components          */         //process         layout.putconstraint(springlayout.west, processlabel, 5, springlayout.west, panel);         layout.putconstraint(springlayout.north, processlabel, 5, springlayout.north, panel);         layout.putconstraint(springlayout.west, process, 5, springlayout.east, processlabel);         layout.putconstraint(springlayout.north, process, 15, springlayout.north, panel);          //process dropdown action on select         process.addactionlistener(new actionlistener() {             @override             public void actionperformed(actionevent e) {                 string temp = (string) ((jcombobox<string>)e.getsource()).getselecteditem();                 system.out.println(temp);             }         });          return panel;     } } 

edit: think figured out issue, or rather there no issue code itself. have tried running on different computers without ever being able reproduce issue. seems specific version of macbook pro running. cannot happen on models newer mine, on versions similar mine or older can happen. not sure causes this.

for reference using ~2011 13-inch macbook pro


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -