Want a GlassPane for a JPanel! Or do I go MDI?
Hello,
We have an Swing application that has been using to the
the GlassPane in JFrame. Since the application used
the complete JFrame, it was ok.
The problem is the new release, requires the effect we
are using the GlassPane to be localized to a JPanel.
We are using a gridbaglayout that has other JPanel doing
other activities.
The problem is that the GlassPane is in the JFrame.
So it covers all the other JPanels, when it's used.
At present the only solution I have come up with is to
go MDI and have multple JFrames. And redo the entire
application and layout as a MDI.
Is there anyway, to just localize a GlassPane to a single
JPanel.
Or is the solution MDI approach...
thanks for your feedback..
larry
Here is an example I made :
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class OverlayPanel extends JPanel {
private GlassPanel glassPanel;
public JCheckBox check;
public OverlayPanel() {
setLayout(new OverlayLayout(this));
glassPanel = new GlassPanel();
add(glassPanel);
add(new SubPanel());
setPreferredSize(new Dimension(500,500));
check = new JCheckBox("Enable glass pane for the panel");
check.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
glassPanel.setVisible(((JCheckBox)e.getSource()).isSelected());
static class SubPanel extends JPanel {
Point p = new Point(0,0);
public SubPanel() {
setBackground(Color.white);
MouseHandler mh = new MouseHandler();
addMouseListener(mh);
addMouseMotionListener(mh);
final class MouseHandler extends MouseInputAdapter {
public void mousePressed(MouseEvent e) {
p.setLocation(e.getPoint());
repaint();
public void mouseDragged(MouseEvent e) {
p.setLocation(e.getPoint());
repaint();
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.red);
g.fillOval(p.x-10,p.y-10,20,20);
static class GlassPanel extends JPanel {
Point p = new Point(0,0);
public GlassPanel() {
setOpaque(false);
MouseHandler mh = new MouseHandler();
addMouseListener(mh);
addMouseMotionListener(mh);
setVisible(false);
final class MouseHandler extends MouseInputAdapter {
public void mousePressed(MouseEvent e) {
p.setLocation(e.getPoint());
repaint();
public void mouseDragged(MouseEvent e) {
p.setLocation(e.getPoint());
repaint();
public void paintComponent(Graphics g) {
g.setColor(Color.green);
g.fillOval(p.x-10,p.y-10,20,20);
public static void main(String[] args) {
JFrame f = new JFrame("Test panel glass pane");
OverlayPanel p = new OverlayPanel();
f.getContentPane().add(p, BorderLayout.CENTER);
f.getContentPane().add(p.check, BorderLayout.SOUTH);
f.pack();
f.setVisible(true);
}Denis
Similar Messages
-
Re: want to write a test diver for a Jpanel
I have a JPanel which is called new PersonalDataPanel which has GUI components and is part of a bigger application i.e
myapplication extend JFrame {
pdp = new PersonalDataPanel();
... etc
I want to write a test driver just for the JPanel how can I do this?eg,
public class PersonalDataPanel extends JPanel
public static void main( String[] args ) {
JFrame f = new JFrame();
JPanel p = (JPanel) f.getContentPane();
p.add( new PersonalDataPanel() );
f.pack();
f.show();
}just invoke it with:
java PersonalDataPanel -
How to set an image as background for a jPanel in an applet
hi,
I want to set an image as background for a jPanel component in an applet. I am using netbeans environment. I found that to set an image as a background for a jPanel is not possible. Could someone help me .
Thanks in advance,
Joshuapublic class ImagePanel extends JPanel
private Image image = null;
public void setImage(Image image)
this.image = image;
protected void paintComponent(Graphics g)
super.paintComponent(g);
g.drawImage(this.image, 0, 0, this);
}Adjust to taste. -
I'm using Time Machine and a LaCie external drive to backup. I also have a 8 GB LaCie flash drive I want to use for small jobs. If I plug the LaCie flash drive in, is my Mac going to think it is the LaCie external drive and start trying to backup?
no.
-
I just bought an Iphone 4 from straight talk. My camera does not work. The shutter does not open and when it does open there is a black screen. I am very upset. I have wanted this phone for awhile. I want the issue fixed.
ThanksTake the iPhone to an Apple store genius bar for testing, and if it is defective and under warranty they will replace. Since you say iPhone 4, was this a used or refurbished iPhone?
-
I recently upgraded to Yosemite 10.10.2 and Aperture 2.1.4 will no longer open. I cannot access my photos and I don't want to pay for latest version of Aperture since this application is no longer going to be supported. How can I get my pictures?
If you want just the originals, then you can go into the Aperture library (right click on it and do "show package contents"). Inside is a directory called "Masters" and you can find the original files in a bunch of subfolders.
But... you'll lose all adjustments, keywords, and other information, and just have the files as they were imported originally from the cameras.
Easiest is probably to buy Aperture and update everything, and then migrate to the Photos application down the road if that's what you want. Aperture 3.0 came out in 2010 (five years ago!) so it's not like you've upgraded in a while -
I have a I Mac in my office & a mac lap top at home. Now I have the same e-mail address. I want the Facetime for my mac at home. 10.5.8 how can I get it?
Addition to above...
I need this on iCloud. anyone know where to find it? -
MMy old iPhone 5c is wanting a password for logging into my apple account. The problem is that the email address its tied to doesn't exist anymore. I changed the email to a different one. But can't figure out how to change the email address on the phone to the new email address.
The fact that the email address doesn't exist anymore doesn't matter. As far as the Apple ID is concerned, the email address is just a user name. As long as you know the password you used, it should be fine.
If you don't remember the password, start here:
https://iforgot.apple.com -
I want to write for firefox tips and tricks. What can I do?!
I found some of basic Firefox tricks that I think very few knows about it!
Hello Hossmf, see already known [https://support.mozilla.org/en-US/products/firefox/tips tips and tricks]
and : http://www.tweakguides.com/Firefox_1.html
(it is only a little bit of knowledge in the above articles)
if you want to contribute for a start see : [https://support.mozilla.org/en-US/kb/how-the-knowledge-base-works#os=win8&browser=fx17 How the Knowledge Base works]
i'm sure other contributors/helpers help you more(with more links)
'''''try it, it worth it'''''
thanks -
Enter the Apple ID you want to use for iCloud in Control Panel > Network > Internet > iCloud.
Enter the Apple ID you want to use for store purchases (including iTunes in the Cloud and iTunes Match) in iTunes > iTunes Store.Welcome to the Apple community.
iTunes and iCloud and different accounts, you will need to delete both accounts from your device before adding the new details in their place.
For iCloud go to settings > iCloud, scroll down and hit the delete button. You can then sign back in using your correct details. For iTunes go to settings >store, tap your account ID and then sign out, you can then sign back in using your correct Apple ID. -
in my iphone settings, my phone has not allowed me to change the apple id account i want to use for icloud
im using another id for my purchases, which was the same one set for icloud, but i wasnt using icloud, now i made a new id, and want to set it for icloud, but its not offering me the chance to change it in icloud settingsWelcome to the Apple Community Rozie.
In order to change your Apple ID or password for your iCloud account on your iOS device, you need to delete the account from your iOS device first, then add it back using your updated details. (Settings > iCloud, scroll down and hit "Delete Account") -
Since installing Ios7 280 music tunes out of a total of 360 will now only play when I'm within range of WiFi. The remainder now appear with the stupid Icloud logo beside them. How can I get them back on my Iphone 4s and scrap this stupid icloud that I did not want or ask for in the first place. Why can't rotten apple ask if you want the dam icloud rather than just stealing everything without permission and then you can only have access to it through wifi.
Wow, just posting and it seems that there is a solution that is working for me...
What I've did is I turned off iTunes Match on my iPhone, then turned in on again. Now in my iTunes library on my mac I can get the duplicates to be matched or uploaded to iCloud with a right-click, add to iCloud. iTunes Match starts to check the songs and everything is done correctly. Pretty nice! -
I just bought a new Mac and migrated my CS6 over. Now when I open it, I'm told I'm running a trial version of Cloud. Why can't I use my CS6 version that I purchased? I don't want to pay for something I've already bought.
Here's how to convert the Trail to Permanent:
On receiving Trial/Trial Expired screen
Make sure that you are online
Click on license this software
Perpetual product owners: Log in with adobe ID and enter product serial number
Product should be licensed successfully -
i damaged my iphone 5 and have been sent a new one, but i do not have enough storage to back up my phone and do not want to pay for more storage. can i get all of my contacts, photos, etc. on my new phone just by logging into my icloud account?
Not photos, just data synced with iCloud shown in Settings>iCloud. If you don't have sufficient storage to back up to iCloud, back up to your computer instead using iTunes (connect you phone to your computer, open iTunes, click on the name of your phone in iTunes, go to ths Summary tab of your iTunes sync settings and click Back Up Now). Also transfer your purchases to your iTunes library (connect your phone to your computer, open iTunes and go to File>Devices>Transfer Purchases). If you have photo stream photos older than 30 days tha you wan to save, save these to your camera roll before backing up (tap Select, tap the photos, tap the share icon -- box with upward facing arrow, then tap Save to Camera Roll).
When setting up your new phone, when given the option choose Restore from iTunes Backup and restore the backup you made earlier. -
I have recently got a new iphone 5 and I dropped it on to the rug on top of wooden flooring and the screen is now cracked. I have made an appointment at my nearest apple store but i still have to travel quite a bit. Will apple replace this phone or send mine away? I don't want to travel for nothing.
If you are in the US ,some Apple genius bars are replacing screens at this time if your local store isn't offering that service or you are not in the US there will be an out of warranty exchange unit for $229
make sure you back up everything as if you exchange your iPhone will go and the Genius bar do not provide a backup service
Maybe you are looking for
-
Can't install OSX after I installed new hard drive
Okay so my 2009 MacBook pro would not start up, took it to the genius bar and they said I need a new hard drive. I installed a Western Digital blue Scorpio one from Best Buy and now when I turn on the computer I just get a flashing folder with a ques
-
"..no bootable device insert boot disk and press any key", i restarted my mac and held options and managed to log in to my OS x again but my windows wasn't installed and when i held options while my mac was starting the usb flash drive wasn't there,
-
Cant export to PDF after buying export to pdf
Hi All i am in dire straights i bought export to pdf however it wont work, ive tried doing it several times and it comes up with an error at the end of the upload. Some people say you have a 100mb limit for this my file is only 87mb. some people also
-
[solved] fastboot and rootdelay kernel option
hi to all, i was reading about improving boot time in our archwiki. it says to append in /boot/grub/menu.lst two ''magic'' words: fastboot and rootdelay=N where N are seconds to wait before mount the root. then i modify my .lst and perform a boot tim
-
How to export an array to an excel-sheet
Hallo, does somebody knows how i can write an String[][]-Array in an simple Excel-Table, or knows someone a source where i can find information about the xls-fileformat?