简体   繁体   中英

What am I doing wrong with passing Rectangle to setContent in javafx 2?

I'm using javafx 2.2 with JDK 7 in Netbeans 7, with a code

Rectangle r = new Rectangle(200, 200);
tab_1.setContent(r);

which gives me error: rectangle cannot be converted to node. The tab_1 is a Tab instance.

According to the 2 docs , Rectangle is a subclass of Node .

Searching for similar problems only gave me the following SO question which I believe is unrelated: JavaFX error: incompatible types - Object cannot be converted to Node

In my understanding Rectangle is a Node , thus usable with setContent . What am I doing wrong?

import javafx.scene.shape.Rectangle;

除了错误的导入外,几乎不可能引起此问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM