Is there a way of doing this without using an inner class
hi, i have developed a tree applet but it takes ages to load on my machine. I was wondering if i could get rid of the inner class that is created when "valuechanged" is called (line 28). I am posting my whole code, i hope someone can help. Cheers Rups
[email protected]
import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.TreeSelectionListener;
import javax.swing.event.TreeSelectionEvent;
import java.net.*;
import java.applet.AppletContext;
import java.util.Enumeration;
public class SimpleTree extends JApplet {
JTree tree = new JTree();
public void init() {
new SimpleTree();
public SimpleTree() {
// WindowUtilities.setNativeLookAndFeel();
Container content = getContentPane();
Object[] hierarchy =
{ "Some Useful Web Links ",
new Object[] { "Microsft","http://www.microsfot.com"},
new Object[]{"Yahoo", "http://www.yahoo.com"}
DefaultMutableTreeNode root = processHierarchy(hierarchy);
final JTree tree = new JTree(root);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)
tree.getLastSelectedPathComponent();
String hoopla = tree.getLastSelectedPathComponent().toString();
if (node == null) return;
if (node.isLeaf()) {
try {
getAppletContext().showDocument(new URL("file://c:/webstuff/"+hoopla),
"viewer1");
}catch(Exception f) {
System.out.println("" + f);
content.add(new JScrollPane(tree), BorderLayout.CENTER);
setVisible(true);
public DefaultMutableTreeNode processHierarchy(Object[] hierarchy) {
DefaultMutableTreeNode node =
new DefaultMutableTreeNode(hierarchy[0]);
DefaultMutableTreeNode child;
for(int i=1; i<hierarchy.length; i++) {
Object nodeSpecifier = hierarchy;
if (nodeSpecifier instanceof Object[]) // Ie node with children
child = processHierarchy((Object[])nodeSpecifier);
else
child = new DefaultMutableTreeNode(nodeSpecifier); // Ie Leaf
node.add(child);
return(node);
public static void main(String [] args) {
JFrame f = new JFrame("") ;
Container contentPane = f.getContentPane();
contentPane.setLayout(new FlowLayout());
SimpleTree ta = new SimpleTree() ;
ta.init() ;
f.addWindowListener(new ExitListener());
f.setSize(250,500);
contentPane.add(ta,BorderLayout.CENTER);
f.setVisible(true) ;
import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.TreeSelectionListener;
import javax.swing.event.TreeSelectionEvent;
import java.net.*;
import java.applet.AppletContext;
import java.util.Enumeration;
public class SimpleTree extends JApplet implements TreeSelectionListener {
JTree tree = new JTree();
public void init() {
new SimpleTree();
public SimpleTree() {
// WindowUtilities.setNativeLookAndFeel();
Container content = getContentPane();
Object[] hierarchy =
{ "Some Useful Web Links ",
new Object[] { "Microsft","http://www.microsfot.com"},
new Object[]{"Yahoo", "http://www.yahoo.com"}
DefaultMutableTreeNode root = processHierarchy(hierarchy);
final JTree tree = new JTree(root);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.addTreeSelectionListener( this );
tree.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)
tree.getLastSelectedPathComponent();
String hoopla = tree.getLastSelectedPathComponent().toString();
if (node == null) return;
if (node.isLeaf()) {
try {
getAppletContext().showDocument(new URL("file://c:/webstuff/"+hoopla),
"viewer1");
}catch(Exception f) {
System.out.println("" + f);
content.add(new JScrollPane(tree), BorderLayout.CENTER);
setVisible(true);
public void valueChanged(TreeSelectionEvent e) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)
tree.getLastSelectedPathComponent();
String hoopla = tree.getLastSelectedPathComponent().toString();
if (node == null) return;
if (node.isLeaf()) {
try {
getAppletContext().showDocument(new URL("file://c:/webstuff/"+hoopla),
"viewer1");
}catch(Exception f) {
System.out.println("" + f);
public DefaultMutableTreeNode processHierarchy(Object[] hierarchy) {
DefaultMutableTreeNode node =
new DefaultMutableTreeNode(hierarchy[0]);
DefaultMutableTreeNode child;
for(int i=1; i<hierarchy.length; i++) {
Object nodeSpecifier = hierarchy[ i ];
if (nodeSpecifier instanceof Object[]) // Ie node with children
child = processHierarchy((Object[])nodeSpecifier);
else
child = new DefaultMutableTreeNode(nodeSpecifier); // Ie Leaf
node.add(child);
return(node);
public static void main(String [] args) {
JFrame f = new JFrame("") ;
Container contentPane = f.getContentPane();
contentPane.setLayout(new FlowLayout());
SimpleTree ta = new SimpleTree() ;
ta.init() ;
// f.addWindowListener(new ExitListener());
f.setSize(250,500);
contentPane.add(ta,BorderLayout.CENTER);
f.setVisible(true) ;
}
Similar Messages
-
I have an iPod which I currently sync on my iMac, but I want to sync it on my Apple mac pro, how do I do this? Is there a way of doing it without restoring my iPod?
Post here:
https://discussions.apple.com/community/ipod -
Why can't you print a cd jewel case listing of songs using iTunes. Is there some other way to do this without using iTunes?
Hi spider1950,
As long as you have the most recent update of iTunes (11.0.4), you should be able to print a jewel case insert directly from iTunes. You may find the following page useful:
Apple Support: Print CD Inserts
https://www.apple.com/findouthow/music/itunes.html#makecd-printinserts
Regards,
- Brenden -
I just purchased a new Win 8.1 laptop and want to authorize it for my iTunes library. I operate this library on a Win 7 desktop. I have three other Windows computers that I no longer own which were authorized under my iTunes account, but I can't unauthorized them because they are broken or sold. I want to have Computer Authorization for just my current desktop running Win 7 and my new laptop operating Win 8.1. How can I selectively unauthorize a computer if I no longer have it in my possession, and if I have to unauthorize all of my computers, how do I get my iTunes library of music back onto my current desktop system?
Deauthorizing the computer will not remove the content from your library. You deauthorize all, then authorize the ones you want. See this support document. Deauthorize your computer using iTunes - Apple Support
-
I would like to duplicate the folders and apps that I have set up on my iPhone to my iPad. Is there a quick way of doing this without going through the whole process again manually?
You can restore your iPad with your iPhone backup but items that are iPhone only will not transfer. It should recreate all your folders. It can't hurt anything to try.
-
OK....... I have an Ipod and an Iphone. Would like all the Movies and music i have on both. My computer broke and now the only music i have is on ipod. It wont let me transfer to itunes. It says this device is linked to a different library and if i want to sync to a new one and delete everything on it. UH....NO Is there a way to do this without deleting ? All purchases were made though the same apple id.
- An iPod can only sync with one iTunes library. Yu can however manage music and videos among different computers by:
Using iPhone, iPad, or iPod with multiple computers
- To change syncing computer, move all the media to compute r#2
- Connect the iPod to #2 and make a backup by right clicking on the iPod under Devices in iTunes and select Back Up
- Restore the iPod from that backup
Note tha the iPod backup the iTunes makes does not include synced media like apps and music. -
i updated to maverick, and maybe it's a coincidence but my left shift key doesn't work unless i really press it down. Is there any way to fix this without bringing it into the Genius Bar?
Plugins usually are installed externally to Firefox. However, you can disable them in Firefox so that Firefox does not use them.
SearchReset is supposed to automate the task of resetting certain preferences, but you still can edit them manually if necessary.
'''''Address Bar Search'''''
(1) In a new tab, type or paste '''about:config''' in the address bar and press Enter. Click the button promising to be careful.
(2) In the filter box, type or paste '''keyword''' and pause while the list is filtered
(3) Right-click '''keyword.URL''' and choose Reset. This should restore Google as the default for address bar search.
Does that work?
'''''Search Box'''''
Usually it works to choose your preferred search engine from the drop-down. To remove an unwanted search engine plugin, usually the Manage Search Engines... choice at the bottom of the drop-down takes care of it.
Do either of those work?
There might be another way to hijack that search box; I think some of the other frequent responders probably are more familiar with it than I am. -
Hi, I'm new at this but I am hoping someone can help me.I have recently been away for 5 weeks and my Tom Tom required updating.When I clicked to update it, it required a pc. As I didn't have access to a pc it wouldn't work is there any way to do this without a pc? I was without this app for 3 weeks! Thanks, Lea
The process to update your Tom Tom is a big data file, you will need to be connected to a Wi-Fi network for it to download. If will take about an hour.
-
I am trying to import photo's on i photo. It downloads all of the pictures on my camera, how do i only select the photos i want? Is there a way to do this without selecting one photo at a time? is there a way to select multiple images? thanks!
To select consecutive images click and drag the cursor over multiple thumbnails to select all at once.
To select multiple images that are randomly located hold down the Command(⌘) key and click on those images you want to select.
Or to select consecutive images from a list of images that are together hold down the Shift key and and click on the first photo you want to select and the on the last photo you want in the list.
OT -
Is it possible to copy a DVD into iTunes and then upload it to my iPad? Is there any way of doing this?
Sure, just use Handbrake to encode the DVD movie into a format that is playable on iTunes and on your iPad:
http://handbrake.fr/downloads.php
Once the encoding is complete, move the movie file from your desktop into iTunes and then sync your iPad. Presto, the movie is on your iPad! -
I have 1,400 items in my in-box and would like to delete them en masse. Is there any way to do this without deleting them individually?
Select the Inbox folder to see emails.
click on first email to get focus.
Hold down 'Ctrl' key and press 'A' key
This will highlight /select all emails.
they will appear as conversations in the Message Pane
Clickon Delete.
when it has finished - you do have a lot of emails :)
Right click on Inbox and select 'compact' - this removes all marked as deleted emails. -
I just upgraded to an iPhone 5S and it is going haywire whenever I use it. It will randomly open applications, send emails suddenly before I am finished writing them, and much more. Is there a way to resolve this without returning the phone?
Hi, jbgatch.
Thank you for visiting Apple Support Communities.
Our iOS devices use a capacitive touch screen and with it being winter in most places, a buildup of static electricity can cause the touch screen to act erratic. Start with closing all applications open in multitasking and power cycling the device. If using a screen protector, remove it and test without it installed. Some cases that include a screen protector can cause this issue as well. Try the remainder of the steps in the attached article below. If the issue persists, a restore as new may been needed. Make sure to backup your data prior to a restore.
iOS: Force an app to close
http://support.apple.com/kb/ht5137
iPhone, iPad, iPod touch: Troubleshooting touchscreen response
http://support.apple.com/kb/ts1827
Cheers,
Jason H. -
Just switched from safari on my imac. When using search menu in safari I had the option to "find on this page," which was an incredible help while doing research and looking for specific phrases/words. Is there any way to have this feature using firefox?
I think Safari has the same keyboard shortcut as Firefox "command+F" on a Mac or "Ctrl+F" on Windows.
Look in the lower left corner for the Find. There are more likely to be differences in Find Next and Find Previous in the keyboard shortcuts, but continuing at the Find bar at the bottom doesn't matter what browser you use. There is an "X" there to dismiss the Find bar. In Windows the "Esc" key will dismiss the bar if you are within the find text entry area.
Keyboard shortcuts:
* [https://support.mozilla.com/en-US/kb/Keyboard%20shortcuts?s=keyboard&r=0&as=s Keyboard shortcuts | How to | Firefox Help], from Mozilla very limited number of shortcuts but will show correctly for your system
* [http://dmcritchie.mvps.org/firefox/keyboard.htm Firefox and other Browser Keyboard Shortcuts (Comparison Table)], more comprehensive but is oriented to Windows users with some guidelines for Mac and Linux users.
<br><small>Please mark "Solved" one answer that will best help others with a similar problem -- hope this was it.</small> -
I changed my passcode, and then forgot it. Is there any way to fix this without restoring it?
Your options are to remember the passcode or restore it
On the plus side if you used iCloud or synced with iTunes theres a good chance you will get most of your data back after restoring -
Is there a way to import tracks without using the mouse in Logic Pro?
From the user manual:
You can import existing audio recordings by simply dragging them from the Media area, shown at the right of the Arrange window.
My question is: is there a way to do this without dragging it with a mouse? I'd like to use a shortcut to open a browse folder and select a file. The reason for this is that I am nearly blind and I can't use my mouse for dragging because I can't see it.
Thanks in advance.Can't see the mouse pointer.. even if you increase it's size using the Accessibilites features in OS X's System preferences...?
http://www.wikihow.com/Change-a-Mouse-Pointer-Size-in-Mac-Os-X
Maybe you are looking for
-
IPod no longer appears in Computer
I use my ipod touch as a portable external hard drive, but after i downloaded the 3.1.3 update, it no longer appears in Computer. Anyone know what is going on??
-
Can wireless backup be on different network to internet connection?
Can you backup to a wireless backup (say a Time Capsule) but connect to a different wireless access point for the internet?
-
Installing 1.5 and 1.6 at the same time
I am an Oracle instructor and I need to teach the current version which is still on 1.5 but also I want to install 1.6 to review the new functionality. Can I do this in the same database? i.e. on my laptop. What issues do I need to be aware of? regar
-
Adobe Premiere Elements/AVCHD?
Can anyone confirm if Adobe Premiere Elements 12 will import AVCHD at 50p? I have a Canon Legria HF R46 which I can't import into imovies from so wondered if Adobe Premiere Elements 12 would be the way to go? any help very much appreciated, thanks. A
-
Curve 9300, no data plan, gmail on wifi only
Hello, I plan to buy a BB Curve 9300 but before I want to be 100% sure that I can configure it to be auto warned if I get a mail on my gmail account but only via wifi because I have no data plan. Thank you for your help; Regards :-)