Anything Java...

IamBob

Registered
Anything Java...
questions, comments, source, project ideas and in-the-works projects are welcome and encouraged.

Here's my not yet completed project and ProjectBuilder example. -being updated tomorrow.

[Edited by IamBob on 11-29-2000 at 01:37 PM]
 
IAmBob -

This kind of comes from the other thread, about documentation and such with the java classes or more specifically, the NS classes. I assume since you have the PB/IB you have the Developer Tools... If so, have you seen the application called 'JavaBrowser' ? That is a really nice tool that shows all the classes, constructors, methods, fields, etc...

It seems to be the only fairly complete documentation of the classes... You'll notice 3 buttons at the bottom of the window... the one that looks like 'books' has descriptions of the methods and such.

Is that something that might help?
 
Originally posted by G4Rules
IAmBob -
If so, have you seen the application called 'JavaBrowser' ? That is a really nice tool that shows all the classes, constructors, methods, fields, etc...

Cool i'll check that one out too.
I have also found this on Apple's http://developer.apple.com/techpubs/macosx/Cocoa/Reference/ApplicationKit/Java/Classes/

The directory contains websites with information on all Cocoa-Java classes. Not really nice, but useable. It has info on the in's and out's of the classes. The variables and the methods it contains etc.

Hopefully i can start working on cocoafy'ing my app the coming weekend. Let's make this Thread a place too share our experiences doing just that.
If you ask me the Java + Cocoa way simply rocks.

DJ
 
Is there anyone around who has created Packages and scripts for the OSX Installer?
I would like to take a shot at it myself, but it would be nice if i knew there was someone there who could help me out with any questions or problems i will run into.

DJ
 
hey..thanks! I have used JavaBrowser a bit(checking for the old MRJ stuff mostly) but didn't notice the books button.

Not really nice, but useable.
you said it. I guess that's what I was trying to get at with my lil rant back in the other thread...sorry 'bout that.

I didn't even think about installer scripts or anything. Maybe I'll dabble and see if I can't get something working in that area as well.

Well, I'm gonna go update my page and check out the JavaBrowser and see if I can't get a simple NS project working

see ya.
 
I downloaded Nicer and nothing happens when I double-click a process. I don't know what's wrong.

I didn't think about it untill now...

if you minimize it, switch apps then come back to it it locks you out. The "fix" is to switch apps again(while it's not minimized). I had reported that to Apple and forgot about it. I'm not having it do any voodoo when it recieves windowIconified or windowDeiconified events so I know it's not my code. I had tried a few things to workaround it but nothing seems to fix it. I don't know if that was what happened so whatever..I'm working on it.

Oh, the JavaBrowser rocks! I think I tried clicking the book button before(couple weeks ago when I was messing with it) and nothing happened..now I know why. I was probably trying to view source it couldn't find(duh@myself). I went ahead and added the JDK docs to its list of searchable directories...that's damn cool. :)

on another note..I've got a new project going. I'm trying to use NS classes for Nicer's GUI. I've got my table(NSTableView) in the window and a label at the bottom. I guess my problem is that I don't know how to get a handle to the table besides through the events it sends. I need to be able to populate the table and for now it only almost-kinda-works. When you click on one of the column headers it puts some junk data in the table(as it should for now). Obviously this won't work so I'm lost.

well, I still need to go update my page so I guess I'll do that.

[Edited by IamBob on 11-30-2000 at 05:06 PM]
 
Originally posted by IamBob
I guess my problem is that I don't know how to get a handle to the table besides through the events it sends. I need to be able to populate the table

I'm not a programmer, and know very little about Cocoa. But here is a bit of code that uses an OutlineView (subclass of TableView). I don't know how directly to get a handle to the table, either -- but if you use interface builder, then it should give you the handle automatically.

To populate the table, you use the delegate methods. For an outline view, this is done in the outlineViewChildOfItem method (which gives an item (null if top-level) and the index of the child requested). Another delegate method is outlineViewObjectValueForItem, which gives you a table column and the item representing the row being displayed; you need to extract the column info from the item.

That's probably unclear. I agree that the documentation is pretty awful, especially compared to that for Java. But the sample ObjC code is useful for understanding the API through Java as well.

--
<pre>
/* ArticlesList */

import com.apple.cocoa.foundation.*;
import com.apple.cocoa.application.*;

import java.io.*;
import java.util.*;
import java.text.*;

public class ArticlesList {

Vector threads = new Vector(); // initialize for outline view

NSOutlineView outline;
NSWindow articlesWindow;

Client client;

private void addArticle(Article art, Hashtable threads) {
Vector refs = art.header.references;
if (null != refs) {
for (Enumeration e = refs.elements(); e.hasMoreElements(); ) {
String ref = (String)e.nextElement();
NSMutableArray thread = (NSMutableArray)threads.get(ref); // make Thread
if (thread != null) {
thread.addObject(art);
return;
}
}
}
// no thread has fit
NSMutableArray thread = new NSMutableArray();
thread.addObject(art);
if (art.header.id != null) {
threads.put(art.header.id, thread);
} else {
threads.put(art.header, thread); // doesn't need to be in thread list
}
}

public void loadArticles(Client client, Newsgroup group) {
this.client = client;
Hashtable threads = new Hashtable();
try {
client.selectGroup(group);
for (int i = group.start; i <= group.end; i++) {
String header = client.getHeader(i);
if (null != header) {
Article article = new Article(header);
addArticle(article, threads);
}
}
} catch (IOException e) {
System.out.println("Error: lost connection");
return;
}
this.threads = new Vector(threads.values());
System.out.println("Fetched " + threads.size() + " threads");

outline.reloadData();

if (!articlesWindow.isVisible()) {
articlesWindow.setFrame(new NSRect(183, 75, 556, 422), true);
}
articlesWindow.orderWindow(NSWindow.Above, 0);
articlesWindow.makeKeyWindow();
}

// Returns the number of child items encompassed by item. If item is null, this method should return the number of children for the top-level item.
// only called on objects which are expandable (Vectors)
public int outlineViewNumberOfChildrenOfItem(NSOutlineView outlineView, Object object) {
if (null == object) {
return threads.size();
} else {
return (((NSMutableArray)object).count() - 1);
}
}

// Returns the data object associated with the specified item. The item is located in the specified tableColumn of the view
public Object outlineViewObjectValueForItem(NSOutlineView outlineView, NSTableColumn tableColumn, Object item) {
if (null == item) {
return null;
}
Article article;
//if ("java.util.Vector".equals(item.getClass().getName())) {
if (item.getClass().getName().endsWith("NSMutableArray")) {
article = (Article)((NSMutableArray)item).objectAtIndex(0);
//return ("" + ((NSMutableArray)item).count());
} else {
article = (Article)item;
}

String response = null;
if (tableColumn.identifier().equals("author")) {
response = article.header.from.name;
} else if (tableColumn.identifier().equals("subject")) {
response = article.header.subject;
} else if (tableColumn.identifier().equals("date")) {
response = DateFormat.getDateInstance().format(article.header.date);
}
return response;
}

// This method should return true if item can be expanded to display its children.
public boolean outlineViewIsItemExpandable(NSOutlineView outlineView, Object item) {
if (null == item) {
return false;
} else {
//if ("java.util.Vector".equals(item.getClass().getName())) {
if (item.getClass().getName().endsWith("NSMutableArray")) {
// Vector v = (Vector)item;
NSMutableArray v = (NSMutableArray)item;
return (v.count() > 1);
} else {
return false;
}
}
}

// Returns the child item at the specified index. Children of a given parent item are accessed sequentially. If item is null, this method should return the appropriate child item of the root object.
public Object outlineViewChildOfItem( NSOutlineView outlineView, int index, Object item) {
if (null == item) {
return threads.elementAt(index);
} else if (item.getClass().getName().endsWith("NSMutableArray")) {
NSMutableArray v = (NSMutableArray)item;
return v.objectAtIndex(index + 1);
} else return null;
}
}

</pre>

One last thing: I wasn't able to use Vectors as the row representation item for some reason; that's why I'm using NSMutableArrays.

[Edited by tie on 12-02-2000 at 09:38 PM]
 
I'm not a programmer, and know very little about Cocoa.

Well, I'm impressed. You've obviously have a better grasp on these things than I do. :)

As for IB giving you a handle..not quite and not that easily. I'm going to sift my way through the docs and see if I can get around having to use IB(or how to better use it). I went through the Cocoa/IB/PB tutorial and still don't quite get it. If someone wants to do an example IB/PB project, please, do so.

Well, thanks for the ideas at least. I'm not sure what I'm going to do next...ahh! :)
 
Okay, i tried to mull through this the hardway, but i think the coming finals week has prematurely fired my brain. Thw NSBrowser docs made NO sense to me. All I want is a nice little "Open" menu item that would allow the user to select a file in the file heiarchy. WEll, I have the mneu item, and I even have a nice, but empty NSBrowser field. So... what do i have to do to make it so all the hardrives and the like comes up as the first column and from which u can navigate down the file structure? (That's a big question, but my brain is REALLY fried.)

Second, does anyone know how to make it so you can drap a file onto an window and the location of the file is then taken by the java app so it can do its little eveil deeds with the file?

Just a wonderin'
F-bacher
 
Originally posted by Ghoser777
All I want is a nice little "Open" menu item that would allow the user to select a file in the file heiarchy.

Second, does anyone know how to make it so you can drap a file onto an window and the location of the file is then taken

Maybe you should look at NSOpenPanel instead of using an NSBrowser (but if you want to do it the hard way, there is an AppKit example which uses an OutlineView to browse through files). For the second question, try looking at the drag-and-drop code, then NSPasteboard. You use the drag pasteboard and take dataForType("FilenamesPboardType"). I believe Java now has drag-and-drop built in, too, but I have never tried it.
 
Originally posted by IamBob
As for IB giving you a handle..not quite and not that easily.[/B]

I'm not entirely sure what's holding you up here.

Here's what I just tried: I opened P(roject)B(uilder) and created a new Cocoa project. I opened the Main.nib file with I(nterface)B(uilder). There already was a blank window; I just dragged into it a TableView (packaged inside a ScrollView on the top right of the tabulation views palette). I opened the Inspector and double-clicked the table columns to set their names, "Date" and "Name." In the Attribute panel I set their respective identifiers to be "Date and "Name" as well. That's done.

Next, I switched to the Classes tab, selected java.lang.Object and went to Classes/Subclass. I named the subclass TableSource. I then went to Classes/Add Outlet, and added an outlet called table. Finally, I selected the class, and went to Classes/Instantiate.

Back in the Instances tab, I control-dragged from the TableSource object into the TableView. With the Inspector open, it switches to the Connections pane, and shows the single outlet, table. Press connect and it should say that an NSTableView is connected. I then control-dragged from the TableView to the TableSource. I selected the dataSource outlet and connected that. Finally, I went to the Classes tab, selected TableSource and went to Classes/Create Files... Saved a java file and finished with IB.

Now in PB, I opened the TableSource.java file and put in the following code (some was already there):

<pre>
/* TableSource */

import com.apple.cocoa.foundation.*;
import com.apple.cocoa.application.*;

public class TableSource {

NSTableView table;

public int numberOfRowsInTableView(NSTableView aTableView) {
return 100;
}


public Object tableViewObjectValueForLocation(NSTableView aTableView, NSTableColumn aTableColumn, int rowIndex) {
if (aTableColumn.identifier().equals("Date")) {
return ("Date" + rowIndex);
} else {
return ("Name" + rowIndex);
}
}
}
</pre>

Save the nib and compile, and you should have a working, scrolling table, with row n having "Daten", "Namen" in it. It actually doesn't use the table outlet, but it is there if you need it (call table.reloadData() if the datasource changes). This is what I meant when I said IB automatically gives you a handle; it does so if you create an outlet and connect it.

[Edited by tie on 12-04-2000 at 12:26 AM]
 
And now I feel stupid because the IDE isn't doing what I want how I want. Every time I've tried to use an IDE it's been awkward and more of a pain than it's worth. This time is no exception.

I had something like that((../Developer/Documentation/Cocoa/JavaTutorial/)JavaTutorial.pdf led) but wasn't sure which connections to make and how to get a handle to the NSTableView without needing an action first.

I should be able to get it working now...thanks! :D
 
I get it! :D

A week of awkwardness for this ease...not bad. Sure, it'll take me a bit to get fully used to it but this could almost be fun.

damn you rock! I'm gonna go see if I can get this really flyin'!
 
Got the ps data in the table and am recieving clicks. I'm able to get the data under the clicks. I've just got to add the slider, buttons and a label. That was too easy!

I guess it didn't quite click in my head. I owe you big time! :D
 
Ok, so here is what I have...
I have a little program that draws an immovable window in the bakcground of everything (everything but the desktop... still don't know about that) then makes a little NSView subclass that makes it snow in the background (there was a nifty app like that I liked when I Was messing with a little bit o redhat a while ago, but that system DIED hardcore [won't even start up anymore], so I am now scared of linux).

ANYWAY, I'm having the worst time trying to convince the the NSWindow to not redraw my view everytime... among other things, like transparency, and many other other things. I want to have control on what it re-draws, so that I can pile up snow, and stuff...
Everything I've tried (in messing with my SnowView and with the NSWindow) still redraws the whole thing from scratch (particularly, it displays the NSWindow's background on the entire frame)

So, my other thought was to save that which I draw to a picture, and then I could have control in updating that, but all I can find is the NSCustomGraphicsContext, which also re-draws everytime...

I really just want a java-esc getGraphics() method that won't flush the image...

forget what it's called though..
non-disposal, or something?

However, the app DOES run, mostly...
Takes up a bit of CPU time, and I am not sure how to tell the OS that my process isn't very important (do I even need to do that?) even on my B+W G3

I might even post it someplace, because I've seen some cute useless things like it out there...

I'm just messing around, no real programming knowledge and it is still fun, so I am keeping at it...


still... some people keep saying that Java is slow, even as Cocoa, to do anything useful....

but I have hope...


cc
 
Originally posted by nullcc
However, the app DOES run, mostly...
Takes up a bit of CPU time, and I am not sure how to tell the OS that my process isn't very important (do I even need to do that?) even on my B+W G3

I might even post it someplace, because I've seen some cute useless things like it out there...

I'm just messing around, no real programming knowledge and it is still fun, so I am keeping at it...


still... some people keep saying that Java is slow, even as Cocoa, to do anything useful....

but I have hope...


cc

use "renice number app", where number is between -20 and 20, with -20 giving highest priority.

HTH,
F-bacher
 
However, the app DOES run, mostly...
Takes up a bit of CPU time, and I am not sure how to tell the OS that my process isn't very important (do I even need to do that?) even on my B+W G3

You don't have to but you might want to renice. You can find source to do that here. You'd need to call ps(look in the man for the best way) to get the PID of your process then as Ghoser777 said, "renice newval pid". As for your window problem, can't you unbuffer it in the IB>Inpector>Attributes of the window?


Okay, I'm lovin' it. Sure, the docs could be a little better but you almost don't need them..so it doesn't matter. After it clicked in my head I've had almost no trouble with IB. I had a few problems getting my drawer sized properly and it's still not quite right but it's ok...nothing major.

I think it's taken me about 3 hours to get it from all Java to Obj-C++(Apple's own term..look in Project BuilderWO>Inspector). And most of the time taken was just sizing and resizing components to get them how I wanted.

I need to go update my page...got a new Nicer to put up! :D
 
Does anyone have any experience installing the javax.crypto framework? Just curious. I have installed it locally (for single user) but don't really know how to install it system-wide. Are there any issues I should be aware of for installing the security manager (i.e., should I install it statically or dynamically; if I install it statically, am I going to have to redo it all when I upgrade to OS X final?)

[Edited by tie on 12-08-2000 at 12:26 AM]
 
Back
Top