Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Swing Window Grey Only Resizing Helps

Swing Window Grey Only Resizing Helps
Thread Tools
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Jan 24, 2004, 01:21 PM
 
I'm trying to run a Swing application on Panther that spawns a window with a standard XY plot. On launch, the window shows up all grey (nothing drawn inside). I can only see the plot's grid while I'm dragging the bottom-right corner of the window i.e. a resize operation. As soon as I let go, the window greys out again.

I know server side java but not a heck of lot about swing. Can anyone offer any insight or clues? I do have access to the source code.

Thanks!
iMac 17" G4 800MHZ & 768 SDRAM
     
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status: Offline
Reply With Quote
Jan 24, 2004, 10:28 PM
 
most likely a JDK bug...there are tons.
signatures are a waste of bandwidth
especially ones with political tripe in them.
     
Registered User
Join Date: Feb 2003
Status: Offline
Reply With Quote
Jan 26, 2004, 12:49 AM
 
This is what I use to achieve a similar effect of positioning a new window on a screen. You may be able to build from it.

Look specifically at the java.awt.Toolkit theKit = getToolkit(); line and associated lines. Currently it positions the window center of screen. Just play with the math's and you can place it anywhere.

------------------------------

public class AboutBox extends javax.swing.JFrame implements java.awt.event.ActionListener {

protected static int aboutWidth = 280;
protected static int aboutHeight = 230;

public AboutBox() {
super("");
this.setTitle("About Red Rover");
this.setResizable(false);
AboutBox.SymWindow aSymWindow = new AboutBox.SymWindow();
this.addWindowListener(aSymWindow);
this.pack();

java.awt.Toolkit theKit = getToolkit();
int yPos = (int) (new java.awt.Dimension(theKit.getScreenSize())).getHei ght() / 2 - aboutHeight / 2;
int xPos = (int) (new java.awt.Dimension(theKit.getScreenSize())).getWid th() / 2 - aboutWidth / 2;
this.setLocation(xPos, yPos);
this.setSize(aboutWidth, aboutHeight);

javax.swing.JLabel aboutLabel[];
int labelCount = 4;

aboutLabel = new javax.swing.JLabel[labelCount];

aboutLabel[0] = new javax.swing.JLabel("Red Rover");
aboutLabel[0].setFont(StyleUtil.LARGE_SYSTEM_BOLD);
aboutLabel[0].setAlignmentX(java.awt.Component.CENTER_ALIGNMENT );

aboutLabel[1] = new javax.swing.JLabel("Version 0.01");
aboutLabel[1].setFont(StyleUtil.SMALL_SYSTEM);
aboutLabel[1].setAlignmentX(java.awt.Component.CENTER_ALIGNMENT );

aboutLabel[2] = new javax.swing.JLabel("Developed by Helmut Kurt Burri");
aboutLabel[2].setFont(StyleUtil.SMALL_SYSTEM_BOLD);
aboutLabel[2].setAlignmentX(java.awt.Component.CENTER_ALIGNMENT );

aboutLabel[3] = new javax.swing.JLabel("and distributed under a Lesser GNU Licence");
aboutLabel[3].setFont(StyleUtil.SMALL_SYSTEM_BOLD);
aboutLabel[3].setAlignmentX(java.awt.Component.CENTER_ALIGNMENT );

/**
* Button launches links to web-site for
* more information on product
*/
javax.swing.JButton moreInfoButton = new javax.swing.JButton();
moreInfoButton = StyleUtil.aquaButton("More Info...", true, false);
moreInfoButton.addActionListener(new MoreInfo());
moreInfoButton.setAlignmentX(java.awt.Component.CE NTER_ALIGNMENT);

javax.swing.JButton aboutWindowIcon = new javax.swing.JButton(new javax.swing.ImageIcon(System.getProperty("image.pa th") + "aboutWindowIcon.png"));
aboutWindowIcon.addActionListener(new MoreInfo());
aboutWindowIcon.setAlignmentX(java.awt.Component.C ENTER_ALIGNMENT);

//Put everything together, using the content pane's BorderLayout.
java.awt.Container contentPanel = getContentPane();
contentPanel.setLayout(new javax.swing.BoxLayout(contentPanel, javax.swing.BoxLayout.Y_AXIS));

contentPanel.add(aboutWindowIcon);
contentPanel.add(aboutLabel[0]);
contentPanel.add(javax.swing.Box.createRigidArea(n ew java.awt.Dimension(0, 6)));
contentPanel.add(aboutLabel[1]);
contentPanel.add(aboutLabel[2]);
contentPanel.add(javax.swing.Box.createRigidArea(n ew java.awt.Dimension(0, 6)));
contentPanel.add(moreInfoButton);
contentPanel.add(javax.swing.Box.createRigidArea(n ew java.awt.Dimension(0, 6)));
contentPanel.add(aboutLabel[3]);

}

class MoreInfo implements java.awt.event.ActionListener {

public MoreInfo() {
}

public void actionPerformed(java.awt.event.ActionEvent e) {

try {
AssortedUtil.openURL("http://www.apple.com.au");
} catch (Exception e1) {
e1.printStackTrace();
}


}
}

class SymWindow extends java.awt.event.WindowAdapter {
public void windowClosing(java.awt.event.WindowEvent event) {
setVisible(false);
}
}

public void actionPerformed(java.awt.event.ActionEvent newEvent) {
setVisible(false);
}
}
------------------------------
     
DaGuy  (op)
Senior User
Join Date: Oct 2000
Location: Lawrence, KS
Status: Offline
Reply With Quote
Jan 26, 2004, 01:14 AM
 
Thanks, that tip could be a potential work around.
iMac 17" G4 800MHZ & 768 SDRAM
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:53 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2