pretty "start" button wont enlarge when hover on it. here code below idea on why wont? , if show me example code help! :)"i'm still pretty new java too" thats why example code me better in advance!.
public class window extends jframe implements mouselistener { private static final long serialversionuid = 1l; private static jbutton button; private static jframe frame = new jframe("scroller runner v0.2.0"); public static void main(string[] args) throws ioexception { new window(); jbutton button = new jbutton(); jtextpane text = new jtextpane(); bufferedimage buttonicon; button = new jbutton(new imageicon("c:\\users\\goulden\\desktop\\menu_start.png")); button.setborder(borderfactory.createemptyborder()); button.setcontentareafilled(false); button.setbounds(490, 250, 300, 75); button.setcursor(new cursor(cursor.hand_cursor)); button.addmouselistener(null); frame.setsize(1280, 720); frame.setdefaultcloseoperation(jframe.exit_on_close); frame.setlocationrelativeto(null); frame.setvisible(true); frame.setresizable(false); frame.setcontentpane(new jlabel(new imageicon(imageio.read(new file("c:\\users\\goulden\\desktop\\main_menu.png"))))); frame.pack(); frame.add(button); frame.setvisible(true); }@override public void mouseentered(mouseevent e) { button.setbounds(550, 300, 300, 75); this.repaint(); }
this piece of code works me.
as want change size setsize() better this.
button.addmouselistener(new java.awt.event.mouseadapter() { public void mouseentered(java.awt.event.mouseevent evt) { button.setsize(width,height); } });
Comments
Post a Comment