java - How can you place a JButton over a Picture in a JFrame -
i creating little program. programme should consist of next things:
first opens window image , text. has button "let's go!" opens joptionpane dialog , 4 different buttons. (it's suposed quiz, question , 4 different answers) when click wrong reply says "wrong answer, seek again" if click right reply say: "right answer, sense free procede" or , next question opens up.
so far good. pretty new java , first "big" programm , got bit stuck. problem facing is: how can place jbutton in jframe image , text? created 1 bit either not displayed or below picture. here code far:
import java.awt.*; import javax.swing.*; public class hba extends jframe { public hba() { setsize(1100, 720); setdefaultcloseoperation(jframe.exit_on_close); setlayout (new flowlayout(flowlayout.center)); icon icon = new imageicon("happybirthday.jpg"); jlabel label1 = new jlabel("happy birthday anna!", jlabel.center); jlabel label2 = new jlabel("und viel erfolg mit diesem geschenk! ;)", jlabel.center); jlabel label3 = new jlabel(icon); jbutton ok = new jbutton("let's go!"); font schrift = new font("comicsans", font.bold, 24); label1.setfont(schrift); label2.setfont(schrift); label1.setforeground(color.black); label2.setforeground(color.black); getcontentpane().add(label1); getcontentpane().add(label2); getcontentpane().add(label3); getcontentpane().setbackground(color.white); getcontentpane().add(ok); } public static void main(string[] args) { new hba().setvisible(true); }
}
beside jbutton problem: can give me advice how build , create joptionpane windows?
java jframe window jbutton joptionpane
No comments:
Post a Comment