| [RFE] Access to Field, Method and Constructor without the use of Strings |
|
 |
Index ‹ java-programmer
|
- Previous
- 3
- JAX-RPC: Strange Exception with Dynamic Proxy ClientHello there
I am using currently SUN's Webservice Development Kit 1.4 and try to
realise a JAX-RPC "rpc/encoded" webservice.
My applicatio is currently running if I am using a static client
(stubs geenerated by wscompile). If am going forward to use a dynamic
proxy client, I am getting a strange exception during the
deserialization of the xml data on the client: "trailing block
elements must have an id attribute". see stack trace at the end of the
messsage.
As far as I understand is that it must somewthing be with the
"ArrayList" or arrays which I am using in my JavaBean which I sent
from the server to the client. Here my extract from my JavaBean:
public class Article
{
long id;
Date date;
String category;
String title="";
String lead="";
List texts;
}
If I am taking out the member "List texts" then it will work
correctly. The list contains only Strings. I tried also to use
String[] array, but this didn't help either.
So here, my questions perhaps someone has some ideas what I did wrong.
- Why does it work with the stastic cleint but not with the dynamic
proxy?
- Does anybody know an example on the net where in JavaBeans Lists or
Arrays has been used?
- Anybody an idea why this error appears? Did I something wrong?
Thank you in advance
Mark Egloff
trailing block elements must have an id attribute
at com.sun.xml.rpc.encoding.SOAPDeserializationContext.deserializeMultiRefObjects(SOAPDeserializationContext.java:81)
at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:226)
at com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.java:80)
at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:489)
at com.sun.xml.rpc.client.dii.CallInvocationHandler.doCall(CallInvocationHandler.java:122)
at com.sun.xml.rpc.client.dii.CallInvocationHandler.invoke(CallInvocationHandler.java:86)
at $Proxy0.getArticle(Unknown Source)
at tagesanzeiger.client.ManagerDynamicClient.main(ManagerDynamicClient.java:43)
- 3
- Scroll JList to bottom automatic .
Hi,
How to automatic scroll a JList to bottom of the list, i.e when inserting
new elements. My list have i created like this:
JList jlist = new JList(objectArray);
JScrollPane scroll = new JList(jlist);
Any simple code to do this?
Best Regards
/Jonny
- 4
- Sending Hop Limited UDP packetsIs there a way to send a UDP packet with a specific TTL however it
must be a unicast address instead of multicast address. Any ideas?
regards
Usman Ismail
- 6
- mozilla and firefox java plugins on jdk1.5.0 Hi all
Have java plugins to firefox and mozilla browsers jdk1.5.0 on Freebsd?
this not work already...
ln -s /usr/local/jdk1.4.2/jre/plugin/i386/ns610/libjavaplugin_oji.so \
/usr/X11R6/lib/browser_plugins/
I have jdk1.5.0 and the dir /plugin is dissapeared :-(
%pwd
/usr/local/jdk1.5.0/jre
%ll
total 36
drwxr-xr-x 2 root wheel 512 14 feb 22:12 .systemPrefs
-r--r--r-- 1 root wheel 2487 14 feb 21:53 COPYRIGHT
-r--r--r-- 1 root wheel 969 14 feb 21:53 CHANGES
-r--r--r-- 1 root wheel 9223 14 feb 21:53 LICENSE
-r--r--r-- 1 root wheel 11172 14 feb 21:53 README
-r--r--r-- 1 root wheel 969 14 feb 21:53 Welcome.html
drwxr-xr-x 2 root wheel 512 14 feb 22:11 bin
drwxr-xr-x 14 root wheel 1024 14 feb 22:11 lib
I have installed too...
%java -version
java version "1.5.0-p1"
linuxpluginwrapper-20050119_1
thanks in advance!
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 6
- Cannot draw on mutable imageHi,
I got a problem with drawing on an image created with the
createImage(int width, int height) method. I use MIDP 1.0 and
everything works fine in the emulator. But when running it on my
T-630, I just get a white image with the defined size. It doesn't
matter what I draw on the Graphics-object, my phone just displays a
white rectangle.
The code should be ok, since it works in the emulator. I also used
several examples from the internet - all with the same result.
Any ideas what might be wrong?
Thanks in advance
Dirk
- 6
- Something FunHere's something fun that you may find interesting. I don't really have
enough know-how to do anything with it yet, but some of you might.
http://mtg.upf.edu/reactable/
One of the releases is in Java. Here's a video of it finished.
http://youtube.com/watch?v=0h-RhyopUmc
If anyone does anything with this, let me know!
- 6
- 7
- [ANNOUNCE] Apache Derby 10.4.1.3 releasedThe Apache Derby project is pleased to announce a new feature release
of Derby, 10.4.1.3.
Apache Derby is a subproject of the Apache DB project.
Derby is a pure Java relational database engine which conforms to the
ISO/ANSI SQL and JDBC standards. Derby aims to be easy for developers
and end-users to work with.
Derby 10.4.1.3 can be obtained from the Derby download site:
http://db.apache.org/derby/derby_downloads.html.
Derby 10.4.1.3 introduces the following new capabilities:
* Asynchronous Replication
Allows you to maintain an up to date copy of your (master) database on
a different host (the slave). In the case of a crash on the master
database you can perform failover to the copy (slave database) and
continue serving client requests against your database.
* Security
o Shutting down the Network Server now supports user authentication,
and in fact requires credentials when authentication is enabled.
* SQL
o Table Functions. Using table functions and standard SQL, you can pose
sophisticated queries against in-memory collections, flat files, web
resources, non-relational databases, etc.. Table functions also let
you efficiently import data from web feeds, sensor logs, and other
relational databases.
o Unique constraints on nullable columns.
o SQL ROW_NUMBER() window function, (for an empty, inlined window
specification).
o Bracketed comments (/* ... */).
* Performance and Memory Usage
o New buffer manager with better concurrency.
o Statement cache in the client driver.
o Caching of isolation level and current schema in the client
driver.
* Administration
o Java Management Extensions (JMX) for Derby, allowing
local and remote monitoring and management of running Derby instances
(embedded or Network Server).
o Continuation prompt. ij adds a short "> " prompt to the next line
after a newline has been entered by the user without ending the
statement with a semicolon.
Derby 10.4.1.3 also has many bugfixes, including the fix for
DERBY-3347 which can cause unrecoverable database corruption. All
10.3 users are encouraged to upgrade to avoid potential corruption
issues.
--
Regards,
Dyre
- 9
- 10
- integration with JSTL
Hallo, here is my question. I have a Java API
to access some data (collections and strings).
How do I make sure that my API is such that i can access data trhough
the JSTL?
I want to be able to do things like the following
in my JSPs:
<c:if test="$someobj.property == 'john'">
Hallo John
</c:if>
Thanks
Luca
- 10
- JNDI Authenticate UserHi All,
I have the below code which is supposed to return a true if the user is
authenticated against active directory and false if the user is not.
This works fine if you send it a correct username and correct password. It
also works if you send it a correct username with an incorrect password. It
also works if you send it an in-correct username with a password.
My problem is that a few accounts in the directory don't have passwords set.
I.e. password is blank. If I send any username without a password then it
always returns true, even if that user has a password set or the user
doesn't exist. Does anyone have any ideas why this is?
<code>
public boolean authenticateUser(String userName, String password){
//Try to log in with the supplied username and password
//If it fails then either the user doesn't exist or the wrong
crudentials where supplied
try{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, ldapConnectionString);
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, userName + "@" +
ADName);
env.put(Context.SECURITY_CREDENTIALS, password);
DirContext ctx = new InitialDirContext(env);
return true;
}catch(Exception ex){
//Authentication failed
return false;
}
}
</code>
- 10
- Static Variables and JAR FilesI am curious - does the scope of static variables carry across
different JAR files?
Here's the issue:
BaseClass is in "BaseClasses.jar"
ExtendedClassA extends BaseClass is in "AnotherPackage.jar"
ExtendedClassB extends BaseClass is in "EvenAnotherPackage.jar"
BaseClass has a static object (ObjectX). Now, normally, this static
object is static across all of the subclasses. However...
These JAR files (AnotherPackage and EvenAnotherPackage) are being read
in by a separate tool. When ExtendedClassA and ExtendedClassB are
used within the context of this tool, ObjectX is instantiated twice
and has two separate values. As far as I can tell, the tool runs
ExtendedClassA and ExtendedClassB within the same JVM, so I am unsure
of what is going on.
Does anybody have any insight into what is going on here? (Sorry for
being vague. I'm not actually working the project, but I'm curious
from an academic standpoint. Another group ran across this problem
today.)
- 10
- 10
- Using a JList with a cell renderer within an applet/cell renderer not workingI have a cell renderer for a JList that is supposed to render the foreground
color in blue, and also insert tabs into the lines. When this code is
changed to run as an application, the cell renderer performs as expected.
When the code is run as an applet, the cell renderer has no impact at all.
Any help would be appreciated.
I am using SDK 1.4.0, Windows XP Professional.
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.text.DecimalFormat;
import javax.swing.text.MaskFormatter;
import java.text.ParseException;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import java.util.StringTokenizer;
public class TempConvert extends JApplet {
public JFormattedTextField low;
public JFormattedTextField high;
public JFormattedTextField incr;
public TempConvert() {
getContentPane().setLayout(new BorderLayout());
createGrid();
setSize(270,400);
}
private void createGrid() {
JPanel panel = new JPanel(new BorderLayout());
// add selection panel
MaskFormatter mf1 = null;
MaskFormatter mf2 = null;
try
{
mf1 = new MaskFormatter("####");
mf1.setPlaceholderCharacter('_');
//mf1.setCommitsOnValidEdit(true);
mf2 = new MaskFormatter("###");
mf2.setPlaceholderCharacter('_');
//mf2.setCommitsOnValidEdit(true);
}
catch (ParseException e){
}
low = new JFormattedTextField(mf1);
low.setFocusLostBehavior(JFormattedTextField.COMMIT);
high = new JFormattedTextField(mf1);
high.setFocusLostBehavior(JFormattedTextField.COMMIT);
incr = new JFormattedTextField(mf2);
incr.setFocusLostBehavior(JFormattedTextField.COMMIT);
JPanel select = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.NONE;
addgbc(select, new JLabel("Low Temperature Range . . ."),gbc,0,0);
addgbc(select, low,gbc,1,0);
addgbc(select, new JLabel("High Temperature Range . ."),gbc,0,1);
addgbc(select, high,gbc,1,1);
addgbc(select, new JLabel("Increment Degrees . . . . ."),gbc,0,2);
addgbc(select, incr,gbc,1,2);
panel.add(select, BorderLayout.NORTH);
// add temperature list
final JList list = new JList();
TabListCellRenderer renderer = new TabListCellRenderer();
//renderer.setTabs(new int[] {50,200,300,});
list.setCellRenderer(renderer);
JScrollPane scroller = new JScrollPane();
scroller.getViewport().add(list);
panel.add(scroller, BorderLayout.CENTER);
// add buttons
JPanel buttons = new JPanel(new FlowLayout(FlowLayout.CENTER,5,5));
JButton ok = new JButton("OK");
JButton cancel = new JButton("Cancel");
buttons.add(ok);
buttons.add(cancel);
panel.add(buttons, BorderLayout.SOUTH);
getContentPane().add(panel);
//pack();
setVisible(true);
// register action listeners for the buttons
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (verifyData())
{
list.setListData(calculateTemps());
list.revalidate();
list.repaint();
}
}
});
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// stop();
// destroy();
}
});
}
private int getIntValue(JFormattedTextField field)
{
try
{
return Integer.parseInt(field.getText().toString().replace('_','
').trim());
}
catch (NumberFormatException e){}
return 0;
}
private boolean verifyData()
{
int lowTemp = getIntValue(low);
int highTemp = getIntValue(high);
int incrTemp = getIntValue(incr);
if (lowTemp < 0)
{
JOptionPane.showMessageDialog(this, "If low temperature is entered, must
be greater than zero");
return false;
}
if (highTemp == 0)
{
JOptionPane.showMessageDialog(this, "High temperature must be entered");
return false;
}
if (highTemp <= lowTemp)
{
JOptionPane.showMessageDialog(this, "High temperature must be greater
than low temperature");
return false;
}
if (incrTemp == 0)
{
JOptionPane.showMessageDialog(this, "Increment degrees must be
entered.");
return false;
}
return true;
}
private void addgbc(Container cont, JComponent comp, GridBagConstraints
gbc, int x, int y) {
gbc.gridx=x; gbc.gridy=y;
cont.add(comp,gbc);
}
private TempData[] calculateTemps() {
int lowTemp = getIntValue(low);
int highTemp = getIntValue(high);
int incrTemp = getIntValue(incr);
int range = highTemp-lowTemp;
TempData[] tempdata = new TempData[range/incrTemp +1];
int j=0;
for (int i=lowTemp; i<=highTemp; i+=incrTemp) {
tempdata[j] = new TempData(i);
j++;
}
return tempdata;
}
public static void main (String[] args) {
new TempConvert();
}
public class TempData {
int fahrenheit;
int celsius;
public TempData(int fahrenheit) {
this.fahrenheit = fahrenheit;
calculateTemp();
}
private void calculateTemp() {
double temp = 5/9 * (fahrenheit-32);
celsius = (int)temp;
}
public String toString() {
return fahrenheit + "\t" + celsius;
}
}
}
class TabListCellRenderer
extends JLabel
implements ListCellRenderer {
protected static Border m_noFocusBorder;
protected FontMetrics m_fm = null;
protected Insets m_insets = new Insets(0, 0, 0, 0);
protected int m_defaultTab = 50;
protected int[] m_tabs = null;
public TabListCellRenderer() {
m_noFocusBorder = new EmptyBorder(1, 1, 1, 1);
setOpaque(true);
setBorder(m_noFocusBorder);
}
public Component getListCellRendererComponent(JList list,
Object value, int index, boolean isSelected, boolean cellHasFocus) {
setText(value.toString());
System.out.println("getText = " + getText());
setBackground(isSelected ? list.getSelectionBackground() :
list.getBackground());
//setForeground(isSelected ? list.getSelectionForeground() :
list.getForeground());
setForeground(Color.blue);
//setBackground(Color.blue);
setFont(list.getFont());
setBorder((cellHasFocus) ?
UIManager.getBorder("List.focusCellHighlightBorder") : m_noFocusBorder);
return this;
}
public void setDefaultTab(int defaultTab) {
m_defaultTab = defaultTab;
}
public int getDefaultTab() {
return m_defaultTab;
}
public void setTabs(int[] tabs) {
m_tabs = tabs;
}
public int[] getTabs() {
return m_tabs;
}
public int getTab(int index) {
if (m_tabs == null)
return m_defaultTab*index;
int len = m_tabs.length;
if (index>=0 && index<len)
return m_tabs[index];
return m_tabs[len-1] + m_defaultTab*(index-len+1);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
Color colorRetainer = g.getColor();
m_fm = g.getFontMetrics();
g.setColor(getBackground());
g.fillRect(0, 0, getWidth(), getHeight());
getBorder().paintBorder(this, g, 0, 0, getWidth(), getHeight());
g.setColor(getForeground());
g.setFont(getFont());
m_insets = getInsets();
int x = m_insets.left;
int y = m_insets.top + m_fm.getAscent();
StringTokenizer st = new StringTokenizer(getText(), "\t");
while (st.hasMoreTokens()) {
String sNext = st.nextToken();
System.out.println("next token = " + sNext);
g.drawString(sNext, x, y);
x += m_fm.stringWidth(sNext);
if (!st.hasMoreTokens())
break;
int index = 0;
while (x >= getTab(index))
index++;
x = getTab(index);
}
g.setColor(colorRetainer);
}
}
- 13
- Certificate Login ModuleHi All,
If I am correct JBoss has added a SSL certificate login module in
version 4.0. I wanted to have a peek in it, but the source code of JBoss
4.0 is not available.
Can anybody please let me know from where can I get the source code of
JBoss 4.0? Or better, can anybody please send me the source code of such
a Login Module.
Any pointers in this direction will be highly appreciated.
Thanks in Advance,
-DN
|
| Author |
Message |
Carl Rosenberger

|
Posted: 2003-9-18 18:53:00 |
Top |
java-programmer, [RFE] Access to Field, Method and Constructor without the use of Strings
Hi all,
I submitted the following RFE to Sun's RFE page.
As a reply I received a mail from Girish Manwani at Sun that I
should start a discussion in one of the Java newsgroups (Huh?).
To my knowledge, this is the most appropriate group. Here gos:
A DESCRIPTION OF THE REQUEST:
It should be possible to obtain references to Field, Method and
Constructor objects without the use of strings. Proposed syntax:
// Assuming the following class
public class Foo {
String bar;
public Foo(String bar) {
this.bar = bar;
}
public void fly(String to) {
bar = to;
}
}
Field fooBarField = Foo.class.bar.field;
Method fooFlyMethod = Foo.class.fly.method(new Object[]{String.class});
Constructor fooConstructor = Foo.class.constructor(new Object[]{String.class});
There are other possible options for the syntax. I would just like to see
this principally possible.
The construct is similar to the ClassName.class syntax and it can be treated
by the Compiler in the same way:
It could produce the getDeclaredField, getDeclaredMethod and getConstructor
bytecode. No modifications to the JVM would be necessary.
JUSTIFICATION :
The existance of the field/method/constructor could be checked during compile
time. Typos would no longer be possible.
A notation without strings could be very easily refactored by IDEs.
We would specifically need the feature for our typesafe querying system,
so it could work completely without strings.
http://sodaquery.sf.net/
The possibility to get Method objects without strings, would encourage many
developers to use them for more dynamic programming and would result in lots
of more flexible libraries for the Java platform.
Thanks in advance for your attention and for positive comments.
Kind regards,
Carl
Carl Rosenberger
db4o - database for objects - http://www.db4o.com
|
| |
|
| |
 |
softeng3456

|
Posted: 2003-9-18 23:42:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
"Carl Rosenberger" <email***@***.com> wrote in message news:<bkc2ml$qdt$01$email***@***.com>...
> Hi all,
>
> I submitted the following RFE to Sun's RFE page.
>
> As a reply I received a mail from Girish Manwani at Sun that I
> should start a discussion in one of the Java newsgroups (Huh?).
Interesting. I wonder if that means Sun actually monitors
Java newsgroups, or if that is their polite way to
say "go away, we are too busy"!
FWIW, Sounds like a small and useful addition.
(Then there was the variable-shadowing issue discussed
elsewhere, though I don't know if that can
be fixed without breaking existing code.)
|
| |
|
| |
 |
larrybar

|
Posted: 2003-9-19 0:51:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
"Carl Rosenberger" <email***@***.com> wrote in message news:<bkc2ml$qdt$01$email***@***.com>...
> Hi all,
>
> I submitted the following RFE to Sun's RFE page.
>
> ...
>
> A DESCRIPTION OF THE REQUEST:
> It should be possible to obtain references to Field, Method and
> Constructor objects without the use of strings. Proposed syntax:
>
> ...
>
> JUSTIFICATION :
> The existance of the field/method/constructor could be checked during compile
> time. Typos would no longer be possible.
>
> A notation without strings could be very easily refactored by IDEs.
>
> ...
But the usual reason for using reflection is that those
classes/fields/methods/constructors don't exist at compile time
and may or may not exist at run time.
-Larry Barowski
|
| |
|
| |
 |
bcd

|
Posted: 2003-9-19 0:59:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
In article <bkc2ml$qdt$01$email***@***.com>,
Carl Rosenberger <email***@***.com> wrote:
>
>Hi all,
>
>I submitted the following RFE to Sun's RFE page.
I'm behind you all the way :-)
I have two main reasons for wanting this. First, it would make me feel
a lot easier about the legacy library we have that makes heavy use of
field reflection. Right now, detection of typos is effectively left to
run-time and I really really hate that. Second, it would become
feasible to make heavier use of reflection without feeling that you're
programming Perl or something.
Is it possible to vote for this RFE on Sun's site?
Cheers
Bent D
--
Bent Dalager - email***@***.com - http://www.pvv.org/~bcd
powered by emacs
|
| |
|
| |
 |
Gordon Beaton

|
Posted: 2003-9-19 1:05:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
On Thu, 18 Sep 2003 12:53:09 +0200, Carl Rosenberger wrote:
> The existance of the field/method/constructor could be checked
> during compile time. Typos would no longer be possible.
It could only be checked at compile time if the compiler has access to
the class in question.
And if that's the case, you can use "regular" syntax to access the
fields and get the checking you're asking for, without using
reflection at all.
/gordon
--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
|
| |
|
| |
 |
Carl Rosenberger

|
Posted: 2003-9-19 19:33:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
Bent C Dalager wrote:
> >I submitted the following RFE to Sun's RFE page.
>
> I'm behind you all the way :-)
Thanks for the backup.
> Is it possible to vote for this RFE on Sun's site?
I don't think so. Attached I send along the answer from Sun.
It tells me to discuss the theme in a newsgroup and to
submit the RFE again, if there is positive feedback.
Funny:
I submitted a similar RFE for access to methods only, more
than three years ago. At that time my suggestion as to the
syntax wasn't too good but the idea was the same. I can attach
the answer I received at that time to this mail also.
How many times do they want me to submit this RFE until it
gos into the database?
Cheers,
Carl
******************************* Answer 2 *** 2003 **************************
> -----Original Message-----
> From: Girish Manwani [mailto:email***@***.com]
> Sent: Donnerstag, 14. August 2003 22:03
> To: email***@***.com
> Cc: email***@***.com
> Subject: Re: (Incident Review ID: 185015) Access
> java.lang.reflect.Field, Method and Constructor objects without strings
>
>
>
> Hi Carl Rosenberger,
>
> Thank you for using our bug submit page. There may be merit to
> your request for feature enhancement (RFE). I would suggest
> that you first post this to a newsgroup and request comment from
> other java developers.
>
> You can view a list of Java newsgroups at:
>
> http://java.sun.com/aboutJava/newsgroups.html
>
>
> Based on the responses, please feel free to submit a new RFE
> containing a link to the newsgroup. Thank you for your time.
>
> Regards,
> Girish
> ----------------- Original Bug Report-------------------
>
> category : java
> release : 1.4.1
> subcategory : classes_lang
> type : rfe
> synopsis : Access java.lang.reflect.Field, Method and Constructor
> objects without strings
> description : A DESCRIPTION OF THE REQUEST :
> It should be possible to obtain references to Field, Method and
> Constructor objects without the use of strings. Proposed syntax:
>
> // Assuming the following class
> public class Foo {
> String bar;
> public Foo(String bar) {
> this.bar = bar;
> }
> public void fly(String to) {
> bar = to;
> }
> }
>
> Field fooBarField = Foo.class.bar.field;
> Method fooFlyMethod = Foo.class.fly.method(new Object[]{String.class});
> Constructor fooConstructor = Foo.class.constructor(new
> Object[]{String.class});
>
> There are other possible options for the syntax. I would just
> like to see this principally possible.
>
> The construct is similar to the ClassName.class syntax and it can
> be treated by the Compiler in the same way:
> It could produce the getDeclaredField, getDeclaredMethod and
> getConstructor bytecode. No modifications to the JVM would be necessary.
>
> JUSTIFICATION :
> The existance of the field/method/constructor could be checked
> during compile time. Typos would no longer be possible.
>
> A notation without strings could be very easily refactored by IDEs.
>
> We would specifically need the feature for our typesafe querying
> system, so it could work completely without strings.
> http://sodaquery.sf.net/
>
> The possibility to get Method objects without strings, would
> encourage many developers to use them for more dynamic
> programming and would result in lots of more flexible libraries
> for the Java platform.
> workaround :
> suggested_val :
> cust_name : Carl Rosenberger
> cust_email : email***@***.com
> jdcid : CarlRosenberger
> keyword : webbug
> company : db4o
> hardware : x86
> OSversion : win_nt_4.0
> bugtraqID : 0
> dateCreated : 2003-04-29 06:29:20.9
> dateEvaluated : 2003-08-14 14:03:03.296
>
******************************* Answer 1 *** 2000 **************************
> -----Original Message-----
> From: Sean Lane [mailto:email***@***.com]
> Sent: Montag, 10. Juli 2000 19:52
> To: email***@***.com
> Subject: Re: (Review ID: 104615) Access to Method object without String
> detour through getMethod
>
>
> I apologize for the length of time it has taken for someone to
> respond to you regarding this Bug Report you have made.
> I hope you will not be offended by us contacting you after
> such a long time. We are very concerned about every Bug
> Report that we receive and with the volume we receive
> we have not able to address all of them is the timely manner
> that we would like. We are looking through our older Bug
> Reports and are trying to find out if these issues are still
> relevant to our customers and want to know if the problem
> still exists in our more recent release.
>
> Please let me know if this problem still exists for you.
>
> Sean Lane
>
> P.S.--
> The following is the most recent release and
> its download site:
>
> JDK 1.3 - http://java.sun.com/j2se/1.3/
>
>
> ----------------- Original Bug Report-------------------
>
> category : java
> subcategory : classes_lang
> type : rfe
> synopsis : Access to Method object without String detour through getMethod
> description : java version "1.2.2"
> Classic VM (build JDK-1.2.2-004, native threads, symcjit)
>
> I would like to be able to store methods into Method variables without the
> detour through Class.getMethod(String, Class[]).
>
> String names for methods within sourcecode
> - are not very performant
> - can not be checked by the compiler
>
> Something like the following would be great:
>
> import java.lang.reflect.*;
> public class MyClass
> {
> public void myMethod(){
> Method foo = new Method(MyClass.myMethod);
> // Alternatives:
> Method foo = new Method(MyClass.myMethod());
> Method foo = new Method(MyClass.class.myMethod);
> Method foo = new Method(MyClass.class.myMethod());
> Method foo = this.getClass().getMethod(MyClass.myMethod);
> Method foo = this.getClass().getMethod(MyClass.myMethod());
> // Maybe sun can think of the syntactic right Java way for this.
> }
> }
> workaround : I use an object to cache the Method so I only need a
> single call to getMethod.
> I still find the String representation of method names spread
> throughout my
> code very irritating.
>
> A portion of my code:
>
> package de.cros.collection;
>
> import java.lang.reflect.*;
>
> public class MethodProperty extends CollectionObjectProperty
> {
> private String i_methodName;
> private Method i_Method;
>
> public MethodProperty(Collection a_Collection, String a_methodName){
> super(a_Collection);
> i_methodName = a_methodName;
> try{
> i_Method =
> a_Collection.getCollectedClass().getMethod
> (a_methodName,null);
> }
> catch(Exception l_ex){
> i_Method = null;
> }
> }
>
> Object get(Object a_Object) throws IllegalAccessException,
> NoSuchMethodException, InvocationTargetException{
> return method(a_Object).invoke(a_Object, null);
> }
>
> private Method method(Object a_Object) throws NoSuchMethodException{
> if (i_Method != null){
> return i_Method;
> }
> return a_Object.getClass().getMethod(i_methodName, null);
> }
> }
> suggested_val :
> cust_name : Carl Rosenberger
> cust_email : email***@***.com
> jdcid : CarlRosenberger
> keyword : webbug
> company : c-ros www.c-ros.de
> release : 1.2.2
> hardware : x86
> OSversion : win_nt_4.0
> priority : 4
> bugtraqID : 0
> dateCreated : 2000-05-09 04:16:16.0
> dateEvaluated : 2000-07-10 10:51:38.1
>
|
| |
|
| |
 |
rick

|
Posted: 2003-9-19 19:59:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
>> description : A DESCRIPTION OF THE REQUEST :
>> It should be possible to obtain references to Field, Method and
>> Constructor objects without the use of strings. Proposed syntax:
>>
>> // Assuming the following class
>> public class Foo {
>> String bar;
>> public Foo(String bar) {
>> this.bar = bar;
>> }
>> public void fly(String to) {
>> bar = to;
>> }
>> }
>>
>> Field fooBarField = Foo.class.bar.field;
>> Method fooFlyMethod = Foo.class.fly.method(new Object[]{String.class});
>> Constructor fooConstructor = Foo.class.constructor(new
>> Object[]{String.class});
I think it's a good idea, too.
|
| |
|
| |
 |
Paul Ebermann

|
Posted: 2003-9-19 21:57:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
"Gordon Beaton" skribis:
> On Thu, 18 Sep 2003 12:53:09 +0200, Carl Rosenberger wrote:
> > The existance of the field/method/constructor could be checked
> > during compile time. Typos would no longer be possible.
>
> It could only be checked at compile time if the compiler has access to
> the class in question.
>
> And if that's the case, you can use "regular" syntax to access the
> fields and get the checking you're asking for, without using
> reflection at all.
Think of an API, which works by reflection.
(S.O.D.A., which Carl mentioned, is such one.)
While _you_ know the structure of the classes,
on which to work, the API-implementation does
not (and can't, since they are compiled seperately).
So it is not possible to use "regular syntax".
You have to give the names of the Fields to
the API - or the Field-Objects.
Now, you'll have to use Strings por specifiing
them - and typos will be catched first in runtime.
With Carl's proposal, you could give Field-Objects,
simply specifiing the name.
Paul
(Please forgive my bad english - I normally
only write in german and Esperanto newsgroups.)
|
| |
|
| |
 |
Carl Rosenberger

|
Posted: 2003-9-22 20:21:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
Carl Rosenberger wrote:
> > Hi Carl Rosenberger,
> >
> > Thank you for using our bug submit page. There may be merit to
> > your request for feature enhancement (RFE). I would suggest
> > that you first post this to a newsgroup and request comment from
> > other java developers.
> >
> > You can view a list of Java newsgroups at:
> >
> > http://java.sun.com/aboutJava/newsgroups.html
> >
> >
> > Based on the responses, please feel free to submit a new RFE
> > containing a link to the newsgroup. Thank you for your time.
Hi all,
following the above directions, I just submitted another
RFE (the third time) to the Java bug database.
I would really appreciate further "+1" comments in this
thread, should anyone else be interested to see this
feature.
It's a very small addition to the compiler and I know,
the merit for dynamic programming would be great. We
would really love to see the feature to be able to
provide the first completely typesafe object querying
system:
http://sourceforge.net/projects/sodaquery/
Thanks!
Cheers,
Carl
|
| |
|
| |
 |
Frank Radermacher

|
Posted: 2003-9-22 21:33:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
Carl Rosenberger wrote:
> Carl Rosenberger wrote:
>
> It's a very small addition to the compiler and I know,
> the merit for dynamic programming would be great. We
> would really love to see the feature to be able to
> provide the first completely typesafe object querying
> system:
> http://sourceforge.net/projects/sodaquery/
>
Hi,
I think that the mentioned addition to the syntax would be very useful
not only for query systems. I would lead to a much more "hygienical"
code anywhere you make heavy use of metadata.
Frank
P.S. +1
|
| |
|
| |
 |
Aljoscha Rittner

|
Posted: 2003-9-23 0:10:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
Carl Rosenberger schrieb:
> I submitted the following RFE to Sun's RFE page.
[...]
> Field fooBarField = Foo.class.bar.field;
> Method fooFlyMethod = Foo.class.fly.method(new Object[]{String.class});
> Constructor fooConstructor = Foo.class.constructor(new Object[]{String.class});
>
> There are other possible options for the syntax. I would just like to see
> this principally possible.
I think the qualifier .class. is a good idea. It ensures compatibility
to accessible fieldnames.
An other syntax:
Foo.class.fields.bar;
Foo.class.methods.fly (new Object[] {String.class});
I think this syntax is easier to read. fields and methods are like
"collections" (see below my extensions)
[...]
> JUSTIFICATION :
> The existance of the field/method/constructor could be checked during compile
> time. Typos would no longer be possible.
But why? Reflection (scripting) is a runtime checked behavior.
> A notation without strings could be very easily refactored by IDEs.
ACK.
> The possibility to get Method objects without strings, would encourage many
> developers to use them for more dynamic programming and would result in lots
> of more flexible libraries for the Java platform.
In addition string queries could by usefull:
Foo.class.fields ("foo");
or:
public Object get (String fieldName)
throws // Foo.class.fields (fieldName):
SecurityException, NoSuchFieldException,
// .get (this):
IllegalArgumentException, IllegalAccessException
{
return Foo.class.fields (fieldName).get (this);
}
IMHO this is a little problem: We have a bunch of exceptions for a
single field access.
Next example (with my syntax):
public static Object invoke (Object obj, String method)
throws // Foo.class.methods (method, null):
SecurityException, NoSuchMethodException,
// .invoke (obj, null)
IllegalAccessException, IllegalArgumentException,
InvocationTargetException
{
return Foo.class.methods (method, null).invoke (obj, null);
}
Five exceptions (ok +2: NPE and ExceptionInInitializerError), phew.
But much easier than the current reflection api.
> Thanks in advance for your attention and for positive comments.
+1 :-)
regards,
josh (sorry for my bad english)
--
Sollte beim Waschen der W鋝che diese absolut nicht weiss werden,
k鰊nte es sich um Buntw鋝che handeln.
[Haushaltstips - f黵 den n鋍hsten Tip eine Antwort provozieren...]
|
| |
|
| |
 |
Peter B黷tner

|
Posted: 2003-9-23 2:03:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
Aljoscha Rittner wrote:
> Carl Rosenberger schrieb:
> > I submitted the following RFE to Sun's RFE page.
> [...]
>
> > Field fooBarField = Foo.class.bar.field;
> > Method fooFlyMethod = Foo.class.fly.method(new Object[]{String.class});
> > Constructor fooConstructor = Foo.class.constructor(new Object[]{String.class});
> >
> > There are other possible options for the syntax. I would just like to see
> > this principally possible.
> An other syntax:
> Foo.class.fields.bar;
> Foo.class.methods.fly (new Object[] {String.class});
>
> I think this syntax is easier to read. fields and methods are like
> "collections" (see below my extensions)
This was my idea.
We access all members, not only public?!
> In addition string queries could by usefull:
> Foo.class.fields ("foo");
right, but:
Foo.class.getDeclaredField("foo");
is nearly the same, so better add less.
Or get the whole bunch:
Field[] f = Foo.class.fields
Methods[] m = Foo.class.methods
Constructor[] c = Foo.class.constructors
...
This seems to change the language to much? And doesn't
help so much as the changes above:
Foo.class.fields.bar, Foo.class.methods.fly
+1
Peter
|
| |
|
| |
 |
Paul Ebermann

|
Posted: 2003-9-23 4:28:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
"Aljoscha Rittner" skribis:
> Carl Rosenberger schrieb:
>
> > I submitted the following RFE to Sun's RFE page.
>
> [...]
>
> > Field fooBarField = Foo.class.bar.field;
> > Method fooFlyMethod = Foo.class.fly.method(new Object[]{String.class});
> > Constructor fooConstructor = Foo.class.constructor(new Object[]{String.class});
> >
> > There are other possible options for the syntax. I would just like to see
> > this principally possible.
>
> I think the qualifier .class. is a good idea. It ensures compatibility
> to accessible fieldnames.
>
> An other syntax:
>
> Foo.class.fields.bar;
>
> Foo.class.methods.fly (new Object[] {String.class});
I would like not using any "new", since "new"
is evaluated at runtime (and we want compile-time
checks).
Method fooFlyMethod = Foo.class.fly.method(String);
Constructor fooConstructor = Foo.class.constructor(String);
or
Foo.class.methods.fly(String);
> I think this syntax is easier to read. fields and methods are like
> "collections" (see below my extensions)
>
> [...]
> > JUSTIFICATION :
> > The existance of the field/method/constructor could be checked during compile
> > time. Typos would no longer be possible.
>
> But why? Reflection (scripting) is a runtime checked behavior.
For only runtime you won't need a new syntax.
The idea (as I understands it) is to enable
compile-time-checking, wherever possible.
(It should not disable the runtime-checking, which
is necessary anyway.)
> > A notation without strings could be very easily refactored by IDEs.
>
> ACK.
>
> > The possibility to get Method objects without strings, would encourage many
> > developers to use them for more dynamic programming and would result in lots
> > of more flexible libraries for the Java platform.
>
> In addition string queries could by usefull:
>
> Foo.class.fields ("foo");
For this already exists
Foo.class.getDeclaredField("foo");
and
Foo.class.getField("foo");
I see no need to use another Syntax with
only slightly less typing.
Paul
PS: +1
|
| |
|
| |
 |
rick

|
Posted: 2003-9-23 15:02:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
>Carl Rosenberger wrote:
>> > Hi Carl Rosenberger,
>> >
>> > Thank you for using our bug submit page. There may be merit to
>> > your request for feature enhancement (RFE). I would suggest
>> > that you first post this to a newsgroup and request comment from
>> > other java developers.
>> >
>> > You can view a list of Java newsgroups at:
>> >
>> > http://java.sun.com/aboutJava/newsgroups.html
>> >
>> >
>> > Based on the responses, please feel free to submit a new RFE
>> > containing a link to the newsgroup. Thank you for your time.
>
>Hi all,
>
>following the above directions, I just submitted another
>RFE (the third time) to the Java bug database.
>
>I would really appreciate further "+1" comments in this
>thread, should anyone else be interested to see this
>feature.
+1
|
| |
|
| |
 |
Jochen Theodorou

|
Posted: 2003-9-23 17:29:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
Carl Rosenberger schrieb:
[...]
> I would really appreciate further "+1" comments in this
> thread, should anyone else be interested to see this
> feature.
+1
(Sorry 4 days without internet)
Byte theo
|
| |
|
| |
 |
Lee Fesperman

|
Posted: 2003-9-24 8:01:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
Carl Rosenberger wrote:
>
> I would really appreciate further "+1" comments in this
> thread, should anyone else be interested to see this
> feature.
>
> It's a very small addition to the compiler and I know,
> the merit for dynamic programming would be great. We
> would really love to see the feature to be able to
> provide the first completely typesafe object querying
> system:
> http://sourceforge.net/projects/sodaquery/
Hi Carl,
At this point, I have to give you a -1.
I think you need to provide more general arguments for a feature that changes the
language.
Object querying has very limited use and doesn't justify a language change.
Dynamic programming could be more general use, but I have serious doubts about it.
You're basically introducing a form of function pointers and variable pointers to Java.
This is definitely not OO programming.
It only supports partial type safety ... for the caller. The called methods would have
no type safety. They would receive anonymous references, to Method, Field, Constructor
objects.
I don't see dynamic references of this type as needed for Java. I find Java effective
for system programming as is.
--
Lee Fesperman, FirstSQL, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)
|
| |
|
| |
 |
Carl Rosenberger

|
Posted: 2003-9-24 18:10:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
Lee Fesperman wrote:
> > I would really appreciate further "+1" comments in this
> > thread, should anyone else be interested to see this
> > feature.
>
> At this point, I have to give you a -1.
Hi Lee,
I didn't expect anything else from you since you have
always been putting down all my postings.
I don't think we would do eachother any good with another
"Your database sucks." "No yours!" thread.
Coexistence should be our goal. SQL certainly has a future
and I think that Java method calls within an SQL query
principally are a good idea. The Evaluation/Callback feature
in S.O.D.A. is designed to make this possible also, when we
start building an SQL layer on top of S.O.D.A. It would
be nice if we would support very similar SQL dialects in
the future.
We both provide native Java engines so we will both benefit,
if Java get's a greater share as an accepted standard as
the No.1 database stored procedure language.
> I think you need to provide more general arguments for
> a feature that changes the language.
The feature does not change the language, it only provides
a design-time shortcut for:
try {
Class#getDeclaredField("");
} catch (NoSuchFieldException e) {
// Handling not necessary since the
// compiler ensures the field is there.
}
Changes to VMs will not be necessary, only the above small
addition would have to be introduced to the compiler. I
would estimate that to be less than an hour of work.
> Object querying has very limited use
If you say so.
Funny, just yesterday someone posted to our newsgroup, that
he would like to see the feature I am talking about, without
the knowledge of this thread here. I will attach his message
to the end of this one.
The idea behind object queries:
They provide an abstraction layer as a base for other querying
systems like SQL, OQL, XPath, XQuery, JDOQL. With a common
object query system it would be possible to reuse multiple query
language parsers for all of the above query languages. All
parsers create a similar query expression tree so why not try
to set a standard at the lowest level possible? That would free
vendors from the work to write parsers themselves. Just by
implementing one standard they could support all the above query
languages. I do have some hope that Prevayler, OJB, and Hibernate
also will jump in on S.O.D.A., since I hear from them that they
are interested. I would love to share the work on query language
layers with these open source products.
> and doesn't justify a language change.
The comments from the other people here come from completely
different areas, where dynamic programming is used.
I am just trying to provide one single concrete example of a
benefit.
All the best for FirstSQL!
Cheers,
Carl
Carl Rosenberger
db4o - database for objects - http://www.db4o.com
and here is the posting to our newsgroup:
"Patrick Sager" <email***@***.com> wrote in message news:bkpnqf$n1v$email***@***.com...
> Hello
>
> I'm currently evaluating db4o and I like it very much, especially its ease
> of use.
>
> But I think, the following improvement could make it even better:
>
> 1. In the trace output, there are no indications, how a query is
> evaluated. Moreover if a column (e.g. in the descendent() method) is
> misspelled, there's no error, warning or exception. The query just returns
> nothing. To avoid the possibility of field misspelling, you could support a
> parameter of type java.lang.reflect.Field. Could you also print out a
> warning, if a field wasn't found?
>
> 2. If in the evaluate method the candidate is an actual descendent and
> he is excluded, the parent should also be excluded.
>
> 3. Support a constrain on a specific array field (e.g.
> descendent("myArray[5]").constrain(42).equal()).
>
> 4. If browsing the ObjectSet and other db4o classes in the debugger, it
> seems, that the member variables are obfuscated. And it's really hard to
> find out, what they mean.
>
> Best regards
> -- Pat
>
>
|
| |
|
| |
 |
Paul Ebermann

|
Posted: 2003-9-24 21:40:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
"Carl Rosenberger" skribis:
> Lee Fesperman wrote:
[...]
> > I think you need to provide more general arguments for
> > a feature that changes the language.
>
> The feature does not change the language, it only provides
> a design-time shortcut for:
It _is_ a (small) addition to the language, but
in a backwards-compatible way.
> try {
> Class#getDeclaredField("");
> } catch (NoSuchFieldException e) {
> // Handling not necessary since the
> // compiler ensures the field is there.
> }
I think, better would be
---
try {
Class#getDeclaredField("");
} catch (NoSuchFieldException e) {
throw new NoSuchFieldError(e);
}
---
since there could be a difference
between runtime and compiletime (new
Class version, ...)
(And the "ignore" does not work, since then
the field-variable may be not initialized.)
Paul
|
| |
|
| |
 |
Lee Fesperman

|
Posted: 2003-9-26 16:20:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
Carl Rosenberger wrote:
>
> Lee Fesperman wrote:
> > > I would really appreciate further "+1" comments in this
> > > thread, should anyone else be interested to see this
> > > feature.
> >
> > At this point, I have to give you a -1.
>
> Hi Lee,
>
> I didn't expect anything else from you since you have
> always been putting down all my postings.
>
> I don't think we would do eachother any good with another
> "Your database sucks." "No yours!" thread.
I will say that a database newsgroup is more appropriate for database issues like that.
I am discussing this purely as a Java issue.
I do object to your characterizations, though. I always try to make my remarks
substantive.
> > I think you need to provide more general arguments for
> > a feature that changes the language.
>
> The feature does not change the language...
No, you are wrong. It is a language change.
> Changes to VMs will not be necessary, only the above small
> addition would have to be introduced to the compiler. I
> would estimate that to be less than an hour of work.
I don't care if it takes 5 minutes. My issue is whether it is an appropriate change to
the language.
> > Object querying has very limited use
>
> If you say so.
Seems to be the crux of the matter.
> The idea behind object queries:
> They provide an abstraction layer as a base for other querying
> systems like SQL, OQL, XPath, XQuery, JDOQL. With a common
> object query system it would be possible to reuse multiple query
> language parsers for all of the above query languages. ...
I don't see that. You are mixing declarative and navigational languages.
> > and doesn't justify a language change.
>
> The comments from the other people here come from completely
> different areas, where dynamic programming is used.
>
> I am just trying to provide one single concrete example of a
> benefit.
I know. I'm just saying that you need to present more convincing arguments for this.
The other posters haven't either. I presented arguments against this use (which you
snipped).
> All the best for FirstSQL!
Thanks. I wish you well in your ventures.
No ill will intended. If you check back on my postings on cljp, you'll see that I am
quite conservative about changes to the Java language.
--
Lee Fesperman, FirstSQL, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)
|
| |
|
| |
 |
Carl Rosenberger

|
Posted: 2003-9-26 21:56:00 |
Top |
java-programmer >> [RFE] Access to Field, Method and Constructor without the use of Strings
Lee Fesperman wrote:
> > The idea behind object queries:
> > They provide an abstraction layer as a base for other querying
> > systems like SQL, OQL, XPath, XQuery, JDOQL. With a common
> > object query system it would be possible to reuse multiple query
> > language parsers for all of the above query languages. ...
>
> I don't see that. You are mixing declarative and navigational languages.
That's what your database engine does also:
It parses SQL and creates an object representation to be
processed by your query processor code.
A standard for the first step would reduce the necessary
implementation work for database products that don't
support SQL yet.
Kind regards,
Carl
Carl Rosenberger
db4o - database for objects - http://www.db4o.com
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- 2
- JOptionPane.showInputDialog on JButton[][] arraySorry i have a problem.
I don't know the java language but i must create a grid Of button witch
random Values, and when i clicked on one button i must change the internal
values.
I try ti make a code but i don't know how to pass the value of botton to
mouse event, and change it with
String input = JOptionPane.showInputDialog("Insert value:");
for a single button there aren't any problems, but how can I change the
value of an array of button witch MouseEvent?
Thx!!!! please help me!!!!
QUADRATOFRAME.CLASS
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Random;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
public class QuadratoFrame extends JFrame {
JButton pulsante = new JButton();
int N=6;
int MAXELEM = 50;
int[][] mat=new int[N][N];
JButton[][] jb = new JButton[N][N];
private JPanel pannello2= new JPanel();
LeftButtonListener leftListener = new LeftButtonListener();
public QuadratoFrame() {
Random generator=new Random();
for (int i=0; i<N; i++)
for (int j=0; j<N; j++)
mat[i][j]=generator.nextInt(MAXELEM);
for(int i = 0; i < N; i++)
for (int j=0; j<N; j++)
{
jb[i][j] = new JButton(Integer.toString(mat[i][j]));
pulsante=jb[i][j];
pulsante.addMouseListener(leftListener);
}
pannello2.setLayout(new GridLayout(N,N));
getContentPane().add(pannello2);
pack();
for(int i = 0; i < jb.length; i++)
for (int j=0; j<N; j++)
pannello2.add(jb[i][j]);
}
private class LeftButtonListener implements MouseListener {
public void mouseClicked(MouseEvent event) { }
public void mouseEntered(MouseEvent event) { }
public void mouseExited(MouseEvent event) { }
public void mousePressed(MouseEvent event) {
String input = JOptionPane.showInputDialog("Insert new value:");
}
public void mouseReleased(MouseEvent event) { }
}
}
QUADRATOTEST.CLASS
import javax.swing.*;
/**Una classe che rende attivo il programma Frattali
*tramite la costruzione e la visualizzazione della finestra Frattali nel
main.
*/
public class QuadratoTest {
public static void main(String[] args) {
JFrame myFrame=new QuadratoFrame();
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
myFrame.setSize(800,600);
myFrame.show();
}
}
- 3
- Data generatorDo You know if there is any data generator for databases like TurboData,
but for free?
- 4
- JMS and httpsHi all,
Have JMS to use with https
It says in documentation to supply these four arguments,
javax.net.ssl.trustStore, javax.net.ssl.keyStore,
javax.net.ssl.keyStoreType and javax.net.ssl.keyStorePassword
Here's my sample below:
System.setProperty("javax.net.ssl.trustStore", "C:\\Program
Files\\Java\\j2re1.4.2_03\\lib\\security\\cacerts");
System.setProperty("javax.net.ssl.keyStore",
"D:\\Projects\\certificates\\tomcat.keystore");
System.setProperty("javax.net.ssl.keyStoreType", "jks");
System.setProperty("javax.net.ssl.keyStorePassword",
"changeit");
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"org.exolab.jms.jndi.InitialContextFactory");
properties.put(Context.PROVIDER_URL,
"https://localhost:8443/");
jndiContext = new InitialContext(properties);
For some reason after creating the new initial context, its reporting:
Default SSL context init failed: null
Did I set my trustStore path correctly?
Thanks
- 5
- 6
- JBuilder applet, adding class to jarI have applet which uses classes like java.util.AbstractList,
java.awt.Point. Unfortunately MS VM doesnt support above(i got IO
exception, above classes not found) So i guess i have to add those
classes to my jar. No idea how to do it... Any help appreciated...
- 7
- How does Java make assignments atomic?>From what I understand, Java guarantees that all assignments to
primitive types (except non-volatile 64-bit types) will be atomic.
How does it do this? I thought that the only truly uninterruptable
processor instruction was the test-and-set, and that test-and-set was
the basis from which richer thread synchronization resources typically
provided by an underlying operating system (e.g. semaphores, mutexes,
critical sections) were built.
Does Java internally implement all of its generated assignment opcodes
inside some kind of test-and-set-based wrappers?
Thanks.
- 8
- Making and Returning Java Byte Arrays in C++ via JNI (Help! Please!)How do you make java byte arrays, fill them with values, and return
them in c++? I have no clue where to start. The JNI Tutorial a at
Java's website isn't much help because it doesn't really explain how to
make new jarrays. Any tips, how-tos and example code are welcome! (And
can anybody please explain me what's jsize? Is it just another integer?)
- 9
- portaudit and linux-sun-jdk15>
X-XaM3-API-Version: 4.3 (R1) (B3pl17)
X-SenderIP: 82.49.197.26
I'm referring to the informations displayed on this page:
http://www.vuxml.org/freebsd/18e5428f-ae7c-11d9-837d-000e0c2e438a.html
Is the information about linux-sun-jdk15 correct?
1.5.* <= linux-sun-jdk <= 1.5.2.02,2
I think that the correct version should be 1.5.0.02,2 considering also that a 1.5 based version >=1.5.1 doesn't (yet) exist.
The last jdk versions for linux is 1.5.0.11 and the port with that version has been committed today, but portaudit is still complaining about this vulnerability.
Thank you.
P.S.
Sorry if I'm writing to too many people, but I'm not sure about who is responsible for that problem.
------------------------------------------------------
Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom
http://click.libero.it/infostrada25feb07
- 10
- Tired of 100s of stupid Getter/Setter methodsTor Iver Wilhelmsen wrote:
> Dave Glasser <email***@***.com> writes:
>
> > Java does not. Methods can be overridden with less restrictive access
> > (like the common practice of overriding Object.clone() with a public
> > clone() method) but not more restrictive access.
>
> But they can be overridden with exception-throwing code to ensure
> they're not used.
Indeed. That's more of a symptom of a problem than a reasonable
solution. You're then left with a class that professes to follow an
interface, but doesn't follow it. What you really wanted was to
implement a different interface on top of existing functionality... a
task for which composition is ideal.
Of course, in a pinch, the exception-throwing kludge will work; it's
integrated into the collections API and even given a fancy name:
"optional methods". However, even its light application there is
generally acknowledged to be one of the few great failures of that API.
--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
- 11
- JButton - Set font to fillHi,
I want to create the best fitting font for my jbutton, so when the user
expands the UI, the JButton expands or shrinks, so I then change the size of
the font to fill the button correctly..
I am trying something like this on component resize:
- 12
- IE AutomationI am working on developing a test application in java. I use java for UI
only. I use JNI to communicate with a VC MFC DLL. I launch an IE browser
instance in one JNI method (init()), which works fine.
OleInitialize(NULL);
CLSID clsid;
CLSIDFromProgID(OLESTR("InternetExplorer.Application"), &clsid);
HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER,
IID_IWebBrowser2, (void**)&m_spBrowser);
I store the browser pointer (IWebBrowser2 *) as a C++ class instance
variable. BTW, I start a
thread on the native side (_beginthread) which in turn calls the method that
launches the browser.
Previously I was facing the problem of marshalling, the IWebBrowser2 pointer
was getting correupted, when used in different methods (even the simple
properties of IWebBrowser2 (like IWebBrowser2::fullname) were not
accessible). So now I have added the code of marshalling after the browser
is launched. In almost all the other methods, I first unmarshall the
interface and then marshall it back at the end of it. This solved my earlier
mentioned problem.
void CIECanvas::MarshallInterface()
{
HRESULT hr;
if(SUCCEEDED(hr = ::CreateStreamOnHGlobal(NULL, TRUE, &pstm)))
{
LARGE_INTEGER bZero = {0, 0};
pstm->Seek(bZero, STREAM_SEEK_SET, NULL);
if(SUCCEEDED(::CoMarshalInterface(pstm, IID_IWebBrowser2, m_spBrowser,
MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL)))
{
pstm->Seek(bZero, STREAM_SEEK_SET, NULL);
}
}
}
void CIECanvas::UnmarshallInterface()
{
LARGE_INTEGER bZero = {0, 0};
pstm->Seek(bZero, STREAM_SEEK_SET, NULL);
HRESULT hr = ::CoUnmarshalInterface(pstm, IID_IWebBrowser2,
(void**)&m_spBrowser);
if(FAILED(hr))
{
showMessageBox("CIECanvas::UnmarshallInterface()", "%s %ld", "FAILED.
ERROR CODE = ", GetLastError());
}
}
Then for recording I use AfxConnectionAdvise(), which is working fine.
The problem I am facing is in Replaying the events.
1)The VM crashes with a hotspot error, when on the first page some link
click event is present, which loads a new page. One observation here is the
VM crashes after onBeforeNavigate2 or TitleChange events are fired.
2)I also tried Yahoo's registration page (having a lot of dropdowns and
checkboxes), it works fine for the first few events, but then the VM
crashes.
My questions are
1)Does IE handle the events like page loading (tiltle change etc.) and click
on some link in different threads? How are the events handled (any useful
info on this)?
2)How should I fix the problem?
3)Is it related to marshalling of IE COM pointers?
Please replay ASAP,
Nikhil
- 13
- Help choosing JSP ServerHello,
could you folks share with me your recomendations on what JSP servers are
available for a small
business with a very small budget, hopefully something that would produce
error message little
more descriptive than that of Tomcat and also with discent web-server
plugin capabilities and
administration interface.
Thanks in advance,
Ilya Bari.
- 14
- SQL into XMLHi All;
My SQL queries return one, two, sometimes even three levels of XML
data.
So for orders in my system I would like to see in my XML:
<RESULTS>
<order>
<number>3213</number>
<date>Feb 03, 2003</date>
<product>
<name>NEC Monitor</name>
<quantity>3</quantity>
<serial_numbers>
<sn>12321312321</sn>
<sn>44314133422</sn>
<sn>43434343553</sn>
<serial_numbers>
</product>
<product>
<name>Genius Mouse</name>
<quantity>2</quantity>
<serial_numbers>
<sn>23232</sn>
<sn>44343</sn>
<serial_numbers>
</product>
</order>
<order>
<number>444</number>
<date>Mar 06, 2003</date>
<product>
<name>MS Keyboard</name>
<quantity>1</quantity>
<serial_numbers>
<sn>333333</sn>
<serial_numbers>
</product>
</order>
........
</RESULTS>
obviously my query would reutrn
order_num order_date product_name quantity
serial_number
------------------------------------------------------------------------
3231 Feb 03, 2003 NEC Monitor 3 12321312321
3231 Feb 03, 2003 NEC Monitor 3 44314133422
3231 Feb 03, 2003 NEC Monitor 3 43434343553
3231 Feb 03, 2003 Genius Mouse 2 23232
3231 Feb 03, 2003 Genius Mouse 2 44343
444 Mar 06, 2003 MS Keyboard 1 333333
You get the point. I do not want to have 3 queries, but only one that
returns something like described above.
For now I have a functioin that does this, but the algorithm is not
the best, and it only works for two levels (so XML without the s/n for
example).
This must be a common problem, I would appriciate input as to how this
is commonly done, any pointers to web sites, articles... are all
welcome. I'd try to search the groups but for what?:) I would also
like to describe my current algorithm, but for now it seems I would
just bore you.
Looking for some input,
Damjan
- 15
- Using BigInteger and BigDecimal [WAS: Converting floats to Strings and back]
"Alun Harford" <email***@***.com> wrote in message
news:dlvmk8$j8e$email***@***.com...
>
> Unless you want speed (ie. the arithmetic is hard and you've analysed the
> result of using floating-point to do it), or you want to demonstrate some
> of
> the nasty things that happen with floating point, use BigDecimal.
> a) It requires significantly less use of your brain, which generally
> reduces
> the number of bugs.
> b) Your users shouldn't have to think about the limitations of floating
> point without a very good reason.
I've experimented with using BigInteger instead of int in my code with
mixed results. Code that was integer-math intensive (e.g. finding prime
numbers) typically ran 5 to 7 times slower, which is pretty bad, but not
"noticeable" for typical user applications. I'll probably continue this
practice because for most of my apps, the bottleneck is not the
integer-math, and the extra flexibility is nice.
My question is: is there a "best" way to store BigInteger and BigDecimal
values in databases (particularly in SQL)? The two most obvious solutions to
me is to store them as BLOBs or as strings. I'd probably favor the latter,
because although it uses more storage space and processing time (e.g. to
parse the string back into a BigInteger value), it'll probably be easier to
inspect the DB to make sure all the values are correct during debugging.
- Oliver
|
|
|