Java: java.io.File extenden

Seite 1 von 1 - Forum: Coding Stuff auf overclockers.at

URL: https://www.overclockers.at/coding-stuff/java_java_io_file_extenden_97223/page_1 - zur Vollversion wechseln!


t3mp schrieb am 30.10.2003 um 19:11

1)vielleicht bin ich ja zu blöd dazu, jedenfalls bekomm ich's nicht hin. :rolleyes:

Code:
import java.io.File;
public class MyFile extends File {
    public MyFile(String pathname) {
        new File(pathname);
    }
}

was ist daran falsch? als compiler-error kommt folgendes:

Code:
MyFile.java [3:1] cannot resolve symbol
  symbol  : constructor File ()
  location: class java.io.File
      public MyFile(String pathname) {
                                     ^  


2)dann wäre ich noch dankbar, wenn jemand wüsste wie ich innerhalb eines JTree einen Doppelklick auffangen kann.

tia :)


Ringding schrieb am 30.10.2003 um 19:39

Mit new machst das sicher nicht. Wenn ich mich recht erinnere, müsste das mit super.File(pathname) gehen.

EDIT: Bledsinn. Nur super(pathname) natürlich.


t3mp schrieb am 30.10.2003 um 20:02

hast recht. thx! ;)


gue schrieb am 31.10.2003 um 15:20

Zitat von dark_templahr
2)dann wäre ich noch dankbar, wenn jemand wüsste wie ich innerhalb eines JTree einen Doppelklick auffangen kann.
Nur mal so ansatzweise:

Code:
JTree tree = new JTree(...);
// ... initialisierung

tree.addMouseListener(new MouseAdapter() {
  public void mouseClicked(MouseEvent e) {
    if (e.getClickCount() > 1) {
      // doppelklick
    }
  }
});
Ich weiß jetzt nicht, ob es noch eine bessere Möglichkeit gibt, Doppelklicks abzufangen, aber ich glaube, so müsst's klappen.


t3mp schrieb am 02.11.2003 um 21:01

ja, die lösung hat bei mir auch schon funktioniert. ein wenig hatschert eben...

aber als benutzer merkt man davon nix. ;)




overclockers.at v4.thecommunity
© all rights reserved by overclockers.at 2000-2026