 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Thomas Fritsch Guest
|
Posted: Sun Apr 02, 2006 3:12 pm Post subject: Re: BeanInfo localization: An alternative to extending ListR |
|
|
"Casper B." <casper (AT) jbr (DOT) dk> wrote:
| Quote: | I know it is possible to change the name and various things for properties
of a Bean though creating a similary named class, which extends from
ListResourceBundle class and has "RB" appended:
class MyBean
{
private String m_title;
public void setTitle(String title){m_title = title};
public String getTitle();
}
public class MyBeanRB extends ListResourceBundle
{
protected Object[][] getContents()
{
return new Object[][]
{
{ "title", "Book title" }
}
}
...however, for internationalization reasons I really wish it was possible
for a bean to simply rely on resource files, e.g. MyBean.properties which
would be easier to manage and create localized versions of
(MyBean_da.properties).
My gut feeling tells me it must be possible, but I have been unable to
come up with a working solution. Help would be greatly appreciated,
thanks,
Your gut feeling was right  |
Instead of implementing subclasses of ListResourceBundle you create several
properties files (one for each language you want to support):
your/package/MyBeanRB.properties:
# default language (english) resources
title=Book title
....
your/package/MyBeanRB_fr.properties:
# french language resources
title=title de livre
.....
your/package/MyBeanRB_de.properties:
# german language resources
title=Buchtitel
.....
You'll have to deploy these .properties-files together with your .class
files. Most commonly this means, you put them into the same jar file.
From within your MyBean class you create the localized resource bundle once
by:
static ResourceBundle resBundle =
ResourceBundle.getBundle("your.package.MyBeanRB");
(You don't append a language suffix here. Java will magically find and read
the appropriate .properties file)
Later you can get specific resources, for example:
String title = resBundle.getString("title");
More info can be found at
http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html
--
"TFritsch$t-online:de".replace(':','.').replace('$','@') |
|
| Back to top |
|
 |
Casper B. Guest
|
Posted: Tue Apr 04, 2006 3:12 am Post subject: Re: BeanInfo localization: An alternative to extending ListR |
|
|
Excellent, it works. Donno why I did not think of adding RB to my
properties test files. Thanks :)
Casper
Thomas Fritsch wrote:
| Quote: | "Casper B." <casper (AT) jbr (DOT) dk> wrote:
I know it is possible to change the name and various things for properties
of a Bean though creating a similary named class, which extends from
ListResourceBundle class and has "RB" appended:
class MyBean
{
private String m_title;
public void setTitle(String title){m_title = title};
public String getTitle();
}
public class MyBeanRB extends ListResourceBundle
{
protected Object[][] getContents()
{
return new Object[][]
{
{ "title", "Book title" }
}
}
...however, for internationalization reasons I really wish it was possible
for a bean to simply rely on resource files, e.g. MyBean.properties which
would be easier to manage and create localized versions of
(MyBean_da.properties).
My gut feeling tells me it must be possible, but I have been unable to
come up with a working solution. Help would be greatly appreciated,
thanks,
Your gut feeling was right
Instead of implementing subclasses of ListResourceBundle you create several
properties files (one for each language you want to support):
your/package/MyBeanRB.properties:
# default language (english) resources
title=Book title
...
your/package/MyBeanRB_fr.properties:
# french language resources
title=title de livre
....
your/package/MyBeanRB_de.properties:
# german language resources
title=Buchtitel
....
You'll have to deploy these .properties-files together with your .class
files. Most commonly this means, you put them into the same jar file.
From within your MyBean class you create the localized resource bundle once
by:
static ResourceBundle resBundle =
ResourceBundle.getBundle("your.package.MyBeanRB");
(You don't append a language suffix here. Java will magically find and read
the appropriate .properties file)
Later you can get specific resources, for example:
String title = resBundle.getString("title");
More info can be found at
http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html
|
|
|
| Back to top |
|
 |
Monique Y. Mudama Guest
|
Posted: Tue Apr 25, 2006 7:12 pm Post subject: Re: Strange occurance with JTextFields... |
|
|
On 2006-04-25, Ian Michael Gumby penned:
| Quote: |
Sorry I can't present the code, and I doubt it would have anything
since the code would show a System.out.println() before and after
the foo.setText("foo");
|
Sorry, I can't debug invisible code.
If you really can't come up with a way to show us the code in a way
that won't compromise your integrity, then I recommend going through
the exercise of trimming down the code until the problem goes away.
If you get down to a tiny amount of code and you still have the
problem, it should be easier to debug.
By the way, when I have a problem with live code and need help, I
often try to create an entirely new coding project that uses the same
java libraries as the code that's not workin for me. This way it's
unlikely that anything proprietary will slip through the cracks. It
also helps me convince myself that the problem really is where I think
it is.
--
monique
Help us help you:
http://www.catb.org/~esr/faqs/smart-questions.html |
|
| Back to top |
|
 |
Chris Smith Guest
|
Posted: Wed May 03, 2006 2:13 am Post subject: Re: No posts for 3 days? |
|
|
Ian Michael Gumby <im_gumbyNoSpam (AT) hotmail (DOT) com> wrote:
| Quote: | Is there something wrong with UseNet or just UU.Net
|
The latter. There is never, ever, ever anything wrong with USENET as a
whole. That's because there is no physical device or network connection
or set thereof anywhere that you can point to and say "That is USENET,
and if it all fails, USENET will cease to exist!" If every computer
that ran a news server anywhere except for one on the beaches of a
remote Pacific island were to suddenly die, that last computer would
still be able to post to USENET... there just wouldn't be anyone to get
the messages.
Okay, so that's too much information...
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation |
|
| Back to top |
|
 |
Thomas Weidenfeller Guest
|
|
| Back to top |
|
 |
cpprogrammer Guest
|
Posted: Tue May 16, 2006 9:07 am Post subject: Re: Dialog owner issue with Mac OS X 10.4 |
|
|
Thomas Weidenfeller wrote:
| Quote: | cpprogrammer wrote:
Hi,
I am trying this sample applet on 2 different Mac OS X's
Don't you think cross-posting to four newsgroups because of one
problem is a little bit overdone?
|
I am very very tired & sick of getting my App to behave similiarly on
Windows, Mac & Solaris. As of now I would be happy enough if they behave
similiarly even between different versions of the Mac(i.e. 10.3 & 10.4)
running
the same JVM - I am experiencing "Write once, Debug Everywhere" at its
peak.
For Mac Java issues, I originally posted a few questions to the Sun Forum
on the sun website - no replies. Then I posted to the Java forums - no
replies.
Finally, I posted to the Mac Forums, I got a reply which said something
like "this may be why it may be happening, but since I don't know Java, I
can't suggest a fix" - which is when I started crossposting.
Is my question not topical in any of the 4 forums - if so, let me know & I
will
avoid it future. |
|
| Back to top |
|
 |
Frankline Guest
|
Posted: Wed May 17, 2006 7:07 am Post subject: Re: Dialog owner issue with Mac OS X 10.4 |
|
|
| I am also facing same problem! Any help on this? |
|
| Back to top |
|
 |
Jeffrey Schwab Guest
|
Posted: Wed May 17, 2006 2:07 pm Post subject: Re: Dialog owner issue with Mac OS X 10.4 |
|
|
cpprogrammer wrote:
| Quote: | Thomas Weidenfeller wrote:
cpprogrammer wrote:
Hi,
I am trying this sample applet on 2 different Mac OS X's
Don't you think cross-posting to four newsgroups because of one
problem is a little bit overdone?
I am very very tired & sick of getting my App to behave similiarly on
Windows, Mac & Solaris. As of now I would be happy enough if they behave
similiarly even between different versions of the Mac(i.e. 10.3 & 10.4)
running
the same JVM - I am experiencing "Write once, Debug Everywhere" at its
peak.
For Mac Java issues, I originally posted a few questions to the Sun Forum
on the sun website - no replies. Then I posted to the Java forums - no
replies.
Finally, I posted to the Mac Forums, I got a reply which said something
like "this may be why it may be happening, but since I don't know Java, I
can't suggest a fix" - which is when I started crossposting.
Is my question not topical in any of the 4 forums - if so, let me know & I
will
avoid it future.
|
Why are you using AWT components instead of Swing? I'm not telling you
what to do, I'm just asking out of curiosity. |
|
| Back to top |
|
 |
Andrey Kuznetsov Guest
|
Posted: Wed May 17, 2006 3:07 pm Post subject: Re: Dialog owner issue with Mac OS X 10.4 |
|
|
| Quote: | 1) Mac OS X 10.3.9
Safari 1.3.2 (v312.6)
JVM - 1.4.2_09
Here whenever the Browser, running the Applet comes on Top, the
Dialog also comes on Top i.e. if the dialog is hidden behind some window
& I click on the browser running the applet, the Dialog(showing "Hello",
"OK")
also becomes uncovered/visible.
2) Mac OS X 10.4.5
Safari 2.0.3 (v417.
JVM - 1.4.2_09
Here clicking on the Browser doesn't make the Dialog Visible.
As per the Java Docs, I think the Behaviour on OS X 10.3.9 is the
correct behaviour.
Is there a way to have that behaviour on OS X 10.4 - any workarounds,
anything I can do so that the dialog doesn't get hidden.
I cannot make the dialog modal.
|
you have to change a bit showDlg():
public void showDlg() {
if (myDialog == null) {
// Set The Applet as owner
final Frame f = findFrame(this);
final Window [] d = new Window[1];
if (f != null) {
f.addWindowListener(new WindowAdapter() {
public void windowActivated(WindowEvent e) {
if(d[0] == null || d[0] != f) {
myDialog.toFront();
}
}
});
System.out.println("Found Frame");
myDialog = new Dialog(f, false);
myDialog.addWindowListener(new WindowAdapter() {
public void windowActivated(WindowEvent e) {
d[0] = e.getOppositeWindow();
}
public void windowDeactivated(WindowEvent e) {
d[0] = e.getOppositeWindow();
}
});
myDialog.add(new Label("Hello "), BorderLayout.NORTH);
myDialog.add(new Button("OK"), BorderLayout.SOUTH);
myDialog.pack();
myDialog.show();
}
}
}
Andrey
--
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities |
|
| Back to top |
|
 |
cpprogrammer Guest
|
Posted: Wed May 17, 2006 6:07 pm Post subject: Re: Dialog owner issue with Mac OS X 10.4 |
|
|
Andrey Kuznetsov wrote:
| Quote: | you have to change a bit showDlg():
public void showDlg() {
|
great. That works in my sample app.
I will try it in my actual program. But
that's surely a start. Tx a lot, Andrey. |
|
| Back to top |
|
 |
Andrey Kuznetsov Guest
|
Posted: Wed May 17, 2006 7:07 pm Post subject: Re: Dialog owner issue with Mac OS X 10.4 |
|
|
| Quote: | Also, one other thing I am curious about - why did
your program create an array of size 1,
final Window [] d = new Window[1];
instead of just creating a single object?
i.e. final Window d = null ;
and using it?
|
because you can't change Object declared as final.
| Quote: | my init is function is
public void init() {
b = new Button("Press me");
b.addActionListener(this);
TextArea t = new TextArea(1,25);
add(b);
add(t);
show();
}
Now once the dialog has been activated it always
has input focus - I can never type text into the
textarea - i.e. the dialog behaves like a modal dialog.
|
Your init function is ok.
You probably changed something else.
Post your complete code.
Andrey
--
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities |
|
| Back to top |
|
 |
cpprogrammer Guest
|
Posted: Wed May 17, 2006 7:07 pm Post subject: Re: Dialog owner issue with Mac OS X 10.4 |
|
|
cpprogrammer wrote:
| Quote: | Andrey Kuznetsov wrote:
you have to change a bit showDlg():
public void showDlg() {
great. That works in my sample app.
I will try it in my actual program. But
that's surely a start. Tx a lot, Andrey.
|
There is a problem with this fix.
Assume I have a textarea below the button.
i.e.
my init is function is
public void init() {
b = new Button("Press me");
b.addActionListener(this);
TextArea t = new TextArea(1,25);
add(b);
add(t);
show();
}
Now once the dialog has been activated it always
has input focus - I can never type text into the
textarea - i.e. the dialog behaves like a modal dialog.
Also, one other thing I am curious about - why did
your program create an array of size 1,
final Window [] d = new Window[1];
instead of just creating a single object?
i.e. final Window d = null ;
and using it? |
|
| Back to top |
|
 |
cpprogrammer Guest
|
Posted: Thu May 18, 2006 6:07 am Post subject: Re: Dialog owner issue with Mac OS X 10.4 |
|
|
Andrey Kuznetsov wrote:
| Quote: | Now once the dialog has been activated it always
has input focus - I can never type text into the
textarea - i.e. the dialog behaves like a modal dialog.
Your init function is ok.
You probably changed something else.
Post your complete code.
|
Here is my complete code.
Now the dialog is always on front when the browser
is in front. However, I can never type anything into
the textarea.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class MyTest extends Applet implements ActionListener{
private Button b;
private Dialog myDialog;
private TextArea t;
public void init() {
b = new Button("Press me");
b.addActionListener(this);
t = new TextArea(1,25);
add(b);
add(t);
show();
}
private Frame findFrame(Component c) {
for (; c != null; c = c.getParent()) {
if (c instanceof Frame) {
return (Frame) c;
}
}
return null;
}
public void RF()
{t.requestFocus();}
public void actionPerformed(ActionEvent e) {
if ( e.getSource() == b ) {
showDlg();
}
}
public void showDlg() {
if (myDialog == null) {
// Set The Applet as owner
final Frame f = findFrame(this);
final Window [] d = new Window[1];
if (f != null) {
f.addWindowListener(new WindowAdapter() {
public void windowActivated(WindowEvent e) {
if(d[0] == null || d[0] != f) {
myDialog.toFront();
RF();
}
}
});
myDialog = new Dialog(f, false);
myDialog.addWindowListener(new WindowAdapter() {
public void windowActivated(WindowEvent e) {
d[0] = e.getOppositeWindow();
}
public void windowDeactivated(WindowEvent e) {
d[0] = e.getOppositeWindow();
}
});
myDialog.add(new Label("Hello "), BorderLayout.NORTH);
myDialog.add(new Button("OK"), BorderLayout.SOUTH);
myDialog.pack();
myDialog.show();
}
}
}
} |
|
| Back to top |
|
 |
Andrey Kuznetsov Guest
|
Posted: Thu May 18, 2006 10:07 am Post subject: Re: Dialog owner issue with Mac OS X 10.4 |
|
|
| Quote: | Here is my complete code.
Now the dialog is always on front when the browser
is in front. However, I can never type anything into
the textarea.
|
<code snipped>
this is strange, because on windows it has expected behavior.
It works also without t.requestFocus();
Since I don't have mac I can't give you another solution.
Andrey
--
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities |
|
| Back to top |
|
 |
steve Guest
|
Posted: Thu May 18, 2006 11:07 pm Post subject: Re: Dialog owner issue with Mac OS X 10.4 |
|
|
On Tue, 16 May 2006 15:19:09 +0800, cpprogrammer wrote
(in article <4ctc10F17g38mU1 (AT) individual (DOT) net>):
| Quote: | Hi,
I am trying this sample applet on 2 different Mac OS X's
1) Mac OS X 10.3.9
Safari 1.3.2 (v312.6)
JVM - 1.4.2_09
Here whenever the Browser, running the Applet comes on Top, the
Dialog also comes on Top i.e. if the dialog is hidden behind some window
& I click on the browser running the applet, the Dialog(showing "Hello",
"OK")
also becomes uncovered/visible.
2) Mac OS X 10.4.5
Safari 2.0.3 (v417.
JVM - 1.4.2_09
Here clicking on the Browser doesn't make the Dialog Visible.
As per the Java Docs, I think the Behaviour on OS X 10.3.9 is the
correct behaviour.
Is there a way to have that behaviour on OS X 10.4 - any workarounds,
anything I can do so that the dialog doesn't get hidden.
I cannot make the dialog modal.
Given below is the Applet source.
------------------------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class MyTest extends Applet implements ActionListener {
private Button b;
private Dialog myDialog;
public void init() {
b = new Button("Press me");
b.addActionListener(this);
add(b);
show();
}
private Frame findFrame(Component c) {
for (; c != null; c = c.getParent()) {
if (c instanceof Frame) return (Frame) c;
}
return null;
}
public void actionPerformed(ActionEvent e) {
if ( e.getSource() == b ) {
showDlg();
}
}
public void showDlg()
{
if(myDialog == null) {
// Set The Applet as owner
Frame f = findFrame(this);
if(f != null) {
System.out.println("Found Frame");
myDialog = new Dialog(f, false);
myDialog.add(new Label("Hello ") , BorderLayout.NORTH);
myDialog.add(new Button("OK"), BorderLayout.SOUTH);
myDialog.pack();
myDialog.show();
}
}
}
}
------------------------------------------------------------------
|
I would start by updating the jvm on you machine
currently the version should 1.5
and your os should be 10.4.6
apple have been doing some work on the swing interface
--
NewsGuy.Com 30Gb $9.95 Carry Forward and On Demand Bandwidth |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|