jpanel

Displaying detected faces on a JPanel

瘦欲@ 提交于 2020-01-07 08:55:49
问题 I am working on a project for detecting faces from an input image. I am using opencv with Java. The problem which I'm facing is as below The faces that are detected are to be placed on a JLabel s setIcon method. First time it places the faces, but for the next image, the previous faces are not cleared. Following code that I tried to add and remove faces 1) Adding faces: jFaceLabel is JLabel array initialized to size 100 jpDetectedImage is a JPanel which contains the JLabels (faces) jFaceLabel

Update jPanel background color when a button is pressed

孤街浪徒 提交于 2020-01-07 08:32:37
问题 I'm just starting with Java and I wanted to make a little program that opens a jFrame with a text field in which you can write a number. Then you press a button and another jFrame with a jPanel, which will turn green if the number is even, and black if it's odd. I edited the code of the jPanel so that the color changes depending on the number, but the problem is that it will only work once. If I write "2" and press the button, the jFrame will appear with a green panel, but then if I write

replacing one jpanel with another jpanel

萝らか妹 提交于 2020-01-07 03:51:29
问题 I want to replace the current panel and call another panel in JPanel forms. I try to do using setContentPane() and getContentPane() method but it gives error. how can I do that.... I also try this but clear all the componens but do not add anything private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) { try { if (new ConnectionFactory().userLoginCheck(usernameText.getText(), new String(passwordText.getPassword()))) { removeAll(); add(new ChangeUsernamePassword()); revalidate

JComponents are not showing up on JPanel

谁说我不能喝 提交于 2020-01-07 03:00:52
问题 My JComponents aren't showing up on my JPanel for some reason. Here's my code: MAIN CLASS import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JFrame; import javax.swing.JPanel; // Main Class - executes the game public class Main extends JFrame { public static int WIDTH = 800, HEIGHT = 800; private JPanel jp; private Dimension d; private Snake s; private Food f; public Main() { setTitle("Snake"); setSize(WIDTH, HEIGHT);

Drawing tree not visible; maybe layout issue

落爺英雄遲暮 提交于 2020-01-07 00:33:32
问题 I want to display a tree. But the tree does not appear. What is the problem? Main: package scanner_parser; public class Main { public static void main(String[] args) { Oberflaeche gui = new Oberflaeche(); gui.setVisible(true); } } GUI: import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.*; import javax.swing.*; public class Oberflaeche extends JFrame implements ActionListener { private JPanel cp, top, bottom; private JTextField eingabefeld = new JTextField(); private

Java - How to force buttons to bottom of panel after others have been removed?

这一生的挚爱 提交于 2020-01-06 19:41:26
问题 I'm making a very simple game in Java where when you press a button on your keyboard, the corresponding button is removed, however I want the buttons to all be pushed to the bottom accordingly when one is removed. I'm not sure where I should do this in the code or what method to use. Is there a way to sort of pack the frame so that everything is anchored to the bottom? Here is a picture of the program when it is ran: And when I press the 3rd button, I want the blocks above it to fall down on

Putting button on top of image in JPanel?

耗尽温柔 提交于 2020-01-06 18:33:13
问题 I have been working on a main menu screen. I use a card layout because I have a splash screen that shows up before the main menu screen. Once the user clicks the "Continue" button on the splash screen, they are brought to the main menu screen. I can't add a screenshot because I don't have a high enough reputation but as of now the buttons are pushed off to the side, I assume because of the card layout. Is there any way that I can place the button on top of the main menu screen image? Here is

adding component with out JPanel is it right thing

这一生的挚爱 提交于 2020-01-06 15:11:18
问题 hello i had a question about JPanel component it is very simple question no coding the question why do i have to add gui component to the JPanel if i can simply adding them to the JFrame directly do i always have to add all the component to JPanel and if i did not do that is that going to effect the appellation in any term 回答1: You don't have to add things to "the JPanel" but can add them directly to the JFrame, but understand a few things: When you add components to a typical JFrame using

Creating a Simple Bar Chart in Java - Reads Data and Outputs Bar Graph

℡╲_俬逩灬. 提交于 2020-01-06 15:08:58
问题 Im required to create a simple bar chart for one of my projects. This program requires an input of 1 to 9 integers that are greater than zero. The program is then required to display a very simple bar graph with the integers displayed above the bars. My professor did not explain this program very well to me and this is the first time working with graphics. The program requires: A class "SimpleBarChart" (which will extend Frame) with private variables Bar[] bars and int [] inputData among

(Java) Component not showing on Panel

杀马特。学长 韩版系。学妹 提交于 2020-01-06 15:04:56
问题 I know this question was asked many times and frequently answered, i read some hours on this topic trying to get following to work, but couldn't manage to get it running. I want to show the user a panel where he or she can click on to select points, remember the coordinates and do some stuff with them later. I want to show the points when clicked, but they just don't show up. The frame I paint around the panel does show up, but the points I set don't. Would be glad for any advice given, im