Swing layout issue on migration to java 8 -
my swing application in java 5 had display
after migrating java 8, zoomed , displays part of
i saw this , tried setting j2d_d3d environment variable , tried passing vm parameter. didn't solved issue. idea be?
for reference, here's example doesn't have problem. uses gridlayout(0, 1)
congruent gaps , border. resize enclosing frame see effect. experiment box(boxlayout.y_axis)
alternative.
i suspect original code (mis-)uses combination of setxxxsize()
or setbounds()
, display effect shown if chosen & feel has different geometry specified buttons' ui delegate.
import java.awt.eventqueue; import java.awt.gridlayout; import javax.swing.borderfactory; import javax.swing.jbutton; import javax.swing.jframe; import javax.swing.jpanel; /** @see https://stackoverflow.com/a/31078625/230513 */ public class buttons { private void display() { jframe f = new jframe("buttons"); f.setdefaultcloseoperation(jframe.exit_on_close); jpanel p = new jpanel(new gridlayout(0, 1, 10, 10)); p.setborder(borderfactory.createemptyborder(10, 10, 10, 10)); (int = 0; < 3; i++) { p.add(new jbutton("button " + (i + 1))); } f.add(p); f.pack(); f.setlocationrelativeto(null); f.setvisible(true); } public static void main(string[] args) { eventqueue.invokelater(new buttons()::display); } }
Comments
Post a Comment