How can i implement a picture in my Java Frame -


i dont know how implement picture frame.

i dont use layout manager instead use absolute positioning.

i got code internet dont understand ever part iam still learning it.

maybe of guys can me. in advance.

import java.awt.container; import java.awt.insects; import java.awt.dimension; import javax.swing.jbutton; import javax.swing.jframe;  public class sssaa {      public static void addcomponentstopane(container pane) {      pane.setlayout(null);      // buttons      jbutton burger = new jbutton("burger");     burger.setfocuspainted(false);     jbutton beilagen = new jbutton("beilagen");     beilagen.setfocuspainted(false);     jbutton salate = new jbutton("salate");     salate.setfocuspainted(false);     jbutton specials = new jbutton("specials");     specials.setfocuspainted(false);     jbutton tagesgericht = new jbutton("tagesgericht");     tagesgericht.setfocuspainted(false);     jbutton aktionsangebot = new jbutton("aktionsangebot");     aktionsangebot.setfocuspainted(false);     jbutton getränke = new jbutton("getränke");     getränke.setfocuspainted(false);        pane.add(burger);     pane.add(beilagen);     pane.add(salate);     pane.add(specials);     pane.add(tagesgericht);     pane.add(aktionsangebot);     pane.add(getränke);      //absolute positioning      insets insets = pane.getinsets();     dimension size = burger.getpreferredsize();     burger.setbounds(20 + insets.left, 50 + insets.top,                  size.width + 100, size.height + 50);     size = beilagen.getpreferredsize();     beilagen.setbounds(20 + insets.left, 130 + insets.top,                  size.width + 90, size.height + 50);     size = salate.getpreferredsize();     salate.setbounds(20 + insets.left, 210 + insets.top,                  size.width + 103, size.height + 50);     size = burger.getpreferredsize();     specials.setbounds(20 + insets.left, 290 + insets.top,                  size.width + 100, size.height + 50);     size = beilagen.getpreferredsize();     tagesgericht.setbounds(20 + insets.left, 370 + insets.top,                  size.width + 90, size.height + 50);     size = salate.getpreferredsize();     aktionsangebot.setbounds(20 + insets.left, 450 + insets.top,                  size.width + 103, size.height + 50);     size = salate.getpreferredsize();     getränke.setbounds(20 + insets.left, 530 + insets.top,                  size.width + 103, size.height + 50);       }       private static void createandshowgui() {     //create , set window.     jframe frame = new jframe("absolutelayoutdemo");     frame.setdefaultcloseoperation(jframe.exit_on_close);            //set content pane.     addcomponentstopane(frame.getcontentpane());      //size , display window.     insets insets = frame.getinsets();     frame.setsize(1200 + insets.left + insets.right,                   900 + insets.top + insets.bottom);     frame.setvisible(true);     }      public static void main(string[] args) {     //schedule job event-dispatching thread:     //creating , showing application's gui.      javax.swing.swingutilities.invokelater(new runnable() {         public void run() {             createandshowgui();         }     });      }         } 

use jpanel have location present image.

jimagecomponent myimage = new jimagecomponent(insertyourimagehere);  imagepanel.add(myimage); 

you can use jlabel store image.

frame.add(new jlabel(new imageicon("path image"))); 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -