question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't add Webcam panel to existing jPanel.

See original GitHub issue

Hello,

I’m using NetBeans and I made basic layout with jPanel in the middle of it. Now I would like to add Webcam in this jPanel.

Webcam webcam = Webcam.getDefault();
webcam.setViewSize(WebcamResolution.VGA.getSize());

WebcamPanel panel = new WebcamPanel(webcam);
panel.setFPSDisplayed(true);
panel.setDisplayDebugInfo(true);
panel.setImageSizeDisplayed(true);
panel.setMirrored(true);

jPanel5.add(panel);
jPanel5.setVisible(true);
jPanel5.revalidate();
jPanel5.repaint();

This code is in my class constructor. I would like to run this at startup. Just after other netbeans componenst are loaded. When I add example to my program it’s working but my main layout is loaded and webcam screen in another window. I would like to get it in the same window.

I tried to do it with other componenst like jInternalFrame, even jLabel and I just have no idea how to add webcam to existing element, not to new one.

Thanks for any help, Qbaloz

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
aftercxdecommented, Feb 5, 2019

After obtaining the same problem, for the components created from swing with netbeans it is necessary to put the panel with flowlayout.

-Panel created in netbeans image

image

0reactions
sarxoscommented, Jan 30, 2019

Hi @lilblazekonceptz,

There should be no issue when adding WebcamPanel to other JPanel. If it’s not working in your case it means that the JPanel added from Netbeans builder have some fancy something set which differs it from a normal JPanel (I guess, e.g. special layaout manager, preferred size, bounds, or something else).

I tested this idea of embedding WebcamPanel inside another JPanel and it works well:

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding Webcam panel to existing jPanel - java - Stack Overflow
Adding Webcam panel to existing jPanel ... I'm using NetBeans and I made basic layout with jPanel in the middle of it. Now...
Read more >
com.github.sarxos.webcam.WebcamPanel java code examples
Adding Webcam panel to existing jPanel. final JPanel jPanelCamera = new JPanel(); jTabbedPane1.addTab("Camera", jPanelCamera); Webcam webcam = Webcam.
Read more >
How to Use Panels - Oracle Help Center
When you add components to a panel, you use the add method. Exactly which arguments you specify to the add method depend on...
Read more >
Using webcam with a Java application
First you need to get a list of devices with the help of CaptureDeviceManager and filter out the first element of that list....
Read more >
Why isn't my image loading on my JPanel?? - java - DaniWeb
Overridding paint rather that paintComponent is almost always a mistake. In this case you call super.paint - which paints the Panel and all ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found