Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Hello. Trying to use Container and place a picture on it

  1. #1
    Member Helium c2's Avatar
    Join Date
    Nov 2023
    Location
    Kekaha, Kaua'i
    Posts
    102
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Hello. Trying to use Container and place a picture on it

    I'm trying to place this container in an html webpage. Blog. I want to know if this Java program will work. If the other side or client side also has a JRE 2021 version of it or it may be their own language. Example, UNIX. It uploads a picture on the client side html or www web page. Curious if this program will run on the other person's computer. Also using Java or JRE. Adding a container for a picture that is already on my iPhone.

     
    import java.awt.Container;
    import java.awt.Frame;
    import java.awt.Panel;
     
    Public class Container   {
     
        Public Static void main(String[] args)  {
          //create a Frame
          Frame frame=new Frame("Kaua'i County Government");  //on my iPhone is the picture
     
          //create a panel
          Panel panel=new Panel();
     
         //Add the pane to the frame
          frame.add(panel);
     
          frame.setSize(300,200);
          frame.setVisible(true);
     
          //adding the picture on my iPhone
          JFlrame frame=new JFrame();
          JLabel label=new ImageIcon("IMG_610.jpg"));
          frame.add(label);
     
          }
    }  //end of program

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Hello. Trying to use Container and place a picture on it

    Have you tried to compile this code? What compiler error messages do you get?

    The Container class is part of java. It would be better to give your code a different name.

    Another issue is the mixing of awt classes with Swing classes. Swing class names start with J.
    It would be better to use only Swing classes. awt is very old and dated.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member Helium c2's Avatar
    Join Date
    Nov 2023
    Location
    Kekaha, Kaua'i
    Posts
    102
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Hello. Trying to use Container and place a picture on it

    No. Not yet. I'll get to it soon. I just want to know if this code might look good enough. I'm waiting to see on another lap top pc. To see if that Lap top is fixed. But soon.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Hello. Trying to use Container and place a picture on it

    Ok, I'll wait until you can try compiling the code to see what happens.
    If you get any error messages, copy and paste them here if you need help.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Constructor & container
    By geoinfoguide in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 20th, 2019, 02:56 PM
  2. component and container class
    By noobjava in forum AWT / Java Swing
    Replies: 3
    Last Post: May 21st, 2014, 08:31 AM
  3. HELP - placing picture on top of another picture in Java - JLayerPane
    By smasm in forum What's Wrong With My Code?
    Replies: 39
    Last Post: April 27th, 2012, 07:16 PM
  4. Converting a picture made up of 0s and 1s into a colored picture??
    By Kranti1992 in forum Java Theory & Questions
    Replies: 10
    Last Post: November 21st, 2011, 06:25 PM
  5. How to place icon on a picture base on (x,y) axis
    By FaintSmile in forum Java Theory & Questions
    Replies: 1
    Last Post: July 13th, 2010, 07:27 AM