Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » How to use DnDTabPane example
How to use DnDTabPane example [message #1403698] Fri, 25 July 2014 12:34 Go to next message
Peter Penzov is currently offline Peter PenzovFriend
Messages: 6
Registered: July 2011
Junior Member
Hi, I would like to use this code to make TabPane draggable. I would like to change the position of the tabs.

I found this code:

http://git.eclipse.org/c/efxclipse/org.eclipse.efxclipse.git/tree/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/internal

Can you give me some example how to use this code and which files do I need?

Also I'm using JVM 8u11. I suppose that this version is supported.

BR,
Peter
Re: How to use DnDTabPane example [message #1404065 is a reply to message #1403698] Tue, 29 July 2014 12:15 Go to previous messageGo to next message
Peter Penzov is currently offline Peter PenzovFriend
Messages: 6
Registered: July 2011
Junior Member
I tested to create this very simple of Reorder and Drag and Drop with JavaFX TabPane


This is the code that I want to run:

package example._draganddroptabpane;

import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.scene.Scene;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
import org.eclipse.fx.ui.controls.tabpane.DndTabPaneFactory;
import org.eclipse.fx.ui.controls.tabpane.DndTabPaneFactory.FeedbackType;

public class MainApp extends Application
{

@Override
public void start(Stage stage) throws Exception
{

HBox h = new HBox();

TabPane tb = new TabPane();

Tab tab1 = new Tab("First");
Rectangle r1 = new Rectangle(100, 100);
r1.setFill(Color.GREEN);
tab1.setContent(new BorderPane(r1));
tb.getTabs().add(tab1);

Tab tab2 = new Tab("Second");
Rectangle r2 = new Rectangle(100, 100);
r2.setFill(Color.RED);
tab2.setContent(new BorderPane(r2));
tb.getTabs().add(tab2);

Tab tab3 = new Tab("Thurd");
Rectangle r3 = new Rectangle(100, 100);
r3.setFill(Color.BLACK);
tab3.setContent(new BorderPane(r3));
tb.getTabs().add(tab3);

Pane pane = DndTabPaneFactory.createDefaultDnDPane(FeedbackType.OUTLINE, tb);

HBox.setHgrow(pane, Priority.ALWAYS);
h.getChildren().add(pane);


Scene scene = new Scene(h);

stage.setTitle("JavaFX and Maven");
stage.setScene(scene);
stage.show();
}

public static void main(String[] args)
{
launch(args);
}

}


I would like to use the code much more simple but I get error at this line:

Pane pane = DndTabPaneFactory.createDefaultDnDPane(FeedbackType.OUTLINE, tb);

incompatible types: TabPane cannot be converted to Consumer<TabPane>

What should be the second argument?
Re: How to use DnDTabPane example [message #1404068 is a reply to message #1404065] Tue, 29 July 2014 12:20 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
The factory only accepts a Consumer<TabPane> you are not supposed to
setup the TabPane yourself.

The reason for this is that in future TabPane will have internal API
we'll make use of to implement TabPane and switch the implementation
depending on the java version we detect.

If you want SB support this is something we won't provide for now.

Tom

On 29.07.14 14:15, Peter Penzov wrote:
> I tested to create this very simple of Reorder and Drag and Drop with
> JavaFX TabPane
>
>
> This is the code that I want to run:
>
> package example._draganddroptabpane;
>
> import javafx.application.Application;
> import static javafx.application.Application.launch;
> import javafx.scene.Scene;
> import javafx.scene.control.Tab;
> import javafx.scene.control.TabPane;
> import javafx.scene.layout.BorderPane;
> import javafx.scene.layout.HBox;
> import javafx.scene.layout.Pane;
> import javafx.scene.layout.Priority;
> import javafx.scene.paint.Color;
> import javafx.scene.shape.Rectangle;
> import javafx.stage.Stage;
> import org.eclipse.fx.ui.controls.tabpane.DndTabPaneFactory;
> import org.eclipse.fx.ui.controls.tabpane.DndTabPaneFactory.FeedbackType;
>
> public class MainApp extends Application
> {
>
> @Override
> public void start(Stage stage) throws Exception
> {
>
> HBox h = new HBox();
>
> TabPane tb = new TabPane();
>
> Tab tab1 = new Tab("First");
> Rectangle r1 = new Rectangle(100, 100);
> r1.setFill(Color.GREEN);
> tab1.setContent(new BorderPane(r1));
> tb.getTabs().add(tab1);
>
> Tab tab2 = new Tab("Second");
> Rectangle r2 = new Rectangle(100, 100);
> r2.setFill(Color.RED);
> tab2.setContent(new BorderPane(r2));
> tb.getTabs().add(tab2);
>
> Tab tab3 = new Tab("Thurd");
> Rectangle r3 = new Rectangle(100, 100);
> r3.setFill(Color.BLACK);
> tab3.setContent(new BorderPane(r3));
> tb.getTabs().add(tab3);
>
> Pane pane =
> DndTabPaneFactory.createDefaultDnDPane(FeedbackType.OUTLINE, tb);
>
> HBox.setHgrow(pane, Priority.ALWAYS);
> h.getChildren().add(pane);
>
>
> Scene scene = new Scene(h);
>
> stage.setTitle("JavaFX and Maven");
> stage.setScene(scene);
> stage.show();
> }
>
> public static void main(String[] args)
> {
> launch(args);
> }
>
> }
>
>
> I would like to use the code much more simple but I get error at this line:
>
> Pane pane = DndTabPaneFactory.createDefaultDnDPane(FeedbackType.OUTLINE,
> tb);
>
> incompatible types: TabPane cannot be converted to Consumer<TabPane>
>
> What should be the second argument?
Re: How to use DnDTabPane example [message #1404071 is a reply to message #1404068] Tue, 29 July 2014 12:33 Go to previous messageGo to next message
Peter Penzov is currently offline Peter PenzovFriend
Messages: 6
Registered: July 2011
Junior Member
Can you show me some much more simple way to use this code?

Box h = new HBox();

{
Pane pane = DndTabPaneFactory.createDefaultDnDPane(
FeedbackType.MARKER, this::setupTb1);
HBox.setHgrow(pane, Priority.ALWAYS);
h.getChildren().add(pane);
}

{
Pane pane = DndTabPaneFactory.createDefaultDnDPane(
FeedbackType.MARKER, this::setupTb2);
HBox.setHgrow(pane, Priority.ALWAYS);
h.getChildren().add(pane);
}

private void setupTb1(TabPane tb) {
{
Tab tab = new Tab("T 1.1");
Rectangle r = new Rectangle(100, 100);
r.setFill(Color.GREEN);
tab.setContent(new BorderPane(r));
tb.getTabs().add(tab);
}

{
Tab tab = new Tab("Tab 1.2");
Rectangle r = new Rectangle(100, 100);
r.setFill(Color.RED);
tab.setContent(new BorderPane(r));
tb.getTabs().add(tab);
}
}
Re: How to use DnDTabPane example [message #1404076 is a reply to message #1404071] Tue, 29 July 2014 12:59 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
There is not simpler code than this, sorry.

Tom

On 29.07.14 14:33, Peter Penzov wrote:
> Can you show me some much more simple way to use this code?
>
> Box h = new HBox();
> {
> Pane pane = DndTabPaneFactory.createDefaultDnDPane(
> FeedbackType.MARKER, this::setupTb1);
> HBox.setHgrow(pane, Priority.ALWAYS);
> h.getChildren().add(pane);
> }
> {
> Pane pane = DndTabPaneFactory.createDefaultDnDPane(
> FeedbackType.MARKER, this::setupTb2);
> HBox.setHgrow(pane, Priority.ALWAYS);
> h.getChildren().add(pane);
> }
>
> private void setupTb1(TabPane tb) {
> {
> Tab tab = new Tab("T 1.1");
> Rectangle r = new Rectangle(100, 100);
> r.setFill(Color.GREEN);
> tab.setContent(new BorderPane(r));
> tb.getTabs().add(tab);
> }
> {
> Tab tab = new Tab("Tab 1.2");
> Rectangle r = new Rectangle(100, 100);
> r.setFill(Color.RED);
> tab.setContent(new BorderPane(r));
> tb.getTabs().add(tab);
> }
> }
Previous Topic:RCP Exported App does not compile JavaFX
Next Topic:Using Jemmy for e4 javafx application
Goto Forum:
  


Current Time: Fri Apr 19 16:12:07 GMT 2024

Powered by FUDForum. Page generated in 0.02949 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top