java - JFrame absolute positioning - Use ContentPane as position reference -


with setlayout(null), can tell components @ e.g. x 5 , y 60. however, references window's x , y position, borders included.

can i, somehow, tell components 0,0 contentpane's upper left (visible) corner?

this annoying since different os have different sized window borders.

code initialising jframe:

jframeadd addframe; addframe = new jframeadd(); addframe.setvisible(true); addframe.settitle("vokabeltrainer"); addframe.setresizable(false); addframe.setlocationrelativeto(null); addframe.setbounds(100, 100, 825, 585); addframe.setdefaultcloseoperation(jframe.exit_on_close); 

inside jframeadd.java:

jbutton btnnewbutton = new jbutton(new imageicon(settingsicon));     btnnewbutton.addactionlistener(new actionlistener() {         public void actionperformed(actionevent arg0) {             jframegenerated.settingsframe.setvisible(true);         }     });     btnnewbutton.setbounds(0, 510, 36, 36);            contentpane.add(btnnewbutton); 

all code here: https://github.com/misterskilly/vokabeltrainer/tree/loadsave/latein%20asterisk/src , yes know shouldn't run 2 jframes simultaneously, changing messed things , don't have time change atm.

however, references window's x , y position, borders included

no, references content pane, not include titlebar , borders.

can somehow tell components 0,0 contentpane's upper left (visible) corner?

this default behaviour.

if believe application behaving differently post sscce demonstrates problem.

the general rule don't use null layout. let layout manager worry positioning components.


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -