Grub de Bliek

Greenhorn
+ Follow
since Sep 09, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Grub de Bliek

If I had the class I could of course invoke a static method on it, like this:
com.company.tool.SomeThing.methodA();

But all I have is a String, ie "com.company.tool.SomeThing". Of course I must have the class first before I can invoke the static method. So how do I convert "com.company.tool.SomeThing" into com.company.tool.SomeThing

Because I want to invoke static methods, there's no point in instantiating the class. Also I prefer not to use reflection.
So my question is: is there a way to invoke static methods on a class I only have the class name of, preferably without using reflection?
19 years ago
Hello,

I have a question I can't find the answer for. Maybe here I can find it.

In short the question is: can I invoke static methods of a certain class when I only have the Class object?

The situation is this:
1. I have a class com.company.tool.SomeThing with method public static void methodA() and field public static final String SOME_FIELD.
2. I do not want to instantiate this class.
3. I just have the class name: (com.company.tool.SomeThing)

What I'm trying is this:


I also want to retrieve the static public field but of course that won't work either. I really don't want to instantiate the class, but maybe I should consider to make it a Singleton with non static methods.
19 years ago
Hello,

I'm trying to use a JTable in combination with the Sun TableSorter (v2.0 02/27/04). All works fine, but the user selection on the JTable disappears, when rows are added dynamically.

TableSorter provides a the method public int modelIndex(int viewIndex), so it's always possible to modify the correct row in the tablemodel when you only have an index of the view.
However, what I need is to retreive the index of the view, while I only have the index of the tableModel.

It works like this:
1. Before I add a row to the tableModel, I can get the selected rows from the JTable, and retrieve the indexes of the tableModel with the method modelIndex.
2. Then I add the row. Practically it is inserted in the view, because my Table is sorted. The row is added to the end of the TableModel, but inserted somewhere at an unknown place in the JTable.
3. I still have the tableModel indexes of the selected rows, and I just need to know their view indexes. But here I'm stuck. There's no way I can convert a modelIndex to a viewIndex.

By the way I'm using MULTIPLE_INTERVAL selections.

Here's the Sun TableSorter I'm using:

[ June 23, 2005: Message edited by: Grub de Bliek ]
19 years ago
Hello,

I'm having a problem here with the design of my Swing app. It is a typical application with a JTree for navigation on the left, and a screen on the right.
Each node in the tree implements an interface with the method JPanel getScreen(), so I'm able to set the screen on the right with the correct screen when selected. This way I can add any node with an own screen to the navigation tree.

Because I want to keep View and Model separated, each Node in the tree contains a DataObject. Lets say my application displays files and directories, then I have a DirectoryNode containing a DirectoryDAO, and a FileNode containing a FileDAO. When a node is clicked, details of the object belonging to it are shown in the screen on right.
All looks good to me so far. I have a lot of different types of DataObjects displayed in my application.

However my problem is that I've several objects that must be available for all of them. For example, because I want to be able to show modal dialogs, I need to have the top level JFrame available for each node. Also, because I must be able to add and remove nodes, I must be able to access the navigation tree from any node. Those are the View objects that must be available.

Also, my DataObjects are nested. Like with Directories and Files, each File or Directory must be able to access the properties of its parent directories. Those are the Model objects that must be available to the child DataObjects.



I've been trying to implement this using a "Context" object which I'm passing to the constructor of any child node added to the tree. Context just contains the JFrame, the Tree, and the parent DataObject. Any new DataObject in the tree just adds itself to the Context and passes the context to its children.

However this is a far from perfect solution.
1. First of all, Model and View are mixed in my Context object, which I don't want.
2. Secondly, not all properties of Context can be final because after creation they must be set by the child data objects. This means they can be null, or set with wrong values.

I really don't know how to handle this, and my whole beautiful application gets messed up right now. Does anyone have some suggestions for me how to solve this?

Thank you very, very much.
[ June 21, 2005: Message edited by: Grub de Bliek ]
19 years ago
Hi,

I'm looking for a couple of good locations on the web where I can find summary's and surveys of (JDBC) databases.

I do not use db's frequently, but when I need to do something with it I always spend hours on the web looking fo specs and features, compatible datatypes, XA support, etc.

99% of the pages I find are commercial advertisement. Specs and features are hard to find, surveys of more than one db even harder.

If anyone can help me with this, I would be very, very grateful..

grtz,
Gerben
What experience/knowledge is required when I want to go for the SCBCD using your material? Do I need SCJP at least? Or SCWCD?
Is it just a similator and do I need another book for the theory?
How many questions are in the simulator?
Is the JMX included in the SCBCD?
Ok thanks!
I knew I could put a try/catch block in a finally block, but I was thinking that prevented the finally block from executing. I see that isn't correct, if an exception occurs in a finally block, the rest of the code is executed anyway.
1. When I close my statement and my connection, do I lose the ResultSet I just queried?
2. Look at this piece of code:
//querying code....
} catch(SQLException e) {
e.printStackTrace();
} finally {
if (statement != null)
statement.close();
if (connection != null)
connection.close();
}
}
This can't be done cuz both close() methods must be handled with an SQLException as well. The way I see it is that I *must* catch that SQLException one level higher, but I don't want that. All my exceptions must be handled in this method. Is there a way to solve this?
But isn't it right that Red Hat Linux is the officially supported Linux platform?
From http://java.sun.com/j2ee/1.4/download-dr.html:
The following table lists the required version of J2SE for each operating system that is supported with this release of J2EE:
SolarisTM SPARC 8, 9
Windows 2000 Professional SP3+
Windows XP Professional SP1+
Windows 2000 Server SP3+
Windows Server 2003
Linux Redhat, v8.0
I have a couple of questions about this. I installed an old version of Red Hat, 7.3. I'm totally no Linux expert, so the question is quite easy:
How can I upgrade to the latest Red Hat release?
Do I have to buy a new release, or can I download it somewhere. Is it enough to install a new kernel, or doesn't that upgrade the whole release?
I've been looking for some time now, but the answers on the simplest questions are always hard to find.
And can I also run all Java 2 Enterprise Platform applications like JBoss and Bea Weblogic on other Linux release like Suse?
21 years ago
I think it's wrong to study the working of the design pattern itself, you should only study the situation it could be applied on.
Then, when you're developing you will sometimes run in situations difficult to solve. Then you will recognize those difficulties and think, "Hey! Doesn't the singleton solve this problem? How does a singleton work?"
And then you're gonna study the design pattern and implement it. This way you won't use much design patterns, but the number will grow when you get more experienced, and recognize more situations. Try to avoid to write your app around a design pattern, rather write your app and then refactor it with a design pattern.
It certainly does! Nice piece of work there...
I'm gonna try to use this in my code. Thx!
Hey,
I'm creating a simple GUIBuilder that builds a GUI from a XML file. I've build it working a few times, but I don't like the design. Number 1 uses one big class that gets the File and returns two references to the mainWindow and the GUIModel. Number 2 uses a class GUIBuilder that calls methods from a class XMLFileReader to get the components out of the XMLFile. But, because the GUIBuilder adds the components one by one on the GUI and in the GUIModel, I can only call static methods in de class XMLFileReader.
It works, but I'm not happy with it, because it's too big already and I use only a couple of components yet.
Those are my requirements:
- I must read a component from the xml file, check it's attributetype, and create the component, I also read attr's like size and position from it's child components and set them.
- I must be able to get a component from the GUI on its unique id, so I need a model with an id-reference mapping(of the component). Especially because I'm gonna add some event handling later).
Problem is that I always tend to functional programming (with the static methods). Maybe someone in here can give me a few hints on how to solve this.
Apparently you TableModelFilter doesn't work correct. Can't say what's wrong with it.
Here's a TableSorter that works with indexes. I once implemented a TableFilter that looked alot like a TableSorter, so this might be a good example.
http://www2.gol.com/users/tame/swing/examples/JTableExamples5.html
21 years ago
tried a revalidate()?
21 years ago