ImageIcon under JPanel not showing up after the Panels disappearAdd a complex image in the panel, with buttons around it in one customized user interfaceHow to set a background picture in JPanelImageIcon not drawing on a panelDrawing an image in JScrollPane within scaleShowing part of an ImageIconImageIcon not Showing up in JPanelManage ImageIcon in jPanelBackground JSwing Image Loading OddlySwitching JPanelsI cannot load Images in .JARWhy isn't the JPanel showing the ImageIcon?Putting a Panel on top of a JLabel backGround (Java)

GNU sort stable sort when sort does not know sort order

Is The Venice Syndrome documentary cover photo real?

Can a US President, after impeachment and removal, be re-elected or re-appointed?

If you inherit a Roth 401(k), is it taxed?

Why does Canada require bilingualism in a lot of federal government posts?

How to efficiently shred a lot of cabbage?

How to season a character?

Convert graph format for Mathematica graph functions

Rampant sharing of authorship among colleagues in the name of "collaboration". Is not taking part in it a death knell for a future in academia?

How do I find the FamilyGUID of an exsting database

Why is my fluorescent tube orange on one side, white on the other and dark in the middle?

Classic vs Modern Experience

To find islands of 1 and 0 in matrix

Why did Windows 95 crash the whole system but newer Windows only crashed programs?

Why did I lose on time with 3 pawns vs Knight. Shouldn't it be a draw?

Why does aggregate initialization not work anymore since C++20 if a constructor is explicitly defaulted or deleted?

How do I make my photos have more impact?

Assuring luggage isn't lost with short layover

What is more environmentally friendly? An A320 or a car?

Blank spaces in a font

Employer stores plain text personal data in a 'data warehouse'

Problem with Eigenvectors

Why put copper in between battery contacts and clamps?

What are the closest international airports in different countries?



ImageIcon under JPanel not showing up after the Panels disappear


Add a complex image in the panel, with buttons around it in one customized user interfaceHow to set a background picture in JPanelImageIcon not drawing on a panelDrawing an image in JScrollPane within scaleShowing part of an ImageIconImageIcon not Showing up in JPanelManage ImageIcon in jPanelBackground JSwing Image Loading OddlySwitching JPanelsI cannot load Images in .JARWhy isn't the JPanel showing the ImageIcon?Putting a Panel on top of a JLabel backGround (Java)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am writing code for a Reverse Raffle in which once a button is pushed, that panel disappears. I want to put an Image behind the panels to slowly be revealed as the Panels are set to not Visible, but for some reason it isn't showing up, can anyone help? (Please excuse all the commented out code, I've done a lot of troubleshooting with this and I've yet to clean it all up yet.)



I've tried changing the frame.setContentPane to frame.add but that puts the image on top of the panels, and after the panels are clicked, the image goes away.



public static void createAndShowGUI()


JFrame frame = new JFrame("Raffle");
RaffleBoard myDemo = new RaffleBoard();
JLabel label = null;
frame.setBackground(Color.BLUE);

try
label = new JLabel(new ImageIcon(ImageIO.read(new File("logo.png"))));
catch (IOException e)
e.printStackTrace();


frame.add(label);
label.setLocation(0,0);
frame.pack();


try
frame.setContentPane(myDemo.createContentPane());

catch(IOException e)
e.printStackTrace();





frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setSize(myDemo.getWidth(),myDemo.getHeight());
frame.setVisible(true);










share|improve this question


























  • frame.setContentPane will replace the frames previous contentPane which contained the label, so, no, it won't show up. A generally better solution would be to create a "background" pane which could render the image and on to which other components can be added

    – MadProgrammer
    Mar 26 at 20:42











  • See How to set a background picture in JPanel for some more details

    – MadProgrammer
    Mar 26 at 20:42











  • frame.setSize(myDemo.getWidth(),myDemo.getHeight()); is some what erroneous, because until the component has undergone a layout pass, its size will be indeterminate. A better solution is simply to use frame.pack() and allow the layout manager to make decisions about how best to deal with it, of course, then you'll have issues with setResizable

    – MadProgrammer
    Mar 26 at 20:44











  • Even so, If add the label to a new JPanel and change frame.setContentPane to frame.add, the image shows up on top of the other panels and disappears once their clicked. Idk if able to tell from what is given what the problem is or not, I'm still fairly new to java

    – tjzeiger
    Mar 26 at 20:48











  • You seem to have a lack of understanding of how the layout management API works. Maybe start with How to Use BorderLayout as that's the default layout manager used by JFrame

    – MadProgrammer
    Mar 26 at 21:00

















0















I am writing code for a Reverse Raffle in which once a button is pushed, that panel disappears. I want to put an Image behind the panels to slowly be revealed as the Panels are set to not Visible, but for some reason it isn't showing up, can anyone help? (Please excuse all the commented out code, I've done a lot of troubleshooting with this and I've yet to clean it all up yet.)



I've tried changing the frame.setContentPane to frame.add but that puts the image on top of the panels, and after the panels are clicked, the image goes away.



public static void createAndShowGUI()


JFrame frame = new JFrame("Raffle");
RaffleBoard myDemo = new RaffleBoard();
JLabel label = null;
frame.setBackground(Color.BLUE);

try
label = new JLabel(new ImageIcon(ImageIO.read(new File("logo.png"))));
catch (IOException e)
e.printStackTrace();


frame.add(label);
label.setLocation(0,0);
frame.pack();


try
frame.setContentPane(myDemo.createContentPane());

catch(IOException e)
e.printStackTrace();





frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setSize(myDemo.getWidth(),myDemo.getHeight());
frame.setVisible(true);










share|improve this question


























  • frame.setContentPane will replace the frames previous contentPane which contained the label, so, no, it won't show up. A generally better solution would be to create a "background" pane which could render the image and on to which other components can be added

    – MadProgrammer
    Mar 26 at 20:42











  • See How to set a background picture in JPanel for some more details

    – MadProgrammer
    Mar 26 at 20:42











  • frame.setSize(myDemo.getWidth(),myDemo.getHeight()); is some what erroneous, because until the component has undergone a layout pass, its size will be indeterminate. A better solution is simply to use frame.pack() and allow the layout manager to make decisions about how best to deal with it, of course, then you'll have issues with setResizable

    – MadProgrammer
    Mar 26 at 20:44











  • Even so, If add the label to a new JPanel and change frame.setContentPane to frame.add, the image shows up on top of the other panels and disappears once their clicked. Idk if able to tell from what is given what the problem is or not, I'm still fairly new to java

    – tjzeiger
    Mar 26 at 20:48











  • You seem to have a lack of understanding of how the layout management API works. Maybe start with How to Use BorderLayout as that's the default layout manager used by JFrame

    – MadProgrammer
    Mar 26 at 21:00













0












0








0








I am writing code for a Reverse Raffle in which once a button is pushed, that panel disappears. I want to put an Image behind the panels to slowly be revealed as the Panels are set to not Visible, but for some reason it isn't showing up, can anyone help? (Please excuse all the commented out code, I've done a lot of troubleshooting with this and I've yet to clean it all up yet.)



I've tried changing the frame.setContentPane to frame.add but that puts the image on top of the panels, and after the panels are clicked, the image goes away.



public static void createAndShowGUI()


JFrame frame = new JFrame("Raffle");
RaffleBoard myDemo = new RaffleBoard();
JLabel label = null;
frame.setBackground(Color.BLUE);

try
label = new JLabel(new ImageIcon(ImageIO.read(new File("logo.png"))));
catch (IOException e)
e.printStackTrace();


frame.add(label);
label.setLocation(0,0);
frame.pack();


try
frame.setContentPane(myDemo.createContentPane());

catch(IOException e)
e.printStackTrace();





frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setSize(myDemo.getWidth(),myDemo.getHeight());
frame.setVisible(true);










share|improve this question
















I am writing code for a Reverse Raffle in which once a button is pushed, that panel disappears. I want to put an Image behind the panels to slowly be revealed as the Panels are set to not Visible, but for some reason it isn't showing up, can anyone help? (Please excuse all the commented out code, I've done a lot of troubleshooting with this and I've yet to clean it all up yet.)



I've tried changing the frame.setContentPane to frame.add but that puts the image on top of the panels, and after the panels are clicked, the image goes away.



public static void createAndShowGUI()


JFrame frame = new JFrame("Raffle");
RaffleBoard myDemo = new RaffleBoard();
JLabel label = null;
frame.setBackground(Color.BLUE);

try
label = new JLabel(new ImageIcon(ImageIO.read(new File("logo.png"))));
catch (IOException e)
e.printStackTrace();


frame.add(label);
label.setLocation(0,0);
frame.pack();


try
frame.setContentPane(myDemo.createContentPane());

catch(IOException e)
e.printStackTrace();





frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setSize(myDemo.getWidth(),myDemo.getHeight());
frame.setVisible(true);







java image swing jlabel imageicon






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 5:04









Andrew Thompson

154k29 gold badges169 silver badges358 bronze badges




154k29 gold badges169 silver badges358 bronze badges










asked Mar 26 at 20:34









tjzeigertjzeiger

1




1















  • frame.setContentPane will replace the frames previous contentPane which contained the label, so, no, it won't show up. A generally better solution would be to create a "background" pane which could render the image and on to which other components can be added

    – MadProgrammer
    Mar 26 at 20:42











  • See How to set a background picture in JPanel for some more details

    – MadProgrammer
    Mar 26 at 20:42











  • frame.setSize(myDemo.getWidth(),myDemo.getHeight()); is some what erroneous, because until the component has undergone a layout pass, its size will be indeterminate. A better solution is simply to use frame.pack() and allow the layout manager to make decisions about how best to deal with it, of course, then you'll have issues with setResizable

    – MadProgrammer
    Mar 26 at 20:44











  • Even so, If add the label to a new JPanel and change frame.setContentPane to frame.add, the image shows up on top of the other panels and disappears once their clicked. Idk if able to tell from what is given what the problem is or not, I'm still fairly new to java

    – tjzeiger
    Mar 26 at 20:48











  • You seem to have a lack of understanding of how the layout management API works. Maybe start with How to Use BorderLayout as that's the default layout manager used by JFrame

    – MadProgrammer
    Mar 26 at 21:00

















  • frame.setContentPane will replace the frames previous contentPane which contained the label, so, no, it won't show up. A generally better solution would be to create a "background" pane which could render the image and on to which other components can be added

    – MadProgrammer
    Mar 26 at 20:42











  • See How to set a background picture in JPanel for some more details

    – MadProgrammer
    Mar 26 at 20:42











  • frame.setSize(myDemo.getWidth(),myDemo.getHeight()); is some what erroneous, because until the component has undergone a layout pass, its size will be indeterminate. A better solution is simply to use frame.pack() and allow the layout manager to make decisions about how best to deal with it, of course, then you'll have issues with setResizable

    – MadProgrammer
    Mar 26 at 20:44











  • Even so, If add the label to a new JPanel and change frame.setContentPane to frame.add, the image shows up on top of the other panels and disappears once their clicked. Idk if able to tell from what is given what the problem is or not, I'm still fairly new to java

    – tjzeiger
    Mar 26 at 20:48











  • You seem to have a lack of understanding of how the layout management API works. Maybe start with How to Use BorderLayout as that's the default layout manager used by JFrame

    – MadProgrammer
    Mar 26 at 21:00
















frame.setContentPane will replace the frames previous contentPane which contained the label, so, no, it won't show up. A generally better solution would be to create a "background" pane which could render the image and on to which other components can be added

– MadProgrammer
Mar 26 at 20:42





frame.setContentPane will replace the frames previous contentPane which contained the label, so, no, it won't show up. A generally better solution would be to create a "background" pane which could render the image and on to which other components can be added

– MadProgrammer
Mar 26 at 20:42













See How to set a background picture in JPanel for some more details

– MadProgrammer
Mar 26 at 20:42





See How to set a background picture in JPanel for some more details

– MadProgrammer
Mar 26 at 20:42













frame.setSize(myDemo.getWidth(),myDemo.getHeight()); is some what erroneous, because until the component has undergone a layout pass, its size will be indeterminate. A better solution is simply to use frame.pack() and allow the layout manager to make decisions about how best to deal with it, of course, then you'll have issues with setResizable

– MadProgrammer
Mar 26 at 20:44





frame.setSize(myDemo.getWidth(),myDemo.getHeight()); is some what erroneous, because until the component has undergone a layout pass, its size will be indeterminate. A better solution is simply to use frame.pack() and allow the layout manager to make decisions about how best to deal with it, of course, then you'll have issues with setResizable

– MadProgrammer
Mar 26 at 20:44













Even so, If add the label to a new JPanel and change frame.setContentPane to frame.add, the image shows up on top of the other panels and disappears once their clicked. Idk if able to tell from what is given what the problem is or not, I'm still fairly new to java

– tjzeiger
Mar 26 at 20:48





Even so, If add the label to a new JPanel and change frame.setContentPane to frame.add, the image shows up on top of the other panels and disappears once their clicked. Idk if able to tell from what is given what the problem is or not, I'm still fairly new to java

– tjzeiger
Mar 26 at 20:48













You seem to have a lack of understanding of how the layout management API works. Maybe start with How to Use BorderLayout as that's the default layout manager used by JFrame

– MadProgrammer
Mar 26 at 21:00





You seem to have a lack of understanding of how the layout management API works. Maybe start with How to Use BorderLayout as that's the default layout manager used by JFrame

– MadProgrammer
Mar 26 at 21:00












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55365783%2fimageicon-under-jpanel-not-showing-up-after-the-panels-disappear%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55365783%2fimageicon-under-jpanel-not-showing-up-after-the-panels-disappear%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해