RE: How to display JPopupMenu properly (size) in model JDialog box?

2002-02-12 Thread Keith Bennett

Akochai -

Attached are some modifications to your file.  Please check out my comments,
especially in the last method.

Why do you want to add a button to a menu?  Isn't that what a menu item is
anyway?

- Keith Bennett


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of akokchai
Sent: Tuesday, February 12, 2002 5:13 PM
To: [EMAIL PROTECTED]
Subject: How to display JPopupMenu properly (size) in model JDialog box?


The size of the PopupMenu is 1000,1000. but it can't show entire. I know
it's because it's in the model
JDialog. But I don't know how to solve it.. Please help me.. Thank you.

public class PopupMenuFrame extends javax.swing.JFrame {
public PopupMenuFrame() {
super();

java.awt.Container c = getContentPane();
c.setLayout(new java.awt.BorderLayout());

javax.swing.JButton button = new javax.swing.JButton("Click me");
button.addActionListener(new java.awt.event.ActionListener() {
 public void actionPerformed(java.awt.event.ActionEvent e) {
  showOptionPane();
 }
});
c.add(java.awt.BorderLayout.CENTER, button);
}

public static void main(String[] args) {
PopupMenuFrame frame = new PopupMenuFrame();
frame.setSize(new java.awt.Dimension(200,200));
frame.setVisible(true);
}

private void showOptionPane() {
final javax.swing.JPanel pane = new javax.swing.JPanel();
pane.setLayout(new java.awt.BorderLayout());

javax.swing.JButton button = new javax.swing.JButton("Click me");
button.addActionListener(new java.awt.event.ActionListener() {
 public void actionPerformed(java.awt.event.ActionEvent e) {
  showPopupMenu(pane);
 }
});
pane.add(java.awt.BorderLayout.CENTER, button);
javax.swing.JOptionPane.showConfirmDialog(this, pane);
}

private void showPopupMenu(java.awt.Component c) {
javax.swing.JPopupMenu menu = new javax.swing.JPopupMenu();
javax.swing.JButton button = new javax.swing.JButton();
button.setPreferredSize(new java.awt.Dimension(1000,1000));
menu.add(button);
menu.show(c, 0, 0);
}
}



PopupMenuFrame.java
Description: Binary data


RE: Design guidelines

2002-02-12 Thread Jackson, Martin

Arnit,

Some of these comments may be lame or real obvious.  I've been at this (Java
Development) 
a while (since 1996), but still have much to learn.

-- Read O'Reilly's book Java Performance Tuning by Jack Shirazi  (Pg. 18-19
has a good check list)
This will help you get the mindset and attitude to shift focus from
"construction worker" to "quality assurance".   

-- Attend some of the performance sessions at JavaOne March 22-29
The points people make during talks will wind up in next year's
books.  The new products (JVM etc) all have their improvements.  This might
affect how you optimize.

-- Use a profiler.  Every project is different. Where the location of the
bottle neck will suprise you. (Especially, 
if you learn from your mistakes).
I personally like JProbe the best (use the built in java -Xrunhprof
until a purchase is made)
80% of the bottle neck will be in 20% of the code
Algorithm improvements will give you the best performance
improvements.

-- Avoid creating Objects, even if it is better OOD
Just like placing a Database design in 3rd normal form, then
implementing 
a not so "perfect" design that queries faster.  
Do your object design and then deconstruct some of the objects in
favor of performance.  
For example, you temporarily need a collection of (X,Y) graph points
and you 
create a Vector of Points (where Points is a class with int x and
int y).
Try using int x[20];int y[20] instead.   If this was in you most
used routine, 
major improvement -- and the code is still easy to read and
maintain.
Same goes for String concatenation.  That's why StringBuffer was
added.

Perceived Performance
Use a simple splash screen during initial startup,  build the rest of the
application in a background thread.
Stop optimizing when the improvements are less than 20% -- it is no longer
noticeable to the user
The wall clock time is your best and only real measure
System.getcurrentTimeMillis()


Hope this helps,
Martin

> -Original Message-
> From: Amit Rana [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, February 11, 2002 11:34 PM
> To:   [EMAIL PROTECTED]
> Subject:  Design guidelines
> Importance:   High
> 
> Hi,
>  
> 1.Can anyone give some guidelines or points to remember while
> designing/scheduling a Swing project.
> 2.Points to remember to get better performance and better memory
> utilization?
>  
> Regards,
> Amit.
___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing



Re: Design guidelines

2002-02-12 Thread Christian Pesch

Amit Rana schrieb:

>1.Can anyone give some guidelines or points to remember while
> designing/scheduling a Swing project.

- Make use cases before designing your gui
- Get user feedback as early as possible

>2.Points to remember to get better performance and better memory
> utilization?

- Do not assume, memory gets freed automatically
- Always remove your listeners
- Finalizers are not the way to free memory
- Put long-lasting actions into separate threads
- Never forget to switch to the AWT Eventqueue before modifying the GUI.

--
Christian Pesch - Software Engineer
CoreMedia AG - http://www.coremedia.com - 0700-COREMEDIA
___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing



Re: Design guidelines

2002-02-12 Thread Marie Alm

There are also 3 good articles in the JavaWorld archives.
http://www.javaworld.com/javaworld/jw-01-2001/jw-0112-performance.html?
--
Marie.
~~/\~~O-O~~~
A. Marie Alm, Sr. Software Engineer
0-In Design Automation, San Jose, Ca.
"Zero-In"   http://www.0-In.com
Tel: 408.487.3608
~~\/

Amit wrote:

Hi,

1.Can anyone give some guidelines or points to remember while
designing/scheduling a Swing
project.
2.Points to remember to get better performance and better memory
utilization?

Regards,
Amit.

___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing



Re: Design guidelines

2002-02-12 Thread Marie Alm

This link should work better:
http://click.idg.email-publisher.com/maaag7EaaRafPa9JE6eb/

--
Marie.
~~/\~~O-O~~~
A. Marie Alm, Sr. Software Engineer
0-In Design Automation, San Jose, Ca.
"Zero-In"   http://www.0-In.com
Tel: 408.487.3608
~~\/

Marie Alm wrote:

> There are also 3 good articles in the JavaWorld archives.
> http://www.javaworld.com/javaworld/jw-01-2001/jw-0112-performance.html?
> --
> Marie.
> ~~/\~~O-O~~~
> A. Marie Alm, Sr. Software Engineer
> 0-In Design Automation, San Jose, Ca.
> "Zero-In"   http://www.0-In.com
> Tel: 408.487.3608
> ~~\/
>
> Amit wrote:
>
> Hi,
>
> 1.Can anyone give some guidelines or points to remember while
> designing/scheduling a Swing
> project.
> 2.Points to remember to get better performance and better memory
> utilization?
>
> Regards,
> Amit.
>
> ___
> Advanced-swing mailing list
> [EMAIL PROTECTED]
> http://eos.dk/mailman/listinfo/advanced-swing

___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing