jpanel

placing a transparent JPanel on top of another JPanel not working

南楼画角 提交于 2019-12-05 01:06:51
I am trying to place a JPanel on top of another JPanel which contains a JTextArea and a button and i want to the upper apnel to be transparent. I have tried it by making the setOpaque(false) of the upper panel. but it is not working. Can anyone help me to get through this? Thanks in advance! public class JpanelTest extends JPanel { public JpanelTest() { super(); onInit(); } private void onInit() { setLayout(new BorderLayout()); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(new JTextArea(100,100),BorderLayout.CENTER); panel.add(new JButton("submit"),BorderLayout

Java get JPanel Components

送分小仙女□ 提交于 2019-12-05 00:59:25
I have a JPanel full of JTextFields... for (int i=0; i<maxPoints; i++) { JTextField textField = new JTextField(); points.add(textField); } How do I later get the JTextFields in that JPanel? Like if I want their values with TextField.getText(); Thanks Well bear in mind they didn't get there by them selves ( I think a read some questions about dynamically creating these panels at runtime ) In the answers posted there, someone said you should kept reference to those textfields in an array. That's exactly what you need here: List<JTextField> list = new ArrayLists<JTextField>(); // your code... for

Resizing jPanels with animation

点点圈 提交于 2019-12-04 22:39:07
问题 I am developing an application with a FullScreen Panel, and sometimes I need to show a second Panel, in the right side of the screen. To develop it I made a jPanel with AbsoluteLayout (from NetBeans) containing another two panels. I calculate each panel position and size relative to the screen resolution. Basically, I have two "states". In the first the jPanel1 has width = 100% and the jPanel 2 has width = 0% (So I am not showing this panel). And the second state, when jPanel1 has width = 75%

change JPanel after clicking on a button

本秂侑毒 提交于 2019-12-04 21:43:00
I'm building simple GUI for my app. I have couple of JPanels. I want to display them depending on action that was performed by clicking on a JButton. How can I disable one JPanel and enable another one ? Couple of details. I have a class with JFrame where I'm building starting gui. Where I have buttons and some text. Clicking on one of the buttons should change the view in this JFrame my button definition JButton btnStart = new JButton("Start"); btnStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); btnStart.setBounds(10, 11, 110, 23); contentPane

Layers overriding each other in GUI using JPanel

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 21:07:12
I am having trouble making the layout of a simple Calculator. What is happening is that everything appears fine except that my subtract button stays as the background and I have to guess where my other buttons are to be able to click them. When I click them I am able to see them until I unclick them. is there anyway to fix this? I'm not posting the math algorithm a it is not needed for this question. import javax.swing.*; import java.awt.*; import java.awt.event.*; public class GUIcalc extends JFrame implements ActionListener { private JPanel panel; private JPanel buttonpanel; private JPanel

How to add imagepanel in jpanel inside Jframe?

﹥>﹥吖頭↗ 提交于 2019-12-04 20:22:10
I'm trying to add an imagepanel which extends JPanel to another JPanel. Which is not working well for me. The paint function of image panel don't get invoked inside Jpanel but works fine in JFrame. Any ideas or help will be appreciated. import javax.swing.*; import java.awt.*; import java.awt.geom.RoundRectangle2D; import java.awt.image.BufferedImage; class ImagePanel extends JPanel { int g_h=10,g_w=10; int width=50,height=50; int cornerradius; Image castle; Dimension size; protected int x1,y1; Color c1=new Color(255, 0, 0); Rectangle rec; boolean b=false; boolean imboo=false; boolean roundb=

Drawing a movable line on a JPanel

假如想象 提交于 2019-12-04 19:28:47
I'm writing a program which should allow the user to create a floor plan of a room - this means they can draw lines to represent walls etc. I am using a JPanel with Graphics 2D to do all the drawing stuff and currently I have a grid set as the background for the JPanel and I can draw lines based on the mouse movement(I have an enum for the mousestate with two states - DRAGGING and IDLE). However I want to add control points to the lines so that they can be moved around the JPanel once they are drawn and I can't figure out how to this. I know that I need rectangles to represent the points but I

JPanel doesn't show up

亡梦爱人 提交于 2019-12-04 19:15:43
JPanel doesn't show up, i put .setVisible but.. it doesn't show up neither, It builds but it doesn't show up I'm only just a beginner in this part of programming. package calculatorv3; public class CalculatorForm extends javax.swing.JPanel { private static final long serialVersionUID = 1L; public CalculatorForm() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") private void initComponents() {

How to center JPanel when JFrame is resized or maximized?

不羁岁月 提交于 2019-12-04 18:55:01
I want my JPanel to be still in the center when I maximize or re-size the JFrame . How can I do that? Tried: jframe.add(panel, BorderLayout.CENTER); panel.setAlignmentX(JComponent.CENTER_ALIGNMENT); But it doesn't work. Here is my other code: public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { login frame = new login(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } public login() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); setBounds(5, 5, 409, 267); setLocationRelativeTo(null);

adding JLayeredPane to JPanel

主宰稳场 提交于 2019-12-04 18:52:58
问题 I am trying to add a JLayeredPane to a JPanel and then add an image (JLabel icon) and a button to the JLayeredPane, but neither show up. I've tested the image without the button and the layeredpane so I know that works. Here is some of the code I am using. Is there something I am missing or doing wrong? public class MyClass extends JPanel { private JLayeredPane layeredPane; private JLabel imageContainer = new JLabel(); private JButton info = new JButton("i"); MyClass(ImageIcon image) { super(