JPanel applied to BorderLayout.WEST covers BorderLayout.NORTH section, why?
I am a newbie to swing, but thought that if you applied a panel to borderlayout.WEST, it would not overwrite another area.
What have I missed, why has may applied panel overwritten borderlayout.NORTH?
Many thanks.
<code>
import java.awt.*;
import javax.swing.*;
public class LayoutTest extends JPanel {
Dimension bd = new Dimension(150,50);
public LayoutTest(){
setLayout(new BorderLayout());
JPanel orderPanel = new JPanel();
orderPanel.setLayout(new BoxLayout(orderPanel, BoxLayout.Y_AXIS));
orderPanel.add(makeButton("rita"));
orderPanel.add(makeButton("bob"));
orderPanel.add(makeButton("sue"));
add(orderPanel, BorderLayout.WEST);
public JButton makeButton(String title) {
JButton b = new JButton(title);
b.setMaximumSize(bd);
b.setMinimumSize(bd);
b.setPreferredSize(bd);
b.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(5,5,5,5),
b.getBorder()));
b.setAlignmentX((float)0.5);
return b;
public static void main(String []args) throws Exception {
JFrame f = new JFrame();
f.setSize(600, 600);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new LayoutTest());
f.show();
</code>
I see, thanks.
I thought each area wouldn't allow you to spill over.
So, if I don't use an area, all other components will use the space, is that right?
If I didn't want anything to populate the NORTH area (can't think of an example why), I guess you would have to add a (any) component to it?
Just modified LayoutTest to populate the NORTH area to, and as you said, it displayed as I initially expected.
It's gonna take a bit of getting used to this Swing business!
Thanks for your help.
<code>
import java.awt.*;
import javax.swing.*;
public class LayoutTest extends JPanel {
Dimension bd = new Dimension(150,50);
public LayoutTest(){
setLayout(new BorderLayout());
JPanel orderPanel = new JPanel();
orderPanel.setLayout(new BoxLayout(orderPanel, BoxLayout.Y_AXIS));
orderPanel.add(makeButton("rita"));
orderPanel.add(makeButton("bob"));
orderPanel.add(makeButton("sue"));
JPanel orderPanel2 = new JPanel();
orderPanel2.add(makeButton("rita"));
orderPanel2.add(makeButton("bob"));
orderPanel2.add(makeButton("sue"));
add(orderPanel, BorderLayout.WEST);
add(orderPanel2, BorderLayout.NORTH);
public JButton makeButton(String title) {
JButton b = new JButton(title);
b.setMaximumSize(bd);
b.setMinimumSize(bd);
b.setPreferredSize(bd);
b.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(5,5,5,5),
b.getBorder()));
b.setAlignmentX((float)0.5);
return b;
public static void main(String []args) throws Exception {
JFrame f = new JFrame();
f.setSize(600, 600);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new LayoutTest());
f.show();
</code>
Similar Messages
-
Add buttons to BorderLayout.NORTH
Hi, I am new to Java. I am using the BorderLayout for my frame. However, I am trying to add two buttons, two comboBoxes, and a checkBox to the NORTH region of the BorderLayout. Can't find anyway to add more than just one to the NORTH in my text book. I use the code below to add them, but the last item added is taking the entire NORTH region and covering the items added previously. If I assign them different regions, then they are all displayed.
add( buttons[ 0 ], BorderLayout.NORTH );
add( buttons[ 1 ], BorderLayout.NORTH );
add( colorComboBox, BorderLayout.NORTH );
add( shapeComboBox, BorderLayout.NORTH );
add( filledCheckBox, BorderLayout.NORTH );
I want to use BorderLayout so I can place a drawing area in the CENTER and the x, y coordinates in the SOUTH.
Thank You,
MikePut the two buttons, two combo boxes, and checkbox into a panel with a FlowLayout, GridLayout, GridBagLayout, whatever layout you wish. Add only that panel to the BorderLayout.NORTH.
-
BorderLayout.NORTH for a Buttonpanel and JMenubar?
Is there a way to make both north?
Thanks.
Here is the relevent code: I tried to make it so that it displays it north then the string read from a file is set to top. But it dosn't display the buttonpanel north.
gameMenu.add(hpset);
gameMenu.add(censor);
menuBar.add(fileMenu);
menuBar.add(modMenu);
menuBar.add(adminCP);
menuBar.add(tools);
adminCP.add(adminCommands);
menuBar.add(gameMenu);
modMenu.add(modCommands);
tools.add(linkTools);
/*Setting censor*/
ButtonGroup censr = new ButtonGroup();
onz = new JRadioButtonMenuItem("On");
onz.setSelected(true);
onz.addActionListener(this);
censr.add(onz);
censor.add(onz);
offz = new JRadioButtonMenuItem("Off");
censr.add(offz);
offz.addActionListener(this);
censor.add(offz);
/*End of setting hp*/
/*Setting hp*/
ButtonGroup hpsel = new ButtonGroup();
hpbar = new JRadioButtonMenuItem("Hitpoints bar");
hpbar.setSelected(true);
hpbar.addActionListener(this);
hpsel.add(hpbar);
hpset.add(hpbar);
numbers = new JRadioButtonMenuItem("Numbers");
hpsel.add(numbers);
numbers.addActionListener(this);
hpset.add(numbers);
/*End of setting hp*/
String place = C();
if(place.startsWith("disable")) {
buttonPanel.setEnabled(false);
System.out.println("Disabling button panel.");
if(place.startsWith("top")) {
frame.getContentPane().add(buttonPanel, BorderLayout.NORTH);
System.out.println("Setting button panel to top.");
} else if(place.startsWith("bottem")) {
frame.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
System.out.println("Setting button panel to bottem.");
if(!place.startsWith("top") && !place.startsWith("bottem") && !place.startsWith("disable")) {
frame.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
System.out.println("No config file found. Setting default bar.");
frame.getContentPane().add(menuBar, BorderLayout.NORTH);
frame.getContentPane().add(gamePanel, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
init();C() is a method which uses bufferedwriter to read the line to see what setting the person wants.
ThanksI can't read that unformatted code, so I can't help you directly, but I get the feeling that you're trying to put both the Buttonpanel and the JMenubar in the same BorderLayout.NORTH position, and you're finding that only the last one entered will be seen. What you need to do instead is create another JPanel, say northPanel, give it a proper layout, say BoxLayout configured to add components along the y-axis (to add a component just below the previous component), add your Buttonpanel and JMenubar to this northPanel and then add the northPanel to the main panel (the frame's contentPane), BorderLayout.NORTH.
Edited by: Encephalopathic on Jun 18, 2008 2:32 PM -
I am unable to apply my downloaded update. When I try to apply it and restart firefox, it still says 'apply downloaded update now...'. Why can't I apply this update and what do I do about it?
Checked out that link and everything seems to be in order on this machine at this time.
I only have CC installed on this one machine, not even my secondary machine like is permitted. it seems odd that I'm asked to re-accept the Licence Agreement as often as I am. If I had to guess, it's almost every week, if not multiple times some weeks, that all the software will decide I should have to view the licence agreement.
Edit: I've never had any noticeable "errors" activating or anything like that. I just get asked to do it quite frequently.
This activation screen isn't too annoying (it involves clicking one single button), but like I stated earlier, if I'm trying to launch the software by double-clicking on a PSD, AI, PPROJ, AEP, etc... that file will fail to open.
I feel like that's probably not really a bug, but it is frustrating, since I did launch the application with the intent to edit that specific file I tried to open.
Again, something that you guys may consider working on.
Another annoyance is that: agreeing to the licence agreement is a per-application task, so if I see that Licence Agreement dialogue window by opening Photoshop (for example), I know that every other piece of software I have in the suite (Illustrator, Premiere, After Effects, Audition) will be showing me that screen on it's next launch. Probably deliberate for legal purposes that I can't just agree once for the whole suite, but heck, it would save me a lot of minor headaches if it was a unified agreement. -
Unable to set JPanel size in BorderLayout.CENTER
I have a class that defines a GUI for a paint-type program. This class extends JPanel. Within the class, I add a JMenu, a vertical JToolbar to the WEST, a JPanel to the SOUTH and lastly, I add the JPanel that the user draws on in the CENTER.
From my understanding of the BorderLayout, the CENTER object will take up the remaining available space. The program is run from an applet (which has a setPreferredSize() but it does not seem to affect anything - I think b/c the size specified for the applet in the HTML override it). Anyway, when I set the size of the applet in the HTML, the JPanel in the SOUTH gets cut off. In order to fit it, I have to make the size of the applet bigger - but that makes my CENTER JPanel too big. I need the CENTER JPanel to be a certain size b/c I'm saving the image - which needs to be a certain size.
I do not understand why the JPanel SOUTH is getting cut off. The JToolBar on the WEST is not that big that it should be governing the size, rather it seems like that JPanel in the CENTER is. I've tried setPreferredSize() and setSize() for that CENTER JPanel, but neither of them seem to help.
I'll appreciate any thoughts/suggestions - I can elaborate or send code if needed. Thank you all in advance.Try using setMinimumSize() and setPreferredSize() for all the other components in the frame other than the CENTER Jpanel. For example, if you want you applet to be 300 pixel high by 500 pixels wide, and you want the centre panel to be 200 x 400 pixels, set the other components as follows:
Dimension westPanelSize = new Dimension(100, 300)); // width x height
westPanel.setMinimumSize(westPanelSize);
westPanel.setPreferredSize(westPanelSize);
�
Dimension southPanelSize = new Dimension(500, 100)); // width x height
southPanel.setMinimumSize(southPanelSize);
southPanel.setPreferredSize(southPanelSize);Good Luck!
- David -
JPanel not resizing BorderLayout.CENTER component
I have a JPanel (panel_1) with a BorderLayout. In response to a mous event, I want to replace the component at BorderLayout.CENTER. I'm tracking which component is currently there, so when i get the event, I remove the component currently there, and then add a different one using add(component, BorderLayout.CENTER), and then for good measure I call getLayout().layoutContainer(this) (where "this" is panel_1). At this point, I've got another JPanel, panel_2, in the CENTER position of PANEL_1, and I can see that it's been resized correctly. However, panel_2 also has a BorderLayout, and has a JScrollPane in it's CENTER position. adding panel_2 to panel_1 at center, and redoing the layout, doesn't resize the ScrollPane inside panel_2, even though panel_2 itself is resized.
Furthermore, in panel_2, I tried overloading setSize(int, int), setSize(Dimension), resize(int, int), resize(Dimension), and even reshape(int, int, int, int), and none of them got called during the layout, but it's size still comes out different on the other side of the layout.
Can anyone suggest a good way to automatically resize the JScrollPane when the parent container (panel_2) is resized? Is this normal behvior? I thought that BorderLayout was supposed to do this automatically?
Message was edited by:
B.MearnsLayoutManagers uses the preferredSize to help layout components. The size means nothing, so using setSize() will not help. You should be using setPreferredSize(...).
You may also want to look at using a [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]Card Layout which is designed to flip back and forth between multiple panels in the same container.
If you need further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the code retains its original formatting. -
I bought my first Iphone - the Iphone S about a month ago. I was able to listen to music no problem. I recently figured out how to get my photos off of my phone and on to my PC, but was prompted to sign up for ICloud to do it. Now when I try to listen to music on my phone, it asks me to download it from Icloud and asks "download over cellular"? "Additional fees may apply when downloading phones over cellular". I've already bought all my music, why would there be more fees and shouldn't ICloud have mentioned this? Seems I need to take a class just to figure all this out.
The clouds you see next to your music on the device and iCloud are two different things. When your music is not on your device it is in iTunes in the Cloud. Not the same thing as iCloud which is used to sync information between devices and house backups of your device contents. So that little cloud you see next to your songs is telling you that the music is not on your device. That's why it is giving you the message - because when you click on it, it is attempting to download it to your device.
What may have happened is when you imported your photos to the PC, you may have sync'd your device via iTunes, and you did not have the Sync Music option checked in your device Profile screen.
Hook up your device to your PC and open iTunes. Make sure the sidebar is showing (Control+S if you cannot see the sidebar with Devices listed), and click on your device to open the Device Profile screens to the right. Click on the Music tab, and make sure that the Sync All Music or Sync Selected Music box is checked. If you have Sync Selected Music checked, then below that, make sure you check all music that you want on your device. Then click on SYNC at the bottom (or APPLY).
Once you have successfully sync'd your music to your device, you will no longer see the cloud next to the songs, and you also will no longer get a message since you will have the songs physically on your device and not in iTunes in the Cloud.
Cheers,
GB -
Link preview in 14.0.1 covers the chat section on facebook
ok I have been looking into how to adjust the link preview in FireFox 14 this has some info https://support.mozilla.org/en-US/questions/803346?as=aaq but I can't find the userChrome.css anywhere I guess it has been removed or something can I either remove link preview or adjust what side and how far it covers?
Hi,
Please see [http://kb.mozillazine.org/index.php?title=UserChrome.css this] for the quick details.
[http://www-archive.mozilla.org/unix/customizing.html Customizing] -
Every time I try to apply a filter of liquify etc program crashes why?
whenever I try to apply a filter ps6 just closes
ok CS6 photoshop has crashed again whilst trying to use liquify. I tested it out in CS5 and it doesn't crash this version. This is the adobe crash report:
Process: AdobeCrashDaemon [420]
Path: /Applications/Adobe Photoshop CS6/Adobe Photoshop CS6.app/Contents/Frameworks/AdobeCrashReporter.framework/Required/AdobeCrashDaemon.app/Co ntents/MacOS/AdobeCrashDaemon
Identifier: AdobeCrashDaemon
Version: ??? (???)
Code Type: X86-64 (Native)
Parent Process: launchd [1]
Date/Time: 2013-03-23 16:38:54.055 +0000
OS Version: Mac OS X 10.6.8 (10K549)
Report Version: 6
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 com.apple.CoreFoundation 0x00007fff81f00c00 CFArrayGetCount + 80
1 com.adobe.AdobeCrashDaemon 0x0000000100003f65 -[MyDaemon getCGWindowListCopyWindowInfo] + 73
2 com.adobe.AdobeCrashDaemon 0x000000010000399c -[MyDaemon GetCrashWindowId] + 40
3 com.adobe.AdobeCrashDaemon 0x00000001000046fc -[MyDaemon waitForCrash] + 714
4 com.adobe.AdobeCrashDaemon 0x0000000100001987 main + 56
5 com.adobe.AdobeCrashDaemon 0x00000001000017a2 _start + 224
6 com.adobe.AdobeCrashDaemon 0x00000001000016c1 start + 33
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000400 rbx: 0x0000000000000000 rcx: 0x00007fff89c95d7a rdx: 0x0000000000000012
rdi: 0x0000000000000000 rsi: 0x00007fff820259dc rbp: 0x00007fff5fbff200 rsp: 0x00007fff5fbff1f0
r8: 0x0000000000000e03 r9: 0x0000000000000000 r10: 0x00007fff81f13080 r11: 0x00007fff81f4ae40
r12: 0x00007fff82130138 r13: 0x00000001001099e0 r14: 0x0000000000000000 r15: 0x0000000000000000
rip: 0x00007fff81f00c00 rfl: 0x0000000000010287 cr2: 0x0000000000000000
Binary Images:
0x100000000 - 0x100007fff +com.adobe.AdobeCrashDaemon ??? (6.20120720) <B880CBFC-FC29-6AFE-B44C-8C1DD5A7F468> /Applications/Adobe Photoshop CS6/Adobe Photoshop CS6.app/Contents/Frameworks/AdobeCrashReporter.framework/Required/AdobeCrashDaemon.app/Co ntents/MacOS/AdobeCrashDaemon
0x7fff5fc00000 - 0x7fff5fc3bdef dyld 132.1 (???) <69130DA3-7CB3-54C8-ABC5-423DECDD2AF7> /usr/lib/dyld
0x7fff80003000 - 0x7fff80003ff7 com.apple.Cocoa 6.6 (???) <68B0BE46-6E24-C96F-B341-054CF9E8F3B6> /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
0x7fff80004000 - 0x7fff80025fe7 libPng.dylib ??? (???) <14F055F9-D7B2-27B2-E2CF-F0A222BFF14D> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.fr amework/Versions/A/Resources/libPng.dylib
0x7fff80026000 - 0x7fff802a8fff com.apple.Foundation 6.6.8 (751.63) <E10E4DB4-9D5E-54A8-3FB6-2A82426066E4> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
0x7fff802b6000 - 0x7fff802bcff7 com.apple.CommerceCore 1.0 (9.1) <3691E9BA-BCF4-98C7-EFEC-78DA6825004E> /System/Library/PrivateFrameworks/CommerceKit.framework/Versions/A/Frameworks/CommerceCor e.framework/Versions/A/CommerceCore
0x7fff80300000 - 0x7fff80314ff7 com.apple.speech.synthesis.framework 3.10.35 (3.10.35) <621B7415-A0B9-07A7-F313-36BEEDD7B132> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynt hesis.framework/Versions/A/SpeechSynthesis
0x7fff80315000 - 0x7fff80315ff7 com.apple.Accelerate.vecLib 3.6 (vecLib 3.6) <4CCE5D69-F1B3-8FD3-1483-E0271DB2CCF3> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Ve rsions/A/vecLib
0x7fff80316000 - 0x7fff80a12ff7 com.apple.CoreGraphics 1.545.0 (???) <58D597B1-EB3B-710E-0B8C-EC114D54E11B> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphi cs.framework/Versions/A/CoreGraphics
0x7fff80a13000 - 0x7fff80a28ff7 com.apple.LangAnalysis 1.6.6 (1.6.6) <1AE1FE8F-2204-4410-C94E-0E93B003BEDA> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalys is.framework/Versions/A/LangAnalysis
0x7fff80b51000 - 0x7fff80b56fff libGFXShared.dylib ??? (???) <6BBC351E-40B3-F4EB-2F35-05BDE52AF87E> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGFXShared.dylib
0x7fff80b57000 - 0x7fff80b5efff com.apple.OpenDirectory 10.6 (10.6) <4FF6AD25-0916-B21C-9E88-2CC42D90EAC7> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory
0x7fff80b69000 - 0x7fff80beeff7 com.apple.print.framework.PrintCore 6.3 (312.7) <CDFE82DD-D811-A091-179F-6E76069B432D> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore. framework/Versions/A/PrintCore
0x7fff8100a000 - 0x7fff81020fef libbsm.0.dylib ??? (???) <42D3023A-A1F7-4121-6417-FCC6B51B3E90> /usr/lib/libbsm.0.dylib
0x7fff81021000 - 0x7fff81025ff7 libmathCommon.A.dylib 315.0.0 (compatibility 1.0.0) <95718673-FEEE-B6ED-B127-BCDBDB60D4E5> /usr/lib/system/libmathCommon.A.dylib
0x7fff81026000 - 0x7fff8103cfe7 com.apple.MultitouchSupport.framework 207.11 (207.11) <8233CE71-6F8D-8B3C-A0E1-E123F6406163> /System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/A/MultitouchSuppor t
0x7fff8103d000 - 0x7fff8105dfff com.apple.DirectoryService.Framework 3.6 (621.15) <9AD2A133-4275-5666-CE69-98FDF9A38B7A> /System/Library/Frameworks/DirectoryService.framework/Versions/A/DirectoryService
0x7fff810c7000 - 0x7fff811e6fe7 libcrypto.0.9.8.dylib 0.9.8 (compatibility 0.9.8) <14115D29-432B-CF02-6B24-A60CC533A09E> /usr/lib/libcrypto.0.9.8.dylib
0x7fff811e7000 - 0x7fff812fdff7 libxml2.2.dylib 10.3.0 (compatibility 10.0.0) <3814FCF9-92B9-A6AB-E76A-F7021894AA3F> /usr/lib/libxml2.2.dylib
0x7fff812fe000 - 0x7fff81354fe7 libTIFF.dylib ??? (???) <9BC0CAD5-47F2-9B4F-0C10-D50A7A27F461> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.fr amework/Versions/A/Resources/libTIFF.dylib
0x7fff81355000 - 0x7fff81380ff7 libxslt.1.dylib 3.24.0 (compatibility 3.0.0) <3630A97F-55C1-3F34-CA63-3847653C9645> /usr/lib/libxslt.1.dylib
0x7fff81388000 - 0x7fff8138bff7 libCoreVMClient.dylib ??? (???) <75819794-3B7A-8944-D004-7EA6DD7CE836> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreVMClient.dylib
0x7fff8141e000 - 0x7fff81538fff libGLProgrammability.dylib ??? (???) <D1650AED-02EF-EFB3-100E-064C7F018745> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLProgrammability.dyl ib
0x7fff816e5000 - 0x7fff81eeffe7 libBLAS.dylib 219.0.0 (compatibility 1.0.0) <FC941ECB-71D0-FAE3-DCBF-C5A619E594B8> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Ve rsions/A/libBLAS.dylib
0x7fff81ef0000 - 0x7fff82067fe7 com.apple.CoreFoundation 6.6.6 (550.44) <BB4E5158-E47A-39D3-2561-96CB49FA82D4> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x7fff82068000 - 0x7fff8208bfff com.apple.opencl 12.3.6 (12.3.6) <42FA5783-EB80-1168-4015-B8C68F55842F> /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL
0x7fff8208c000 - 0x7fff82118fef SecurityFoundation ??? (???) <8A74D45E-9FE9-DD58-42F5-C7474FFDD0C1> /System/Library/Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation
0x7fff8212b000 - 0x7fff821e1ff7 libobjc.A.dylib 227.0.0 (compatibility 1.0.0) <03140531-3B2D-1EBA-DA7F-E12CC8F63969> /usr/lib/libobjc.A.dylib
0x7fff821e2000 - 0x7fff821e2ff7 com.apple.CoreServices 44 (44) <DC7400FB-851E-7B8A-5BF6-6F50094302FB> /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
0x7fff823f6000 - 0x7fff82401ff7 com.apple.speech.recognition.framework 3.11.1 (3.11.1) <3D65E89B-FFC6-4AAF-D5CC-104F967C8131> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognition.frame work/Versions/A/SpeechRecognition
0x7fff8240e000 - 0x7fff8244ffef com.apple.QD 3.36 (???) <5DC41E81-32C9-65B2-5528-B33E934D5BB4> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framewo rk/Versions/A/QD
0x7fff82450000 - 0x7fff8258efff com.apple.CoreData 102.1 (251) <9DFE798D-AA52-6A9A-924A-DA73CB94D81A> /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
0x7fff8258f000 - 0x7fff82651fe7 libFontParser.dylib ??? (???) <EF06F16C-0CC9-B4CA-7BD9-0A97FA967340> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framew ork/Versions/A/Resources/libFontParser.dylib
0x7fff826de000 - 0x7fff826edfef com.apple.opengl 1.6.14 (1.6.14) <ECAE2D12-5BE3-46E7-6EE5-563B80B32A3E> /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
0x7fff826ee000 - 0x7fff826f4ff7 IOSurface ??? (???) <6AF28EC1-BCC4-9F65-AF7D-ABE60B91072A> /System/Library/Frameworks/IOSurface.framework/Versions/A/IOSurface
0x7fff82729000 - 0x7fff827e2fff libsqlite3.dylib 9.6.0 (compatibility 9.0.0) <2C5ED312-E646-9ADE-73A9-6199A2A43150> /usr/lib/libsqlite3.dylib
0x7fff827e3000 - 0x7fff827e3ff7 com.apple.vecLib 3.6 (vecLib 3.6) <96FB6BAD-5568-C4E0-6FA7-02791A58B584> /System/Library/Frameworks/vecLib.framework/Versions/A/vecLib
0x7fff827e4000 - 0x7fff828a1fff com.apple.CoreServices.OSServices 359.2 (359.2) <BBB8888E-18DE-5D09-3C3A-F4C029EC7886> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framew ork/Versions/A/OSServices
0x7fff82900000 - 0x7fff8293bfff com.apple.AE 496.5 (496.5) <208DF391-4DE6-81ED-C697-14A2930D1BC6> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Vers ions/A/AE
0x7fff8293c000 - 0x7fff82c3afff com.apple.HIToolbox 1.6.5 (???) <AD1C18F6-51CB-7E39-35DD-F16B1EB978A8> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Ver sions/A/HIToolbox
0x7fff82c56000 - 0x7fff82cf0fff com.apple.ApplicationServices.ATS 275.19 (???) <2DE8987F-4563-4D8E-45C3-2F6F786E120D> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framew ork/Versions/A/ATS
0x7fff83058000 - 0x7fff83135fff com.apple.vImage 4.1 (4.1) <C3F44AA9-6F71-0684-2686-D3BBC903F020> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Ve rsions/A/vImage
0x7fff83142000 - 0x7fff83167ff7 com.apple.CoreVideo 1.6.2 (45.6) <E138C8E7-3CB6-55A9-0A2C-B73FE63EA288> /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo
0x7fff83168000 - 0x7fff831bbff7 com.apple.HIServices 1.8.3 (???) <F6E0C7A7-C11D-0096-4DDA-2C77793AA6CD> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices .framework/Versions/A/HIServices
0x7fff832b8000 - 0x7fff83655fe7 com.apple.QuartzCore 1.6.3 (227.37) <16DFF6CD-EA58-CE62-A1D7-5F6CE3D066DD> /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
0x7fff8366e000 - 0x7fff83682fff libGL.dylib ??? (???) <2ECE3B0F-39E1-3938-BF27-7205C6D0358B> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
0x7fff838ec000 - 0x7fff8392dfff com.apple.SystemConfiguration 1.10.8 (1.10.2) <78D48D27-A9C4-62CA-2803-D0BBED82855A> /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
0x7fff83c52000 - 0x7fff83c53fff liblangid.dylib ??? (???) <EA4D1607-2BD5-2EE2-2A3B-632EEE5A444D> /usr/lib/liblangid.dylib
0x7fff83e47000 - 0x7fff83e6ffff com.apple.DictionaryServices 1.1.2 (1.1.2) <E9269069-93FA-2B71-F9BA-FDDD23C4A65E> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryService s.framework/Versions/A/DictionaryServices
0x7fff83f52000 - 0x7fff84111fff com.apple.ImageIO.framework 3.0.6 (3.0.6) <2C39859A-043D-0EB0-D412-EC2B5714B869> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.fr amework/Versions/A/ImageIO
0x7fff84112000 - 0x7fff84555fef libLAPACK.dylib 219.0.0 (compatibility 1.0.0) <0CC61C98-FF51-67B3-F3D8-C5E430C201A9> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Ve rsions/A/libLAPACK.dylib
0x7fff84556000 - 0x7fff845d4ff7 com.apple.CoreText 151.13 (???) <5C6214AD-D683-80A8-86EB-328C99B75322> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreText.f ramework/Versions/A/CoreText
0x7fff845d5000 - 0x7fff845d6ff7 com.apple.audio.units.AudioUnit 1.6.7 (1.6.7) <49B723D1-85F8-F86C-2331-F586C56D68AF> /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit
0x7fff847ef000 - 0x7fff84859fe7 libvMisc.dylib 268.0.1 (compatibility 1.0.0) <AF0EA96D-000F-8C12-B952-CB7E00566E08> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Ve rsions/A/libvMisc.dylib
0x7fff849c3000 - 0x7fff84b81fff libicucore.A.dylib 40.0.0 (compatibility 1.0.0) <0B4ABA92-C1F0-4548-A157-0CFD65561DA5> /usr/lib/libicucore.A.dylib
0x7fff84cf3000 - 0x7fff84e28fff com.apple.audio.toolbox.AudioToolbox 1.6.7 (1.6.7) <F4814A13-E557-59AF-30FF-E62929367933> /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
0x7fff84e29000 - 0x7fff84e7eff7 com.apple.framework.familycontrols 2.0.2 (2020) <F09541B6-5E28-1C01-C1AE-F6A2508670C7> /System/Library/PrivateFrameworks/FamilyControls.framework/Versions/A/FamilyControls
0x7fff84e7f000 - 0x7fff84e80ff7 com.apple.TrustEvaluationAgent 1.1 (1) <5952A9FA-BC2B-16EF-91A7-43902A5C07B6> /System/Library/PrivateFrameworks/TrustEvaluationAgent.framework/Versions/A/TrustEvaluati onAgent
0x7fff84f82000 - 0x7fff84f93ff7 libz.1.dylib 1.2.3 (compatibility 1.0.0) <97019C74-161A-3488-41EC-A6CA8738418C> /usr/lib/libz.1.dylib
0x7fff851d7000 - 0x7fff85bd1ff7 com.apple.AppKit 6.6.8 (1038.36) <4CFBE04C-8FB3-B0EA-8DDB-7E7D10E9D251> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
0x7fff85bd2000 - 0x7fff85c32fe7 com.apple.framework.IOKit 2.0 (???) <4F071EF0-8260-01E9-C641-830E582FA416> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
0x7fff85c33000 - 0x7fff85c38fff libGIF.dylib ??? (???) <5B2AF093-1E28-F0CF-2C13-BA9AB4E2E177> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.fr amework/Versions/A/Resources/libGIF.dylib
0x7fff85c39000 - 0x7fff85ceefe7 com.apple.ink.framework 1.3.3 (107) <8C36373C-5473-3A6A-4972-BC29D504250F> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/ A/Ink
0x7fff85d52000 - 0x7fff85d54fff libRadiance.dylib ??? (???) <61631C08-60CC-D122-4832-EA59824E0025> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.fr amework/Versions/A/Resources/libRadiance.dylib
0x7fff85d55000 - 0x7fff85e3afef com.apple.DesktopServices 1.5.11 (1.5.11) <39FAA3D2-6863-B5AB-AED9-92D878EA2438> /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopService sPriv
0x7fff85e3e000 - 0x7fff85e44ff7 com.apple.DiskArbitration 2.3 (2.3) <857F6E43-1EF4-7D53-351B-10DE0A8F992A> /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
0x7fff85e45000 - 0x7fff85e54fff com.apple.NetFS 3.2.2 (3.2.2) <7CCBD70E-BF31-A7A7-DB98-230687773145> /System/Library/Frameworks/NetFS.framework/Versions/A/NetFS
0x7fff85f43000 - 0x7fff85f8aff7 com.apple.coreui 2 (114) <923E33CC-83FC-7D35-5603-FB8F348EE34B> /System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI
0x7fff85f8b000 - 0x7fff8600afe7 com.apple.audio.CoreAudio 3.2.6 (3.2.6) <79E256EB-43F1-C7AA-6436-124A4FFB02D0> /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
0x7fff87122000 - 0x7fff8716cff7 com.apple.Metadata 10.6.3 (507.15) <DE238BE4-5E22-C4D5-CF5C-3D50FDEE4701> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framewor k/Versions/A/Metadata
0x7fff8716d000 - 0x7fff8721dfff edu.mit.Kerberos 6.5.11 (6.5.11) <085D80F5-C9DC-E252-C21B-03295E660C91> /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos
0x7fff8721e000 - 0x7fff87552fef com.apple.CoreServices.CarbonCore 861.39 (861.39) <1386A24D-DD15-5903-057E-4A224FAF580B> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framew ork/Versions/A/CarbonCore
0x7fff87627000 - 0x7fff87673fff libauto.dylib ??? (???) <F7221B46-DC4F-3153-CE61-7F52C8C293CF> /usr/lib/libauto.dylib
0x7fff87756000 - 0x7fff8776ffff com.apple.CFOpenDirectory 10.6 (10.6) <401557B1-C6D1-7E1A-0D7E-941715C37BFA> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/Frameworks/CFOpenDirectory. framework/Versions/A/CFOpenDirectory
0x7fff87770000 - 0x7fff87831fef com.apple.ColorSync 4.6.8 (4.6.8) <7DF1D175-6451-51A2-DBBF-40FCA78C0D2C> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync. framework/Versions/A/ColorSync
0x7fff8795b000 - 0x7fff8795bff7 com.apple.Accelerate 1.6 (Accelerate 1.6) <15DF8B4A-96B2-CB4E-368D-DEC7DF6B62BB> /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
0x7fff880f9000 - 0x7fff8811afff libresolv.9.dylib 41.1.0 (compatibility 1.0.0) <9410EC7F-4D24-6740-AFEE-90405750FAD7> /usr/lib/libresolv.9.dylib
0x7fff88abb000 - 0x7fff88b8ffe7 com.apple.CFNetwork 454.12.4 (454.12.4) <C83E2BA1-1818-B3E8-5334-860AD21D1C80> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CFNetwork.framewo rk/Versions/A/CFNetwork
0x7fff88b90000 - 0x7fff88bc1fff libGLImage.dylib ??? (???) <562565E1-AA65-FE96-13FF-437410C886D0> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib
0x7fff88be7000 - 0x7fff88c30fef libGLU.dylib ??? (???) <B0F4CA55-445F-E901-0FCF-47B3B4BAE6E2> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
0x7fff88c31000 - 0x7fff88c3fff7 libkxld.dylib ??? (???) <8145A534-95CC-9F3C-B78B-AC9898F38C6F> /usr/lib/system/libkxld.dylib
0x7fff890b5000 - 0x7fff890effff libcups.2.dylib 2.8.0 (compatibility 2.0.0) <4F2A4397-89BD-DEAC-4971-EE838FFA0964> /usr/lib/libcups.2.dylib
0x7fff891f0000 - 0x7fff8926dfef libstdc++.6.dylib 7.9.0 (compatibility 7.0.0) <35ECA411-2C08-FD7D-11B1-1B7A04921A5C> /usr/lib/libstdc++.6.dylib
0x7fff89aa1000 - 0x7fff89ae9ff7 libvDSP.dylib 268.0.1 (compatibility 1.0.0) <98FC4457-F405-0262-00F7-56119CA107B6> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Ve rsions/A/libvDSP.dylib
0x7fff89aea000 - 0x7fff89b7afff com.apple.SearchKit 1.3.0 (1.3.0) <4175DC31-1506-228A-08FD-C704AC9DF642> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framewo rk/Versions/A/SearchKit
0x7fff89b7b000 - 0x7fff89c1bfff com.apple.LaunchServices 362.3 (362.3) <B90B7C31-FEF8-3C26-BFB3-D8A48BD2C0DA> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.fr amework/Versions/A/LaunchServices
0x7fff89c1c000 - 0x7fff89c6bff7 com.apple.DirectoryService.PasswordServerFramework 6.1 (6.1) <01B370FB-D524-F660-3826-E85B7F0D85CD> /System/Library/PrivateFrameworks/PasswordServer.framework/Versions/A/PasswordServer
0x7fff89c6c000 - 0x7fff89c6cff7 com.apple.ApplicationServices 38 (38) <10A0B9E9-4988-03D4-FC56-DDE231A02C63> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
0x7fff89c6d000 - 0x7fff89c94ff7 libJPEG.dylib ??? (???) <472D4A31-C1F3-57FD-6453-6621C48B95BF> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.fr amework/Versions/A/Resources/libJPEG.dylib
0x7fff89c95000 - 0x7fff89e56fef libSystem.B.dylib 125.2.11 (compatibility 1.0.0) <9AB4F1D1-89DC-0E8A-DC8E-A4FE4D69DB69> /usr/lib/libSystem.B.dylib
0x7fff89e57000 - 0x7fff89e69fe7 libsasl2.2.dylib 3.15.0 (compatibility 3.0.0) <76B83C8D-8EFE-4467-0F75-275648AFED97> /usr/lib/libsasl2.2.dylib
0x7fff8a3ec000 - 0x7fff8a675ff7 com.apple.security 6.1.2 (55002) <772E1B13-8271-02F8-B1FE-023592A7AED7> /System/Library/Frameworks/Security.framework/Versions/A/Security
0x7fffffe00000 - 0x7fffffe01fff libSystem.B.dylib ??? (???) <9AB4F1D1-89DC-0E8A-DC8E-A4FE4D69DB69> /usr/lib/libSystem.B.dylib
Msny thanks -
Spry navigation covers flash movie element, why?
i have a spry navigation bar with a flash movie underneath,
and when i hover over the navbar and the submenu pops down it
covers the flash movie, but it doesn't cover the .jpg image that is
next to the flash movie. how can i fix this? thanks.mediastream13,
> i have a spry navigation bar with a flash movie
underneath,
> and when i hover over the navbar and the submenu pops
> down it covers the flash movie, but it doesn't cover the
.jpg
> image that is next to the flash movie.
What you're seeing is the result of the default WMODE
setting for Flash
Player, which you can change. Keep in mind, Flash content
isn't something
any browser natively supports. It requires an ActiveX
component or plugin,
and as a result, is processed outside of the browser's
composition buffer.
This lifts Flash content (and other active content, like
QuickTime, Java
applets, and so on) from the context of its surroundings. To
change that,
you can configure a SWF's WMODE setting for transparent or
opaque, as
described here:
http://www.quip.net/blog/2006/flash/how-to-position-flash-beneath-other-content
Be aware that any WMODE setting other than the default has
been known to
cause usability issues as described in the articles/blog
entries further
linked from the above URL.
David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design." -
Loading up an image into a Jpanel!! HELP!!
Hi,
With regards to the following code, I was wondering if anyone could help me. I am in the early stages of making a basic Image Editing program, and have managed to implement the following code. The thing is, when you load up an image, it seems to always position it in the top left corner of the container - overwiting all menus, buttons placed underneath. Why is this??
I need the image to appear in the JPanel/canvas below the toolbar and not on top of it!!
I hope someone out there can help me!
Thanks,
a very confused girl :(
SAMPLE CODE:-
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import java.util.*;
import javax.imageio.ImageIO;
import java.net.*;
import javax.swing.filechooser.*;
public class ImageMaker extends JFrame implements ActionListener
String kBanner = "ImageMaker v1.0";
JPanel contentPane;
JButton loadButton;
JToolBar toolBar;
JMenuBar menuBar;
JMenu fileMenu;
JMenuItem fileOpenMenuItem;
public BufferedImage mBufferedImage;
public ImageMaker(String fileName)
Container appWindow = getContentPane();
setTitle(kBanner);
appWindow.setLayout(new BorderLayout(5,5));
menuBar = new JMenuBar();
setJMenuBar(menuBar);
fileMenu = new JMenu("File");
menuBar.add(fileMenu);
fileOpenMenuItem = new JMenuItem("Open");
fileMenu.add(fileOpenMenuItem);
fileOpenMenuItem.addActionListener(this);
toolBar = new JToolBar();
loadButton = new JButton("Open");
loadButton.addActionListener(this);
toolBar.add(loadButton);
contentPane = new JPanel();
appWindow.add( BorderLayout.NORTH, toolBar);
appWindow.add( BorderLayout.SOUTH, contentPane);
public void loadImage(String fileName)
Image image = Toolkit.getDefaultToolkit().getImage(fileName);
MediaTracker mt = new MediaTracker(this);
mt.addImage(image, 0);
try { mt.waitForID(0); }
catch (InterruptedException ie) { return; }
if (mt.isErrorID(0)) return;
mBufferedImage = new BufferedImage(image.getWidth(null),
image.getHeight(null),
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = mBufferedImage.createGraphics();
g2.drawImage(image, null, null);
validate();
repaint();
setTitle(kBanner + ": " + fileName);
public void paint(Graphics g)
super.paint(g);
if (mBufferedImage == null) return;
Insets insets = getInsets();
g.drawImage(mBufferedImage, insets.left, insets.top, null);
public void actionPerformed(ActionEvent ae)
JFileChooser fd = new JFileChooser();
int returnVal=fd.showOpenDialog(ImageMaker.this);
if(returnVal==JFileChooser.APPROVE_OPTION)
if (fd.getSelectedFile() == null)
{ return; }
File file=fd.getSelectedFile();
String path=(String)file.getPath();
loadImage(path);
JMenu men = (JMenu) ae.getSource();
String label = (String) men.getText();
JButton butt = (JButton) ae.getSource();
String butt2 = (String) butt.getText();
if (label.equals("Open"))
else if (label.equals("Save"))
}//end ActionListener
public static void main(String[] args)
String fileName = "default";
if (args.length > 0) fileName = args[0];
ImageMaker img=new ImageMaker(fileName);
img.setSize(800,600);
img.show();
}Hi,
Thank you for your help.
I have done what you suggested and created this code below using the paintComponent.
It compiles, but when i run it i get an error ("Uncaught error fetching image: java.lang.NullPointerExecption"). I was hoping you could advise me further as i am really struggling to get this basic app running propely.
Thanks againfor your help.
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import java.util.*;
import javax.imageio.ImageIO;
import java.net.*;
import javax.swing.filechooser.*;
import javax.swing.plaf.basic.*;
public class TLookupOp extends JFrame
{ DisplayPanel displayPanel;
JButton loadButton;
public BufferedImage mBufferedImage;
Graphics2D g2;
String path;
JFileChooser fd;
public TLookupOp()
{super("Test");
Container container=getContentPane();
container.setLayout(new BorderLayout(5,5));
displayPanel=new DisplayPanel(path);
container.add(displayPanel);
JPanel panel=new JPanel();
loadButton = new JButton("Open");
loadButton.addActionListener(new ActionListener()
{public void actionPerformed(ActionEvent ae)
fd = new JFileChooser();
int returnVal=fd.showOpenDialog(TLookupOp.this);
if(returnVal==JFileChooser.APPROVE_OPTION )
if (fd.getSelectedFile() == null)
{ return; }
File file=fd.getSelectedFile();
path=(String)file.getPath();
//displayPanel=new DisplayPanel(path);
//displayPanel.loadImage(path);
loadButton.setToolTipText("Click to load an image.");
panel.add(loadButton);
container.add( BorderLayout.NORTH, panel);
addWindowListener(new WindowEventHandler());
setSize(displayPanel.getWidth(),displayPanel.getHeight()+25);
show();
class WindowEventHandler extends WindowAdapter
{public void windowClosing(WindowEvent e)
{System.exit(0);
public static void main(String[] args)
{new TLookupOp();
class DisplayPanel extends JPanel
{Image image;
BufferedImage mBufferedImage;
Graphics2D g2;
String filepath;
DisplayPanel(String path)
{ filepath=path;
loadImage(filepath);
setSize(image.getWidth(this), image.getWidth(this));
createBufferedImage();
public void loadImage(String fileName)
Image image = Toolkit.getDefaultToolkit().getImage(fileName);
MediaTracker mt = new MediaTracker(this);
mt.addImage(image, 0);
try { mt.waitForID(0); }
catch (InterruptedException ie) { return; }
if (mt.isErrorID(0)) return;
public void createBufferedImage()
{mBufferedImage=new BufferedImage(image.getWidth(null),
image.getHeight(null),
BufferedImage.TYPE_INT_RGB);
g2 = mBufferedImage.createGraphics();
g2.drawImage(image,0,0,this);
public void paintComponent(Graphics g)
super.paintComponent(g);
Graphics2D g2D=(Graphics2D) g;
g2D.drawImage(mBufferedImage,0,0,this);
} -
Good Morning Everyone:
I have a question in regards to Java Frames. I have just created a button in my princial frame and pressing this button creates another Frame. I have two questions relating to these resulting frame:
1)Every time I close the new frame, the old one closes with that one too. Is there a way that I can restrict the "X" button on the top-right corner of the frame?
2)How can I change the co-ordinates of the new frame so that when it appears, it doesn't overlap the existing one? (In other words, I would like to frame to open to the right of the existing frame).
I would highly appreciate a response.
CordiallyDear Walken16:
I went through the codes and suggestions you posted meticulously. However, I have to lament that it didn't help me in trtying to sour my problem out. What happens is that in my situation, when the user presses a button in the main frame, a second frame appears. However, when one presses the "X" in the second frame, this causes both frames to disappear whereas we only want the second frame to disappear. Below is the code pertaining the second frame that emerges when a button in the first frame is pressed:
package ca.inasec.ui.conference;
import java.awt.*;
import javax.swing.border.BevelBorder;
import java.awt.event.*;
import javax.swing.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.io.*;
import java.util.StringTokenizer;
import ca.inasec.server.behaviour.*;
import ca.inasec.ui.whiteboard.*;
import ca.inasec.ui.*;
//import ca.inasec.server.*;
import ca.inasec.utilities.*;
import ca.inasec.models.*;
import ca.inasec.audio.*;
//import ca.inasec.net.*;
import ca.inasec.packetsource.JavaFrameSource;
//import ca.inasec.net.IPLister;
import java.util.Date;
public class MyPageFrame extends JFrame{
public MyPageFrame(){
super(" My Page");
//The Image "Q" will be associated with this frame as well. Hence, it awaits implementation
//setIconImage(ImageLoader.load("images\\mainIcon.gif", this));
setLayout(new BorderLayout());
setSize(470, 658);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0); return;
setVisible(true);
setResizable(false);
//Let's create 5 panels satisfying the requirements of the BorderLayout
//First, an array of panels
JPanel TheNorth =new JPanel();
JPanel TheSouth= new JPanel();
JPanel TheCenter = new JPanel();
JPanel TheEast = new JPanel();
JPanel TheWest = new JPanel();
add(TheNorth, BorderLayout.NORTH);
add(TheSouth, BorderLayout.SOUTH);
add(TheCenter, BorderLayout.CENTER);
add(TheEast, BorderLayout.EAST);
add(TheWest, BorderLayout.WEST);
//Now, the work to be done in the south panel
TheSouth.setLayout(new BorderLayout());
TheSouth.setPreferredSize(new Dimension(400, 90));
JButton QWebsite = new JButton("AWebsite");
JLabel Copyright = new JLabel ("Copyright 2005. A Website");
Copyright.setFont(new Font("Arial", Font.ITALIC, 10));
JLabel Rights = new JLabel ("ALL RIGHTS RESERVED");
QWebsite.setPreferredSize(new Dimension(110, 30));
QWebsite.setFont(new Font("Garamond", Font.BOLD, 14));
//Let's also create two extra panels to satsfy the requirements of BorderLayout
JPanel ExtraPanelA = new JPanel();
JPanel ExtraPanelB = new JPanel();
ExtraPanelA.setPreferredSize(new Dimension(80, 130));
ExtraPanelB.setPreferredSize(new Dimension(80, 130));
//ExtraPanelA.setBackground(Color.red);
//ExtraPanelB.setBackground(Color.green);
JPanel CenterOfTheSouth = new JPanel();
TheSouth.add(CenterOfTheSouth, BorderLayout.CENTER);
CenterOfTheSouth.add(AWebsite);
CenterOfTheSouth.add(Copyright);
CenterOfTheSouth.add(Rights);
TheSouth.add(ExtraPanelA, BorderLayout.EAST);
TheSouth.add(ExtraPanelB, BorderLayout.WEST);
TheNorth.setPreferredSize(new Dimension(400, 70));
TheCenter.setPreferredSize(new Dimension(100, 200));
TheCenter.setBackground(Color.BLUE);
TheCenter.setBorder(BorderFactory.createLineBorder(Color.black, 1));
//AddWindow Listener
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0); return;
} -
FillOval blinks and disappears when I compile and run JApplet
public void paint(Graphics graf)
graf.setColor(Color.blue);
graf.fillOval(300,200,50,50);
}When I run the JApplet the oval blinks and disappears. I have tried repaint but this makes the whole container white and the oval can be seen then. I have used JPanels on BorderLayout NORTH, SOUTH and WEST all with an orange background colour. It's as though the oval goes behind the content pane.
Edited by: Aurora88 on Feb 3, 2008 3:50 PMpublic void init()
mainNorth = new JPanel();
add(mainNorth, BorderLayout.NORTH);
mainNorth.setBackground(Color.orange);
mainNorth.add(title1);
mainSouth = new JPanel();
add(mainSouth, BorderLayout.SOUTH);
copyright = new JLabel("? 2008 Frenzy Fours");
copyright.setFont(new Font("Verdana", Font.PLAIN, 9));
mainSouth.add(copyright, BorderLayout.SOUTH);
mainSouth.setBackground(Color.orange);
mainCenter = new JPanel();
add(mainCenter, BorderLayout.CENTER);
mainCenter.setBackground(Color.orange);
mainEast = new JPanel();
add(mainEast, BorderLayout.EAST);
mainEast.setBackground(Color.orange);
public void paint(Graphics g)
g.setColor(Color.blue);
g.fillOval(300,200,100,10);
}The blue oval blinks and disappears when the applet is run. I don't know why. I've fiddled with the paintComponent() but no luck... -
JscrollPane Inside Jscrollpane
Hi all,
my project include a few panels and a few jscrollpanes.
one of the issues is to make an outer jscrollpane that will include another panel and this panel will include another jscrollpane that will conatin a jtree.
the problem that i deal with :
im not getting the inner jscrollpane only the outer scrollbar.
i was thinking that it might be depend on setPreferredSize().
if you have any suggestion ill be glad to try.
my code:
work with eclipse3.2
package test;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JToolBar;
import javax.swing.JTree;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.TableColumnModelEvent;
import javax.swing.event.TableColumnModelListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.tree.DefaultMutableTreeNode;
public class BaseFrame extends JFrame {
// Specify the look and feel to use. Valid values:
// null (use the default), "Metal", "System", "Motif", "GTK+"
final static String LOOKANDFEEL = "System";
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private boolean Maximized=false;
private JToolBar jToolBar = null;
private JButton jButton = null;
private JPanel jPanel = null;
private JPanel jPanelProgressBar = null; //instead of jPanel1
private JLabel jLabel = null;
private JTextArea jTextArea = null;
private JLabel jLabel1 = null;
private JProgressBar jProgressBar = null;
private JLabel jLabel2 = null;
private JProgressBar jProgressBar1 = null;
private JPanel jTableTreeResultPanel = null;
private JPanel jTablePanel = null;
private JScrollPane jTableScrollPane = null;
private JTable jTable = null;
* This is the default constructor
public BaseFrame() {
super();
initialize();
* This method initializes this
* @return void
private void initialize() {
initLookAndFeel();
//CATCH MAXIMIZE WINDOW EVENT
addWindowStateListener(new WindowAdapter()
public void windowStateChanged(WindowEvent e)
if(e.getNewState() == Frame.NORMAL)
System.out.println("Window is Normal");
Maximized=false;
else if(e.getNewState() == Frame.MAXIMIZED_BOTH)
System.out.println("Window is Maximized");
Maximized=true;
public void windowClosing(WindowEvent e)
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setPreferredSize(new Dimension(680, 530));
//this.setSize(300, 200);
this.setSize(680, 560);
this.setContentPane(getJContentPane());
this.setTitle("JFrame");
private void initLookAndFeel() {
String lookAndFeel = null;
if (LOOKANDFEEL != null) {
if (LOOKANDFEEL.equals("Metal")) {
lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
} else if (LOOKANDFEEL.equals("System")) {
lookAndFeel = UIManager.getSystemLookAndFeelClassName();
} else if (LOOKANDFEEL.equals("Motif")) {
lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
} else if (LOOKANDFEEL.equals("GTK+")) { //new in 1.4.2
lookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
} else {
System.err.println("Unexpected value of LOOKANDFEEL specified: "
+ LOOKANDFEEL);
lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
try {
UIManager.setLookAndFeel(lookAndFeel);
} catch (ClassNotFoundException e) {
System.err.println("Couldn't find class for specified look and feel:"
+ lookAndFeel);
System.err.println("Did you include the L&F library in the class path?");
System.err.println("Using the default look and feel.");
} catch (UnsupportedLookAndFeelException e) {
System.err.println("Can't use the specified look and feel ("
+ lookAndFeel
+ ") on this platform.");
System.err.println("Using the default look and feel.");
} catch (Exception e) {
System.err.println("Couldn't get specified look and feel ("
+ lookAndFeel
+ "), for some reason.");
System.err.println("Using the default look and feel.");
e.printStackTrace();
* This method initializes jContentPane
* @return javax.swing.JPanel
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.add(getJToolBar(), BorderLayout.NORTH);
jContentPane.add(getJPanel(), BorderLayout.CENTER);
jContentPane.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentResized(java.awt.event.ComponentEvent e) {
System.out.println("componentResized()"); // TODO Auto-generated Event stub componentResized()
Component GetComp=e.getComponent();
ExtendTableColumns(GetComp);
return jContentPane;
* This method initializes jToolBar
* @return javax.swing.JToolBar
private JToolBar getJToolBar() {
if (jToolBar == null) {
jToolBar = new JToolBar();
// jToolBar.setMinimumSize(new Dimension(405, 40));
jToolBar.add(getJButton());
return jToolBar;
* This method initializes jButton
* @return javax.swing.JButton
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setIcon(new ImageIcon(getClass().getResource("/test/button_help.gif")));
return jButton;
* This method initializes jPanel
* @return javax.swing.JPanel
private JPanel getJPanel() {
if (jPanel == null) {
jPanel = new JPanel();
jPanel.setLayout(new BorderLayout());
jPanel.add(getJPanelProgressBar(), BorderLayout.NORTH);
jPanel.add(getJTableTreeResultPanel(), BorderLayout.CENTER);
return jPanel;
* This method initializes jPanel1
* @return javax.swing.JPanel
private JPanel getJPanelProgressBar() {
if (jPanelProgressBar == null) {
GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
gridBagConstraints5.gridy = 2;
gridBagConstraints5.insets = new Insets(3, 3, 3, 3);
gridBagConstraints5.gridx = 1;
GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
gridBagConstraints4.gridx = 0;
gridBagConstraints4.fill = GridBagConstraints.HORIZONTAL;
gridBagConstraints4.gridy = 2;
jLabel2 = new JLabel();
jLabel2.setText("Batch Progress:");
GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
gridBagConstraints3.gridx = 1;
gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL;
gridBagConstraints3.anchor = GridBagConstraints.EAST;
gridBagConstraints3.insets = new Insets(3, 3, 3, 3);
gridBagConstraints3.gridy = 1;
GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
gridBagConstraints2.gridy = 1;
gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL;
gridBagConstraints2.insets = new Insets(1, 1, 0, 0);
jLabel1 = new JLabel();
jLabel1.setText("Test Progress:");
GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
gridBagConstraints1.insets = new Insets(1, 1, 0, 0);
gridBagConstraints1.weightx = 0.0D;
gridBagConstraints1.weighty = 0.0D;
gridBagConstraints1.anchor = GridBagConstraints.WEST;
gridBagConstraints1.fill = GridBagConstraints.NONE;
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
gridBagConstraints.weighty = 1.0D;
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new Insets(3, 3, 3, 3);
gridBagConstraints.weightx = 1.0D;
jLabel = new JLabel();
jLabel.setText("Current Test:");
jPanelProgressBar = new JPanel();
jPanelProgressBar.setLayout(new GridBagLayout());
jPanelProgressBar.setName("PanelMainNorth");
// jPanelProgressBar.setMinimumSize(new Dimension(405, 66));
jPanelProgressBar.add(jLabel, gridBagConstraints1);
jPanelProgressBar.add(getJTextArea(), gridBagConstraints);
jPanelProgressBar.add(jLabel1, gridBagConstraints2);
jPanelProgressBar.add(getJProgressBar(), gridBagConstraints3);
jPanelProgressBar.add(jLabel2, gridBagConstraints4);
jPanelProgressBar.add(getJProgressBar1(), gridBagConstraints5);
return jPanelProgressBar;
* This method initializes jTextArea
* @return javax.swing.JTextArea
private JTextArea getJTextArea() {
if (jTextArea == null) {
jTextArea = new JTextArea();
jTextArea.setBorder(BorderFactory.createLineBorder(Color.gray, 2));
return jTextArea;
* This method initializes jProgressBar
* @return javax.swing.JProgressBar
private JProgressBar getJProgressBar() {
if (jProgressBar == null) {
jProgressBar = new JProgressBar();
return jProgressBar;
* This method initializes jProgressBar1
* @return javax.swing.JProgressBar
private JProgressBar getJProgressBar1() {
if (jProgressBar1 == null) {
jProgressBar1 = new JProgressBar();
return jProgressBar1;
* This method initializes jTreeResultPanel
* @return javax.swing.JPanel
private JPanel getJTableTreeResultPanel() {
if (jTableTreeResultPanel == null) {
jTableTreeResultPanel = new JPanel();
jTableTreeResultPanel.setLayout(new BorderLayout());
jTableTreeResultPanel.setName("Tree Display Panel");
jTableTreeResultPanel.setForeground(new Color(51, 51, 51));
jTableTreeResultPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
jTableTreeResultPanel.setPreferredSize(new Dimension(687, 417));
jTableTreeResultPanel.setPreferredSize(new Dimension(669, 31));
jTableTreeResultPanel.add(getJTablePanel(), BorderLayout.NORTH);
jTableTreeResultPanel.add(getJTreeResultScrollPane(), BorderLayout.CENTER);
return jTableTreeResultPanel;
* This method initializes jTablePanel
* @return javax.swing.JPanel
private JPanel getJTablePanel() {
if (jTablePanel == null) {
GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
gridBagConstraints12.anchor = GridBagConstraints.WEST;
gridBagConstraints12.gridheight = 1;
gridBagConstraints12.gridwidth = 4;
gridBagConstraints12.gridx = -1;
gridBagConstraints12.gridy = -1;
gridBagConstraints12.weightx = 1.0D;
gridBagConstraints12.weighty = 1.0D;
gridBagConstraints12.insets = new Insets(0, 0, -10, 0);
gridBagConstraints12.fill = GridBagConstraints.BOTH;
jTablePanel = new JPanel();
jTablePanel.setLayout(new GridBagLayout());
// jTablePanel.setPreferredSize(new Dimension(660, 20));
jTablePanel.add(getJTableScrollPane(), gridBagConstraints12);
return jTablePanel;
* This method initializes getJTableScrollPane
* @return javax.swing.JScrollPane
private JScrollPane getJTableScrollPane() {
if (jTableScrollPane == null) {
jTableScrollPane = new JScrollPane();
jTableScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
jTableScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
// jTableScrollPane.setPreferredSize(new Dimension(660, 40));
jTableScrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
// jTableScrollPane.setMinimumSize(new Dimension(405, 4));
jTableScrollPane.setViewportView(getJTable());
return jTableScrollPane;
* This method initializes jTable
* @return javax.swing.JTable
TableColumn DiagTreeColumn = null; // @jve:decl-index=0:
TableColumn LastResultcolumn = null; // @jve:decl-index=0:
TableColumn Passcolumn = null; // @jve:decl-index=0:
TableColumn Failcolumn = null; // @jve:decl-index=0:
private JTable getJTable() {
String[] columnNames = {"Diagnostics Tree",
"Last Result",
"# Pass",
"# Fail"
Object[][] data = {};
if (jTable == null) {
jTable = new JTable(data,columnNames);
jTable.setPreferredScrollableViewportSize(new Dimension(10,10));
jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
jTable.getTableHeader().setReorderingAllowed( false );
//ALLIGN ALL THE TITLES TO CENTER
DefaultTableCellRenderer TableRenderer=(DefaultTableCellRenderer)jTable.getTableHeader().getDefaultRenderer();
TableRenderer.setHorizontalAlignment(JLabel.CENTER);
//resize the first column (Diagnostics Tree)
DiagTreeColumn = jTable.getColumnModel().getColumn(0);
DiagTreeColumn.setMinWidth(30);
DiagTreeColumn.setPreferredWidth(285);
DiagTreeColumn.setResizable(true);
//resize the second column (Last Result)
LastResultcolumn = jTable.getColumnModel().getColumn(1);
LastResultcolumn.setPreferredWidth(125);
LastResultcolumn.setResizable(true);
//resize the second column (#Pass)
Passcolumn = jTable.getColumnModel().getColumn(2);
Passcolumn.setPreferredWidth(125);
Passcolumn.setResizable(true);
//resize the second column (#Fail)
Failcolumn = jTable.getColumnModel().getColumn(3);
Failcolumn.setPreferredWidth(125);
Failcolumn.setResizable(true);
jTable.getColumnModel().addColumnModelListener(new TableColumnModelListener(){
public void columnMarginChanged(ChangeEvent e)
// int getColumnWidth;
//for Diagnostics Tree
// int getTreeScrollHight;//, getTreeScrollWidth;
//for Last result
// int getResultScrollHight, getResultScrollWidth;
//for #Pass
// int getPassScrollHight, getPassScrollWidth;
//for #Fail
// int getFailScrollHight;//, getFailScrollWidth;
System.out.println("im columnMarginChanged");
// TableColumn resizingColumn = jTable.getTableHeader().getResizingColumn();
if(resizingColumn!=null)
int modelindx=resizingColumn.getModelIndex();
//FOR THE FIRST COLUMN("Diagnostics Tree")
if(modelindx==0)
System.out.println("we are in Diagnostics Tree Column0");
getColumnWidth=resizingColumn.getWidth();
// int getTreeScrollWidth=jTreeScrollPane.getWidth();
getTreeScrollHight=jTreeScrollPane.getHeight();
jTreePanel.setSize(getColumnWidth, getTreeScrollHight);
jTreePanel.setPreferredSize(new Dimension(getColumnWidth, getTreeScrollHight));
jTreePanel.validate();
jTreePanel.repaint();
//move the all panel jResultPanel
Point ResultPanelLocation=jResultPanel.getLocation();
jResultPanel.setLocation(jTreeScrollPane.getWidth(), ResultPanelLocation.y);
jResultPanel.setSize(jResultPanel.getWidth(),jResultPanel.getHeight());
jResultPanel.setPreferredSize(new Dimension(jResultPanel.getWidth(),jResultPanel.getHeight()));
//FOR THE SeCOND COLUMN("Last Result")
if(modelindx==1)
System.out.println("we are in Last Result Column");
getColumnWidth=resizingColumn.getWidth();
getResultScrollHight=jResultListScrollPane.getHeight();
getResultScrollWidth=jResultListScrollPane.getWidth();
jResultListScrollPane.setSize(new Dimension(getColumnWidth,getResultScrollHight));
jResultListScrollPane.setPreferredSize(new Dimension(getColumnWidth,getResultScrollHight));
jResultListScrollPane.validate();
//ALSO MOVE THE PASS LIST
Point ResultListScrollPaneLocation=jResultListScrollPane.getLocation();
getPassScrollWidth=jPassListScrollPane.getWidth();
Point PassListScrollPaneLocation=jPassListScrollPane.getLocation();
jPassListScrollPane.setLocation(ResultListScrollPaneLocation.x+getResultScrollWidth, PassListScrollPaneLocation.y);
jPassListScrollPane.validate();
//ALSO MOVE THE FAIL LIST
Point FailListScrollPaneLocation=jFailListScrollPane.getLocation();
jFailListScrollPane.setLocation(PassListScrollPaneLocation.x+getPassScrollWidth, FailListScrollPaneLocation.y);
jFailListScrollPane.validate();
//FOR THE THIRD COLUMN("#Pass")
if(modelindx==2)
System.out.println("we are in #Pass Column");
getColumnWidth=resizingColumn.getWidth();
getPassScrollHight=jPassListScrollPane.getHeight();
getPassScrollWidth=jPassListScrollPane.getWidth();
jPassListScrollPane.setSize(new Dimension(getColumnWidth,getPassScrollHight));
jPassListScrollPane.setPreferredSize(new Dimension(getColumnWidth,getPassScrollHight));
Point PassListScrollPaneLocation=jPassListScrollPane.getLocation();
jPassListScrollPane.validate();
Point FailListScrollPaneLocation=jFailListScrollPane.getLocation();
jFailListScrollPane.setLocation(PassListScrollPaneLocation.x+getPassScrollWidth, FailListScrollPaneLocation.y);
jFailListScrollPane.validate();
//FOR THE FOURTH COLUMN("#Fail")
if(modelindx==3)
System.out.println("we are in #Fail Column");
getColumnWidth=resizingColumn.getWidth();
getFailScrollHight=jFailListScrollPane.getHeight();
// int getFailScrollWidth=jFailListScrollPane.getWidth();
jFailListScrollPane.setSize(new Dimension(getColumnWidth,getFailScrollHight));
jFailListScrollPane.setPreferredSize(new Dimension(getColumnWidth,getFailScrollHight));
jFailListScrollPane.validate();
public void columnSelectionChanged(ListSelectionEvent e)
System.out.println("in columnSelectionChanged");
public void columnAdded(TableColumnModelEvent e)
System.out.println("in columnAdded");
public void columnMoved(TableColumnModelEvent e)
System.out.println("in columnMoved");
public void columnRemoved(TableColumnModelEvent e)
System.out.println("in columnRemoved");
return jTable;
String[] columnNames = {"Diagnostics Tree","Last Result",
"# Pass","# Fail"};
Object[][] data = {};
private void createNodes(DefaultMutableTreeNode top) {
DefaultMutableTreeNode category = null;
DefaultMutableTreeNode SubCategory = null;
DefaultMutableTreeNode SubSubCategoryBasee = null;
DefaultMutableTreeNode SubCategory2 = null;
category = new DefaultMutableTreeNode("Dfe");
top.add(category);
//Sub test visible
SubCategory = new DefaultMutableTreeNode("Test Visible");
category.add(SubCategory);
SubCategory.add(new DefaultMutableTreeNode("Son 1"));
SubCategory.add(new DefaultMutableTreeNode("Son 2"));
SubSubCategoryBasee = new DefaultMutableTreeNode("Test Base");
SubSubCategoryBasee.add(new DefaultMutableTreeNode("Grandson 1"));
SubSubCategoryBasee.add(new DefaultMutableTreeNode("Grandson 2"));
SubCategory.add(SubSubCategoryBasee);
//Sub test visible
SubCategory2 = new DefaultMutableTreeNode("Test Visible2");
category.add(SubCategory2);
SubCategory2.add(new DefaultMutableTreeNode("Son 1"));
SubCategory2.add(new DefaultMutableTreeNode("Son 2"));
SubSubCategoryBasee = new DefaultMutableTreeNode("Test Base");
SubSubCategoryBasee.add(new DefaultMutableTreeNode("Grandson 1"));
SubSubCategoryBasee.add(new DefaultMutableTreeNode("Grandson 2345678910111213141516171920212223242526"));
SubCategory2.add(SubSubCategoryBasee);
private DefaultMutableTreeNode top; // @jve:decl-index=0:
// private DefaultListModel listModel=null;
private int prevWidth=0;
private JScrollPane jTreeResultScrollPane = null;
private JPanel jTreeResultPanel = null;
private JScrollPane jTreeScrollPanel = null;
private JTree jTree = null;
/********WHEN WE MAKE THE RESIZE AND SHRINK
* WE MAKE IT FOR THREE COMPONENTS:
* 1)FOR THE TREECOLUMN
* 2)FOR THE TREEPANEL
* 3)IF during the maximize process we resize some columns
* we have to keep it when we back to original state
* for example:
* if we maximize the window and resize the last result column
* when we back the previous state we shell keep the same size
* AS THE COULMN SIZE
* WE HAVE TO DO THAT FOR ALL THE THREE LIST COMPONENT
* @param GetComp
private void ExtendTableColumns(Component GetComp)
int getComponentWidth;
int getComponentHeight;
int DiagTreeColumnWidth;
getComponentWidth=GetComp.getWidth();
getComponentHeight=GetComp.getHeight();
if(getComponentHeight!=0)
System.out.println("jTreeResultsScrollPane height="+jTreeResultsScrollPane.getHeight());
System.out.println("jTreePanel height="+jTreePanel.getHeight());
System.out.println("jTreeScrollPane height="+jTreeScrollPane.getHeight());
if(prevWidth!=0 && (prevWidth!=getComponentWidth) )
/* System.out.println("GetTreescrollwidthfrom resize="+jTreeScrollPane.getWidth());
System.out.println("DiagTreeColumn1 ="+DiagTreeColumn.getWidth());
System.out.println("jTreeScrollPane width ="+jTreeScrollPane.getWidth());
// System.out.println("ResultList width ="+jResultList.getWidth());
System.out.println("Last Result column width ="+LastResultcolumn.getWidth());
DiagTreeColumnWidth= DiagTreeColumn.getWidth();
DiagTreeColumn.setWidth(DiagTreeColumnWidth+(getComponentWidth-prevWidth));
DiagTreeColumn.setPreferredWidth(DiagTreeColumnWidth+(getComponentWidth-prevWidth));
GetComp.invalidate();
GetComp.validate();
GetComp.repaint();
System.out.println("DiagTreeColumn2 ="+DiagTreeColumn.getWidth());
jTreePanel.setSize(DiagTreeColumnWidth+(getComponentWidth-prevWidth), jTreeScrollPane.getHeight());
jTreePanel.setPreferredSize(new Dimension(DiagTreeColumnWidth+(getComponentWidth-prevWidth), jTreeScrollPane.getHeight()));
jTreePanel.invalidate();
jTreePanel.validate();
jTreePanel.repaint();
//IN ORDER TO KEEP CONSTARINT 3
//WE MAKE THE LIST WIDTH THE SAME AS THE COLUMN SIZE
jResultListScrollPane.setSize(LastResultcolumn.getWidth(), jResultList.getHeight());
jResultListScrollPane.setPreferredSize(new Dimension(LastResultcolumn.getWidth(),jResultList.getHeight()));
jResultListScrollPane.invalidate();
jResultListScrollPane.validate();
jResultListScrollPane.repaint();
jPassListScrollPane.setSize(Passcolumn.getWidth(), jPassList.getHeight());
jPassListScrollPane.setPreferredSize(new Dimension(Passcolumn.getWidth(),jPassList.getHeight()));
jPassListScrollPane.invalidate();
jPassListScrollPane.validate();
jPassListScrollPane.repaint();
jFailListScrollPane.setSize(Failcolumn.getWidth(), jFailList.getHeight());
jFailListScrollPane.setPreferredSize(new Dimension(Failcolumn.getWidth(),jFailList.getHeight()));
jFailListScrollPane.invalidate();
jFailListScrollPane.validate();
jFailListScrollPane.repaint();
/* if(DiagTreeColumn.getWidth()==DiagTreeColumn.getMinWidth())
jTreePanel.setSize(jTreePanel.getMinimumSize().width, jTreePanel.getHeight());
jTreePanel.setPreferredSize(new Dimension(jTreePanel.getMinimumSize().width, jTreePanel.getHeight()));
jTreePanel.invalidate();
jTreePanel.validate();
jTreePanel.repaint();
/* jContentPane.invalidate();
jContentPane.validate();
jContentPane.repaint();*/
prevWidth=getComponentWidth;
private JScrollPane getJTreeResultScrollPane() {
if (jTreeResultScrollPane == null) {
jTreeResultScrollPane = new JScrollPane();
// jTreeResultScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
// jTreeResultScrollPane.setPreferredSize(new Dimension(160, 415));
// jTreeResultScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
// jTreeResultScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
jTreeResultScrollPane.setViewportView(getJTreeResultPanel());
return jTreeResultScrollPane;
* This method initializes jTreeResultPanel
* @return javax.swing.JPanel
private JPanel getJTreeResultPanel() {
if (jTreeResultPanel == null) {
GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
gridBagConstraints6.fill = GridBagConstraints.BOTH;
gridBagConstraints6.weighty = 1.0;
gridBagConstraints6.weightx = 1.0;
jTreeResultPanel = new JPanel();
jTreeResultPanel.setLayout(new GridBagLayout());
jTreeResultPanel.add(getJTreeScrollPanel(), gridBagConstraints6);
return jTreeResultPanel;
* This method initializes jTreeScrollPanel
* @return javax.swing.JScrollPane
private JScrollPane getJTreeScrollPanel() {
if (jTreeScrollPanel == null) {
jTreeScrollPanel = new JScrollPane();
// jTreeScrollPanel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
jTreeScrollPanel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
jTreeScrollPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
jTreeScrollPanel.setPreferredSize(new Dimension(280, 403));
// jTreeScrollPanel.setPreferredSize(new Dimension(142, 387));
// jTreeScrollPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
// jTreeScrollPanel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
jTreeScrollPanel.setViewportView(getJTree());
return jTreeScrollPanel;
* This method initializes jTree
* @return javax.swing.JTree
private JTree getJTree() {
if (jTree == null) {
top = new DefaultMutableTreeNode("DIAGNOSTICS TREE");
createNodes(top);
jTree = new JTree(top);
jTree.setPreferredSize(new Dimension(250, 20));
//expand all nodes
int row=0;
while (row<jTree.getRowCount()) {
jTree.expandRow(row);
row++;
return jTree;
private JTree getJTree() {
if (jTree == null) {
top = new DefaultMutableTreeNode("DIAGNOSTICS TREE");
createNodes(top);
jTree = new JTree(top);
//expand all nodes
int row=0;
while (row<jTree.getRowCount()) {
jTree.expandRow(row);
row++;
return jTree;
}this is the relevant piece of code:
jTreeResultScrollPane.setViewportView(getJTreeResultPanel());
return jTreeResultScrollPane;
* This method initializes jTreeResultPanel
* @return javax.swing.JPanel
private JPanel getJTreeResultPanel() {
if (jTreeResultPanel == null) {
GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
gridBagConstraints6.fill = GridBagConstraints.BOTH;
gridBagConstraints6.weighty = 1.0;
gridBagConstraints6.weightx = 1.0;
jTreeResultPanel = new JPanel();
jTreeResultPanel.setLayout(new GridBagLayout());
jTreeResultPanel.add(getJTreeScrollPanel(), gridBagConstraints6);
return jTreeResultPanel;
* This method initializes jTreeScrollPanel
* @return javax.swing.JScrollPane
private JScrollPane getJTreeScrollPanel() {
if (jTreeScrollPanel == null) {
jTreeScrollPanel = new JScrollPane();
// jTreeScrollPanel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
jTreeScrollPanel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
jTreeScrollPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
jTreeScrollPanel.setPreferredSize(new Dimension(280, 403));
// jTreeScrollPanel.setPreferredSize(new Dimension(142, 387));
// jTreeScrollPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
// jTreeScrollPanel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
jTreeScrollPanel.setViewportView(getJTree());
return jTreeScrollPanel;
* This method initializes jTree
* @return javax.swing.JTree
private JTree getJTree() {
if (jTree == null) {
top = new DefaultMutableTreeNode("DIAGNOSTICS TREE");
createNodes(top);
jTree = new JTree(top);
jTree.setPreferredSize(new Dimension(250, 20));
//expand all nodes
int row=0;
while (row<jTree.getRowCount()) {
jTree.expandRow(row);
row++;
return jTree;
}hope it is clear now -
Open and display image in MVC layout
Hello!
I cant figure out how I shall do this in an MVC layout:
The program request user to open an image file that are then displayed in a JLabel
My setup at the moment resolve in a nullpointerexeption because it dont get any actual image file, but I dont understand what I have missed.
I can not post the whole code fo you to run because it is to big, so I post the part that are the most important. please have a look.
PicturePanel
//Import Java library
import javax.swing.*;
import java.awt.*;
public class PicturePanel extends JPanel {
//Variables
private ImageIcon picture;
//Method to get information of the selected file
PicturePanel (String fileName) {
picture = new ImageIcon (fileName); //Get the filename
int w = picture.getIconWidth(); //Get the image with
int h = picture.getIconHeight(); //Get the image height
//Set preferable size for the image (Use the properties for the selected image)
setPreferredSize(new Dimension(w, h));
setMinimumSize(new Dimension(w, h));
setMaximumSize(new Dimension(w, h));
//Method to draw the selected image
protected void paintComponent(Graphics g) {
super.paintComponent(g); //We invoke super in order to: Paint the background, do custom painting.
g.drawImage(picture.getImage(), 0, 0, this); //Draw the image at its natural state
}From my model:
//Local attributes
boolean check = false; //Used to see if a statement is true or not
PicturePanel pp;
JFileChooser fc;
int returnVal;
//newFile in File menu
public void newFile() {
//Open a file dialog in users home catalog
fc = new JFileChooser();
//In response to a button click:
returnVal = fc.showOpenDialog(pp);
System.out.println("You pressed new in file menu");
}From my controler:
//User press "New" in File menu
else if (user_action.equals("New")) {
//Call method in model class
model.newFile();
//Update changes
if (model.returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println("Hello1");
File f = model.fc.getSelectedFile();
if (model.pp != null)
model.pp = new PicturePanel(f.getAbsolutePath());
System.out.println("Hello2");
//Display image (Here is line 83)
view.setImage_DisplayArea(model.pp);
System.out.println("Hello3");
}From my view:
//Sets the image to be displayed on the image_display area (Here is line 302)
public void setImage_DisplayArea(PicturePanel pp) {
image_display.add(pp);
}The complet error:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.awt.Container.addImpl(Container.java:1015)You pressed new in file menu
Hello1
Hello2
at java.awt.Container.add(Container.java:351)
at View_Inlupp2.setImage_DisplayArea(View_Inlupp2.java:302)
at Control_Inlupp2.actionPerformed(Control_Inlupp2.java:83)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1882)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2202)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.AbstractButton.doClick(AbstractButton.java:334)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1050)
at apple.laf.CUIAquaMenuItem.doClick(CUIAquaMenuItem.java:119)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1091)
at java.awt.Component.processMouseEvent(Component.java:5602)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3129)
at java.awt.Component.processEvent(Component.java:5367)
at java.awt.Container.processEvent(Container.java:2010)
at java.awt.Component.dispatchEventImpl(Component.java:4068)
at java.awt.Container.dispatchEventImpl(Container.java:2068)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3936)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)
at java.awt.Container.dispatchEventImpl(Container.java:2054)
at java.awt.Window.dispatchEventImpl(Window.java:1801)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)Edited by: onslow77 on Dec 16, 2009 5:00 PM
Edited by: onslow77 on Dec 16, 2009 5:04 PMHello again!
Anyone that can help me figure out how to implement this in an MVC layout, I feel stuck.
I post a little program that open and display an image file so that you better can understand what I whant to do.
ShowImage
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import javax.swing.filechooser.*;
public class ShowImage extends JFrame{
//Variables
JFileChooser fc = new JFileChooser();
PicturePanel pp = null;
ShowImage () {
super("Show"); //Title
//Create the GUI
JPanel top = new JPanel();
add(top, BorderLayout.NORTH);
JButton openBtn = new JButton("Open");
top.add(openBtn);
openBtn.addActionListener(new Listner());
//Settings for the GUI
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
setVisible(true);
class Listner implements ActionListener {
public void actionPerformed(ActionEvent ave) {
int answer = fc.showOpenDialog(ShowImage.this);
if (answer == JFileChooser.APPROVE_OPTION){
File f = fc.getSelectedFile();
//Check
System.out.println(f);
System.out.println(pp);
if (pp != null)
remove(pp); //Clean so that we can open another image
//Check
System.out.println(pp);
//Set the PicturePanel
pp = new PicturePanel(f.getAbsolutePath());
//Check
System.out.println(pp);
//Add PicturePanel to frame
add(pp, BorderLayout.CENTER);
validate();
pack();
repaint();
//Main
public static void main(String[] args) {
new ShowImage();
}PicturePanel
//Import Java library
import javax.swing.*;
import java.awt.*;
public class PicturePanel extends JPanel {
//Variables
private ImageIcon picture;
//Method to get information of the selected file
PicturePanel (String fileName) {
picture = new ImageIcon (fileName); //Get the filename
int w = picture.getIconWidth(); //Get the image with
int h = picture.getIconHeight(); //Get the image height
//Set preferable size for the image (Use the properties for the selected image)
setPreferredSize(new Dimension(w, h));
setMinimumSize(new Dimension(w, h));
setMaximumSize(new Dimension(w, h));
//Method to draw the selected image
protected void paintComponent(Graphics g) {
super.paintComponent(g); //We invoke super in order to: Paint the background, do custom painting.
g.drawImage(picture.getImage(), 0, 0, this); //Draw the image at its natural state
}//The endEdited by: onslow77 on Dec 16, 2009 7:30 PM
Maybe you are looking for
-
I'm using the latest iTunes on Windows 8. Since upgrading to iTunes 12 my old system of smart playlists within folders have not worked properly. I used to have a folder containing three folders with smart playlists in them, but I had to abandon this
-
Difference between Standard PI 7.31 SP14 Rest adapter VS Advantco Rest Adapter
Hi, I have a requirement which need to connect Restful webservices( JSon format). and my current version is on PI 7.31 SP11 I have to chose the best options of REST adapter which is avialable in the market. So far I identifyed two options one is '3rd
-
Interesting Lync client "Bug" with Timezones with Fix.
Running Lync Client v4.0.7577.4087 User called stating he was unable to log into Lync and was getting a message about the Clock on his PC being wrong. He verified his time was correct but continued to get the error. I looked at the machine, he live
-
Rebuilding Catalogue in PSE 12
Every time I start up the Catalogue it takes ages re-building its content, and always ends up with "missing files". Why is this, and can it be put right?
-
Preload to Memory ( is that even possible ) ?
So I noticed with the app I am working on. There are some stutters the first time a section animates on the stage. Once its been seen on the stage is performs great for the duration of the session. is there a way to preload all these moviec