473,467 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

JPanel drawing issues

84 New Member
Hi all, here's a kinda bullet-pointy explanation of what i have

- I have a simple JFrame
- I create a JPanel called 'ContentPane'

Expand|Select|Wrap|Line Numbers
  1. contentPane = new JPanel();
  2. contentPane.setBackground(SystemColor.window);
  3. contentPane.setBorder(new LineBorder(SystemColor.inactiveCaption));
  4. contentPane.setLayout(null);
  5. setContentPane(contentPane);
- the JFrame has a JMenuBar -> JMenuBar -> JMenuItem
- The JMenuItem has a MouseListener and a override to 'mouseReleased'
- Inside mouseReleased i call

Expand|Select|Wrap|Line Numbers
  1. TestPanel p = new TestPanel(null, new Vector2(12, 12));
  2.  
  3. contentPane.add(p);
- TestPanel extends a JPanel, and ha some simple text boxes and labels in it which are created in its constructor, super(); is called.

- When the event is fired it creates a TestPanel but it is tiny, about an inch long and 5 mm in height, it should be much much bigger.

- If I move the call to instance the TestPanel outside of the event (so the TestPanel is instanced on load) it is drawn fine.

Why does the event effect it in this way ?

Thanks,

Stu.
Oct 31 '11 #1
0 1255

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Moth | last post by:
I have a PlotPanel class that extends JPanel which I have used previously to display charts in swing guis. I now want to display a graph in a jsp page so I was going to generate the graph and then...
2
by: TR | last post by:
Hi All: I have a simple test GUI that has 2 panels (a left side and a right side), and each panel is displaying an image. The left panel has a hardcoded size of (600,400) using the Dimension()...
2
by: =?Utf-8?B?aXdkdTE1?= | last post by:
hi, im trying to get my form (that has a tabcontrol and 4 tabs on it) to be a solid color, aka you cant see the color Control that the TabControl has. The issue im having is, that the control color...
1
by: dishal | last post by:
Hi, Im having a problem with typing on the JPanel. The thing is, that it works perfectly fine when this line " content.add(jp, BorderLayout.NORTH); " is taken out (its the buttons panel) but when its...
5
by: James Barrett | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi all, I am experimenting with JApplet and JPanel. My JApplet contains a JPanel called jpanel1 size 210x210. I created a class myPanel which...
3
by: sumuka | last post by:
Hello, I'm doing a project in java using swings ,im able to create a panel and frame but i have a problem in event handling.I have added the MouseMotionListener but it's giving some error .Here i...
2
by: zahit | last post by:
hi guys, my line doesn't appear on the frame. what's the problem? import java.util.*; import java.io.*; import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.*; public class...
8
by: eddiewould | last post by:
Hi, I want to write a custom widget which will act similarly to a JPanel (i.e it can contain other Components), but semantically it's not a kind of JPanel so it shouldn't extend from it. Here is...
1
by: Akino877 | last post by:
Hello, I have a question regarding Java and Swing programming I wonder if I could ask the forum for some help. I have a JPanel that has a couple of radio buttons and an "OK/Next" button on it. ...
0
by: Chanbre | last post by:
Using the Netbeans design editor I have created a JPanel (as "public class LengthPanel extends javax.swing.JPanel {...}" ) containing a few items. Now I want to place two copies of that panel into...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.