swing - Java Fitting JPanel into Modal JDialog -


i have class returns jpanel:

  public static jpanel program(string csvname) {          jpanel f = new jpanel();          try {              string path = system.getproperty("user.dir");              string datafile = path+"/files/logic/"+csvname+".csv";             filereader fin = new filereader(datafile);             defaulttablemodel m = createtablemodel(fin, null);             jtable table = new jtable(m);             jscrollpane stable = new jscrollpane (table);             stable.setverticalscrollbarpolicy(jscrollpane.vertical_scrollbar_as_needed);             stable.sethorizontalscrollbarpolicy(jscrollpane.horizontal_scrollbar_as_needed);             table.setautoresizemode(jtable.auto_resize_off);              f.add(stable);               f.setminimumsize(new dimension(900,500));              jframe desktopframe = new jframe();              desktopframe.add(f);              desktopframe.setsize(900, 500);              desktopframe.setvisible(true);              toexcel(m, new file(path+"/files/logic/"+csvname+".csv"));          } catch (exception e) {             e.printstacktrace();         }          return f;      } 

and used display jpanel modally.

string csv = "war"; jpanel f = t1data.program(csv);  jdialog desktopframe = new jdialog(); desktopframe.add(f); desktopframe.setmodal(true); desktopframe.setsize(900, 500); desktopframe.setvisible(true); 

however result getting has jpanel centered , not fitting jdialog.

it looks this: http://gyazo.com/4bc360e7d2c7cf7117a95d748d520838.png

how can fix this?

the jpanel using flowlayout, if change borderlayout, scroll panel laid out fills full container.

you should consider using jdialog#pack on setsize well


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -