RE: Combo Box

2001-07-05 Thread Ma, Ancheng

You may want to try the following:

In your container: getRootPane().setDefaultButton(okButton). 

Note: I assume you have a button called OK (okButton) on your GUI. When
you select an item in your combobox and hit ENTER, it acts like clicking
the OK button.

Hope this may give you some help.

Ancheng Ma
White Rock Networks, Inc.
Dallas. 

-Original Message-
From: Preeti Pujni [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 05, 2001 5:10 AM
To: [EMAIL PROTECTED]
Subject: Combo Box


Hi , 

I have a  Editable Combo Box with an action listenser added to it. 
I want the event to fire only on Enter key but that does not happen. 
I have added the KeyListener also but it does not work. 

Can u tell me how can i do that ? 

Preeti 


___
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



Re: Combo Box

2001-07-05 Thread Steve Barrett

I think you maight have to perform the following

JTextField jtf = 
   (JTextField)combobox.getEditor().getEditorComponent();

and then add the listeners to it. 


--- Preeti Pujni [EMAIL PROTECTED] wrote:
 Hi , 
 
 I have a  Editable Combo Box with an action listenser added to it. 
 I want the event to fire only on Enter key but that does not
 happen. 
 I have added the KeyListener also but it does not work. 
 
 Can u tell me how can i do that ? 
 
 Preeti 
 
 
 ___
 Advanced-swing mailing list
 [EMAIL PROTECTED]
 http://eos.dk/mailman/listinfo/advanced-swing


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
___
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing



Re: Adding and Removing Lists

2001-07-05 Thread Doug Fields

The easiest thing to do, IMO, is create several list objects, and 
setVisible one of them at a time.

Doug

At 06:52 AM 7/3/2001, Greg Munt wrote:
Or use a tabbed pane..?

-Original Message-
From: Arnaud Hallais [EMAIL PROTECTED]
To: [EMAIL PROTECTED] [EMAIL PROTECTED]
Date: Monday, July 02, 2001 08:53
Subject: Re: Adding and Removing Lists


 You need as many ListModel as you have different contents but only one
JList
 object (to display the contents)
 
 I would suggest something like this
 
 class MyGui extend JFrame {
 
 private Vector m_listModels;  // vector of ListModel objects
 private int m_currentListModel;
 private JList m_list;
 
 
 public MyGui () {
 m_list = new JList();
 m_currentListModel = -1;
 m_listModel = new Vector();
 
 getContentPane().add(m_list);
 
 JButton nextButton = new JButton();
 nextButton.addActionListener() {new ActionListener() {
   public void actionPerformed(ActionEvent ae) {
 if (m_listModels.size() != 0 and m_currentListModel+1 
 m_listModels.size())
 
 m_list.setListModel((ListModel)m_listModel.elementAt(m_currentListModel++))
;
   }
 }
 getContentPane().add(nextButton);
 }
 
 public void main(String args) {
  (new MyGui()).show();
 }
 
 
 I don't even think this is compiling but it will give you a start
 
 In the m_listModels vector you put ListModel object . There is a default
 implementation of this interface DefaultListModel which works like a
vector:
 add(Object o), remove(Object o), elementAt(i)  ...
 
 
 bye
 - Original Message -
 From: Is'haaq Suleiman [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Sunday, July 01, 2001 11:50 AM
 Subject: Adding and Removing Lists
 
 
  Dear members.
 
  I am using a JList component, and I have defined
  categories of lists(e.g list1,list2,list3,list4, etc).
  I want only one list to  be displayed at a time. And
  if the user clicks button marked next, the next list
  should be displayed replacing  the previous one.
 
  Could you please write me the codes which can solve
  ths problem?
 
  Thanx(ishaaq)
 
  __
  Do You Yahoo!?
  Get personalized email addresses from Yahoo! Mail
  http://personal.mail.yahoo.com/
  ___
  Swing mailing list
  [EMAIL PROTECTED]
  http://eos.dk/mailman/listinfo/swing
 
 ___
 Swing mailing list
 [EMAIL PROTECTED]
 http://eos.dk/mailman/listinfo/swing

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


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



Why text(label) in JTree is not displaying as expected

2001-07-05 Thread Ravi Prakash

Hi all,

I am reading the directory structure and displaying in Jtree.
for e.g root dir(/) and two files abc.txt and b.java and i am also
displaying two files
abc.txt and b.java

for example

abc.txt20bytes2001-06-03 11.30 PM
b.java 345  bytes2001-06-03 12.30 PM


i am sending this str to be displayed in the tree.

when the jtree displays the string it is not displaying correctly and it
is displaying on its own, i have even calculated the length the string
and if the length of the string is less than 50 then i will add spaces
to make the length of the string to be 50.  even then it is displaying
incorrectly.


/
abc.txt20bytes  2001-06-03 11.30 PM
b.java345bytes2001-06-03 12.30 PM


I am using treecellrenderer, i have tried different options I dont know
why this is happening, is there any thing to do with the label.

Could any one throw light on this..


this the method for treecellrenderer

public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean selected, boolean expanded,
boolean leaf, int row,
boolean hasFocus) {
 Fontfont;
 String  stringValue = tree.convertValueToText(value, selected,
expanded, leaf, row, hasFocus);

 /* Set the text. */
// find dir name from path
 StringTokenizer sz = new StringTokenizer(stringValue,/);
 String str = null;
 while(sz.hasMoreTokens())
 {
 str = (String)sz.nextElement();
 str = str.trim();
 }
 // add / to dir
 if (stringValue.endsWith(/))
 str += /;
 // display str for current dir
 if (stringValue.equals(rootStr))
 str =   /;

 setText(str);
 /* Tooltips used by the tree. */
 setToolTipText(stringValue);

 /* Set the image. */
 if(expanded  expandedIcon != null)
 setIcon(expandedIcon);
 else if(!leaf  collapsedIcon != null)
 setIcon(collapsedIcon);
 else
 setIcon(null);

 /* Set the color and the font based on the SampleData userObject. */
 String userObject = (String)((DefaultMutableTreeNode)value)
 .getUserObject();
 /* Update the selected flag for the next paint. */
 this.selected = selected;
 return this;
}



raviprakash



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



multi-lined labels?

2001-07-05 Thread alex

Is there a way to create a JLabel 
with text that breaks across multiple
lines?

Thanks,
-alex

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
___
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing



Re: multi-lined labels?

2001-07-05 Thread Jose L. Rando Calvo



You must use html text. For example:

import javax.swing.*;

public class Multiline extends JFrame{ public 
Multiline() { JLabel text = new 
JLabel("htmlHelloBRworld/html"); 
getContentPane().add(text); }

 static public void main(String 
[]args) { Multiline m = new 
Multiline(); m.pack(); 
m.setVisible(true); }}
Regards.


- 
Jose Luis Rando Calvo Area de 
Investigación y Desarrollo Estudio 
Informática Software 
S.L.U.- 
· · [ Grupo EI ] · 
·- 
http://www.grupoei.com 
mail: [EMAIL PROTECTED] 
phone: +34 952 653 
516 
fax: +34 952 650 
460- 
alex [EMAIL PROTECTED] 07/05 7:35 Is there a 
way to create a JLabel with text that breaks across 
multiplelines?Thanks,-alex__Do 
You Yahoo!?Get personalized email addresses from Yahoo! Mailhttp://personal.mail.yahoo.com/___Swing 
mailing list[EMAIL PROTECTED]http://eos.dk/mailman/listinfo/swing


RE: multi-lined labels?

2001-07-05 Thread Harkishin Nachnani

Use HTML 
Example: html line one br line two /html

-Original Message-
From: alex [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 05, 2001 1:36 PM
To: [EMAIL PROTECTED]
Subject: multi-lined labels?


Is there a way to create a JLabel 
with text that breaks across multiple
lines?

Thanks,
-alex

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
___
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing
___
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing