SWT DirectoryDialog not showing Android Smartphone - java

I've written an application to administer my audio files using Java/SWT. Now I want to copy files from the PC to my mobile Phone, which is a Samsung Galaxy A30, Android 10 device. When I hook up the phone to the PC (Win 10) it is listed in Explorer under "This PC" as "Galaxy A30s" and I can scroll through folders and files just fine. However when I open the SWT DirectoryDialog the phone is not listed there.
Has anybody a tip why this is and how to solve it?
Many thanks.
Here is the calling code snippet:
AudioFilesCopy afc = new AudioFilesCopy(shell);
if (afc.selectDirectory() != null) {
Cursor waitCursor = shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT);
shell.setCursor(waitCursor);
afc.copyFiles(plSongs);
shell.setCursor(null);
}
This is the class:
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Shell;
public class AudioFilesCopy {
private Shell shell;
private Logger logger;
private String selDirectory;
public AudioFilesCopy(Shell parent) {
logger = java.util.logging.Logger.getLogger(this.getClass().getName());
logger.addHandler(MusicCatalog.fileHandler);
shell = new Shell(parent, SWT.BORDER | SWT.RESIZE | SWT.Close | SWT.MAX | SWT.MIN | SWT.PRIMARY_MODAL);
shell.setLayout(new FillLayout());
}
public String selectDirectory() {
DirectoryDialog dialog = new DirectoryDialog(shell);
dialog.setFilterPath(System.getProperty("user.home") + "\\TransferOrdner");
selDirectory = dialog.open();
return selDirectory;
}
public void copyFiles(String[] plSongs) {
for (int i = 0; i < plSongs.length; i++) {
Path source = Paths.get(plSongs[i]);
Path target = Paths.get(selDirectory, source.getFileName().toString());
// System.out.println("Copy " + source + " to " + target);
try {
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES);
} catch (IOException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
}
}
}
}

Use FileDialog instead of DirectoryDialog.

Related

Error when running jar: JavaFX runtime components are missing, and are required to run this application [VS Code] [Java]

My JavaFX project runs in the editor fine but when I try to build to .jar it wont run. I am using java 17 so I need to manually import it and I have imported the libraries properly in settings.json and have added the vmArgs in launch.json. When I run- java gui.java (gui.java is my class name) I get errors saying stuff like: error: package javafx.application does not exist , error: package javafx.geometry does not exist , error: package javafx.scene does not exist. I know that I should use a different version of java or use something other that vs code but I don't know how to convert a project to an earlier version of java and I want to use vs code. Does anyone know how I can get a .jar or any executable working for it. I am even fine with something like a bash script that compiles it manually I just need to run it outside the editor. Here is my gui code I know that allot of it is bad.
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Scanner;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class gui extends Application {
ArrayList<CheckBox> checkBoxes = new ArrayList<CheckBox>();
static String currentDir = System.getProperty("user.dir");
static File checkListFile = new File(currentDir + "\\list.TXT");
public static void main(String[] args) {
launch(args);
}
#Override
public void start(Stage primaryStage) throws Exception {
BorderPane root = new BorderPane();
Scene scene = new Scene(root, 450, 250);
VBox vbCenter = new VBox();
TextField input = new TextField();
input.setOnKeyPressed( event -> {
if( event.getCode() == KeyCode.ENTER ) {
addCheckBox(input.getText(), vbCenter);
input.setText("");
saveCheckBoxes();
}
});
vbCenter.getChildren().add(input);
HBox hbButtons = new HBox();
Button reset = new Button("Reset");
reset.setOnAction( event -> {
removeCheckBoxes(vbCenter);
});
hbButtons.getChildren().add(reset);
hbButtons.setAlignment(Pos.CENTER_LEFT);
loadCheckBoxes(vbCenter);
root.setPadding(new Insets(20));
root.setCenter(vbCenter);
root.setBottom(hbButtons);
primaryStage.setTitle("Checklist");
primaryStage.setScene(scene);
primaryStage.show();
}
public void addCheckBox(String name, VBox vbCenter) {
CheckBox checkBox = new CheckBox(name);
checkBoxes.add(checkBox);
vbCenter.getChildren().add(checkBox);
}
public void removeCheckBoxes(VBox vbCenter) {
for (CheckBox checkBox : checkBoxes) {
vbCenter.getChildren().remove(checkBox);
}
checkBoxes = new ArrayList<CheckBox>();
try {
clearTheFile(checkListFile);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void clearTheFile(File file) throws IOException {
FileWriter fwOb = new FileWriter(file);
PrintWriter pwOb = new PrintWriter(fwOb, false);
pwOb.flush();
pwOb.close();
fwOb.close();
}
public void saveCheckBoxes() {
String[] name = new String[checkBoxes.size()];
for (int i = 0; i < checkBoxes.size(); i++) {
name[i] = checkBoxes.get(i).getText();
}
writeData(name, checkListFile);
}
public void loadCheckBoxes(VBox vb) {
String[] data = readData(checkListFile);
for (String s : data) {
CheckBox checkBox = new CheckBox(s);
checkBoxes.add(checkBox);
vb.getChildren().add(checkBox);
}
}
public String[] readData(File file) {
String[] result = new String[0];
try {
result = new String[(int)Files.lines(file.toPath()).count()];
Scanner scanner = new Scanner(file);
int index = 0;
while (scanner.hasNextLine()) {
result[index] = scanner.nextLine();
index++;
}
scanner.close();
}
catch (Exception e) {
e.printStackTrace();
}
return result;
}
public void writeData(String data, File file) {
try {
FileWriter writer = new FileWriter(file);
writer.write(data);
writer.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
public void writeData(String[] dataArr, File file) {
String data = "";
for (int i = 0; i < dataArr.length; i++) {
data += (dataArr[i] + "\n");
}
writeData(data, file);
}
}
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Launch Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "Launch gui",
"request": "launch",
"vmArgs": "--module-path C:/Users/Billy1301/Downloads/openjfx-17.0.1_windows-x64_bin-sdk/javafx-sdk-17.0.1/lib --add-modules javafx.controls,javafx.fxml",
"mainClass": "gui",
"projectName": "Productivity_5753000c"
}
]
}
settings.json
{
"java.project.referencedLibraries": [
"lib/**/*.jar",
"c:\\Users\\Billy1301\\Downloads\\openjfx-17.0.1_windows-x64_bin-sdk\\javafx-sdk-17.0.1\\lib\\javafx.base.jar",
"c:\\Users\\Billy1301\\Downloads\\openjfx-17.0.1_windows-x64_bin-sdk\\javafx-sdk-17.0.1\\lib\\javafx.controls.jar",
"c:\\Users\\Billy1301\\Downloads\\openjfx-17.0.1_windows-x64_bin-sdk\\javafx-sdk-17.0.1\\lib\\javafx.fxml.jar",
"c:\\Users\\Billy1301\\Downloads\\openjfx-17.0.1_windows-x64_bin-sdk\\javafx-sdk-17.0.1\\lib\\javafx.graphics.jar",
"c:\\Users\\Billy1301\\Downloads\\openjfx-17.0.1_windows-x64_bin-sdk\\javafx-sdk-17.0.1\\lib\\javafx.media.jar",
"c:\\Users\\Billy1301\\Downloads\\openjfx-17.0.1_windows-x64_bin-sdk\\javafx-sdk-17.0.1\\lib\\javafx.swing.jar",
"c:\\Users\\Billy1301\\Downloads\\openjfx-17.0.1_windows-x64_bin-sdk\\javafx-sdk-17.0.1\\lib\\javafx.web.jar",
"c:\\Users\\Billy1301\\Downloads\\openjfx-17.0.1_windows-x64_bin-sdk\\javafx-sdk-17.0.1\\lib\\javafx-swt.jar"
]
}

JavaSWT app working in Eclipse but not in Terminal

import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class clientWindow {
static Text chatWindow;
public static void sendMessage(Socket socket, String message) throws IOException {
PrintWriter pr = new PrintWriter(socket.getOutputStream());
pr.println("Client: " + message);
pr.flush();
}
public static void main(String[] args) throws UnknownHostException, IOException {
Socket s = new Socket("10.0.1.8", 4500);
Display display = new Display();
Shell clientWindow = new Shell(display);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
clientWindow.setLayout(layout);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
GridData data1 = new GridData(GridData.FILL_BOTH);
chatWindow = new Text(clientWindow, SWT.MULTI | SWT.V_SCROLL | SWT.READ_ONLY);
chatWindow.setLayoutData(data1);
Text messageBox = new Text(clientWindow, SWT.SINGLE);
messageBox.setLayoutData(data);
Button send = new Button(clientWindow, 0);
send.setText("Send");
send.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent event) {
try {
sendMessage(s, messageBox.getText());
messageBox.setText("");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
#Override
public void widgetDefaultSelected(SelectionEvent arg0) {
// TODO Auto-generated method stub
}
});
clientWindow.open();
while (!clientWindow.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
}
This is a small messaging app that I've finished. Everything in here works fine in Eclipse. When I try to run it in the Terminal, however, I get this.
Exception in thread "main" org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:4711)
at org.eclipse.swt.SWT.error(SWT.java:4626)
at org.eclipse.swt.SWT.error(SWT.java:4597)
at org.eclipse.swt.widgets.Display.error(Display.java:1112)
at org.eclipse.swt.widgets.Display.createDisplay(Display.java:853)
at org.eclipse.swt.widgets.Display.create(Display.java:837)
at org.eclipse.swt.graphics.Device.<init>(Device.java:132)
at org.eclipse.swt.widgets.Display.<init>(Display.java:736)
at org.eclipse.swt.widgets.Display.<init>(Display.java:727)
at clientWindow.main(clientWindow.java:28)
I'm pretty sure this error happens when a trying to access the Display from something that isn't in "main", which isn't what I'm trying to do. So why is it giving me this error?
Judging by the line numbers in the Display code you are running this on macOS.
On macOS you must specify the -XstartOnFirstThread option when you run your code with the java command in Terminal.
The program works in Eclipse because Eclipse sets this up for you automatically in the Run Configuration.

Setting the tab spacing/size visualization for a JavaFX TextArea

I am using JavaFX 8 and specifically the TextArea control. In that control I can enter free form text including "tab" characters. When I enter a tab, the data is spaced in units of 8 characters. For example. In the following, the ! character is where I enter a tab:
1234567890123456789012345678901234567890
! Data here
ABC! Data here
!! Data Here
My puzzle is how to change the tab spacing/sizing for the visual so that instead of the tab size being 8 characters it will only be 4 characters.
To further illustrate, here is an actual screen shot showing tabs in my text area:
I want to leave the data as containing tab characters and not replace tabs with spaces.
This Stack Exchange question does not apply as it talks exclusively about changing tabs to space:
JavaFX TextArea: how to set tabulation width
I decided to grunge through the source code of JavaFX to see if I could find an answer and, although I am not an expert in examining such a large amount of code, I seem to have found that the answer is that the tab size is hard-coded to be 8 characters!!
I found the source file called:
com.sun.javafx.text.PrismTextLayout.java
which has a method called getTabAdvance which returns a fixed value of "8". See the following:
This is most disappointing to me but it is what it is.
After the implementation of JDK-8130738 in JavaFX 14, you can now change the advance of a tab character to any multiple of 'spaceAdvance'. Text and TextFlow now have a tabSize property and the CSS supports -fx-tab-size
Since TextAreaSkin implements the TextArea using Text nodes, you can change the tab size of the TextArea with CSS.
Example:
package example.stackoverflow;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import javafx.scene.control.TextArea;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.stage.Stage;
public class TextAreaTabs extends Application {
private Scene scene;
private File cssFile;
public static void main(String[] args) {
launch(args);
}
#Override
public void start(Stage primaryStage) throws Exception {
var slider = new Slider(1, 50, 8);
slider.valueProperty().addListener((obs, old, newValue) -> {
try {
updateTabSize(newValue.intValue());
} catch (IOException ex) {
System.err.println("Can't write CSS file.");
}
});
var ta = new TextArea("This is a test\n\tafter a tab\n\t1\t2\n");
ta.setFont(Font.font("Monospaced"));
var vbox = new VBox(8,new HBox(8,new Label("Tab size:"),slider),ta);
vbox.setPadding(new Insets(8));
scene = new Scene(vbox);
primaryStage.setScene(scene);
primaryStage.setTitle("TextArea Tab Experiment");
primaryStage.show();
}
private void updateTabSize(int spaces) throws IOException {
File oldFile = cssFile;
cssFile = File.createTempFile("textareatabs", ".css");
cssFile.deleteOnExit();
Files.writeString(cssFile.toPath(), """
Text {
-fx-tab-size: %d;
}
""".formatted(spaces), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
String confStyleSheet = cssFile.toURI().toString();
scene.getStylesheets().setAll(confStyleSheet);
if (oldFile != null) {
oldFile.delete();
}
}
}
Here's a version of Scotts Proggy adapted to use the new JavaFX 17 Data-URI's:
P.S. I use the Azul Zulu openJDK 17 JavaFX Runtime Bundle
You can get that here:
https://www.azul.com/downloads/?package=jdk#download-openjdk
package example.stackoverflow;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.util.Base64;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.scene.text.Font;
import javafx.stage.Stage;
public class TextAreaTabs extends Application {
private static final String CSS_TABSIZE_N = "Text {-fx-tab-size: %d}";
private static final char TAB = '\t';
private static final char NEWLINE = '\n';
private static final String TABBED_TEXT = "This is a test" + NEWLINE + TAB + "after a tab" + NEWLINE + TAB + "1" + TAB + "2";
public static void main(final String[] args) {
launch(args);
}
private Scene scene;
#Override
public void start(final Stage primaryStage) {
final var sliderLabel = new Label("Tab size:");
final var slider = new Slider(1, 50, 8);
; slider.valueProperty().addListener((obs, old, newValue) -> updateTabSize(newValue.intValue()));
final var textArea = new TextArea(TABBED_TEXT);
; textArea.setFont(Font.font("Monospaced"));
final var vBox = new VBox(8, new HBox(8, sliderLabel, slider), textArea);
; vBox.setPadding(new Insets(8));
scene = new Scene(vBox);
primaryStage.setScene(scene);
primaryStage.setTitle("TextArea Tab Experiment");
primaryStage.show();
}
private void updateTabSize(final int tabSize) {
final var styleText = CSS_TABSIZE_N.formatted(tabSize);
final var styleBase64 = Base64.getUrlEncoder().encodeToString(styleText.getBytes(UTF_8));
final var url = "data:text/css;charset=UTF-8;base64," + styleBase64;
System.out.println(styleText + TAB + " -> " + url);
scene.getStylesheets().setAll(url);
}
}

Get input field of a dialog in eclipse

For my plugin, I try to get the active Eclipse dialog with these lines:
String shellTitle = Display.getCurrent().getActiveShell().getTitle();
System.out.println("Opened dialog: " + shellTitle);
If e.g. I open the search dialog, these lines print me
Opened dialog: Search
in my console. But I would also want to print the keyword in the search field, for example
Opened dialog: Search (with the search word 'ChatSession')
I have read the API reference and there, I just can found the getTitle() and some other methods for getting bounds and so on.
Is my idea realizable? And if not, is it realizable with these so-called extension points? I have never used them but heard of them.
Mistakes in your question:
You are calling getTitle() method on Shell array object. It is wrong.
You are mixing dialog and Shell
Assuming you are talking about Shell. You can use the below code to get the controls on active Shell.
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class ShellControlsGetting {
public static void main(String[] args) {
Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Button button = new Button(shell, SWT.PUSH);
button.setText("Open 3 Shells");
final Shell[] shells = new Shell[3];
button.addSelectionListener(new SelectionListener() {
#Override
public void widgetSelected(SelectionEvent e) {
for (int i = 0; i < 3; i++) {
shells[i] = new Shell(shell);
shells[i].setText("Shell" + (i + 1));
shells[i].setLayout(new FillLayout());
shells[i].setSize(250, 50);
shells[i].setLocation(100, 200 + (i + 1) * 100);
Label label = new Label(shells[i], SWT.LEFT);
label.setText("Search Box" + (i + 1));
Text search = new Text(shells[i], SWT.SINGLE | SWT.BORDER);
search.setText("search key" + (i + 1));
shells[i].open();
}
Shell currentActiveShell = Display.getCurrent().getActiveShell();
String shellTitle = currentActiveShell.getText();
Control[] children = currentActiveShell.getChildren();
for (int i = 0; i < children.length; i++) {
Control child = children[i];
if (child instanceof Text) {
System.out.println("Opened dialog: " + shellTitle + "(with the search word '" + ((Text)child).getText()
+ "')");
}
}
}
#Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
If this not answers you question then edit your post add some code and clarify what exactly you are expecting.

How to customize the renders in prefuse. Problem in customize images in prefuse layout

HI all,
I have written a java application to show the images in different layouts. I am able to show it different layout correctly but some times the images are overlapped. In my application having more than 20/30 nodes and couple of nodes having 6 to 10 edges. The images size are 50*50. Because of the 10 edges, the nodes will overlapped i.e images will overlapped on another images. How can I solve the problem?
Any help will be highly appreciated.
My code is given below
import javax.swing.JFrame;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.util.;
import java.io.;
import java.awt.Font;
import prefuse.Constants;
import prefuse.Display;
import prefuse.Visualization;
import prefuse.action.ActionList;
import prefuse.action.RepaintAction;
import prefuse.action.assignment.ColorAction;
import prefuse.action.assignment.FontAction;
import prefuse.action.assignment.DataColorAction;
import prefuse.action.layout.graph.ForceDirectedLayout;
import prefuse.action.layout.graph.;
import prefuse.action.layout.;
import prefuse.activity.Activity;
import prefuse.controls.DragControl;
import prefuse.controls.PanControl;
import prefuse.controls.ZoomControl;
import prefuse.data.Graph;
import prefuse.data.io.DataIOException;
import prefuse.data.io.GraphMLReader;
import prefuse.render.DefaultRendererFactory;
import prefuse.render.LabelRenderer;
import prefuse.util.ColorLib;
import prefuse.visual.VisualItem;
import prefuse.visual.*;
import prefuse.util.FontLib;
import prefuse.action.assignment.DataSizeAction;
import prefuse.data.*;
import prefuse.render.ImageFactory;
public class LayoutExample {
public static void main(String[] argv) throws Exception {
Graph graph = null;
try {
graph = new GraphMLReader().readGraph("/graphs.xml");
} catch ( DataIOException e ) {
e.printStackTrace();
System.err.println("Error loading graph. Exiting...");
System.exit(1);
}
ImageFactory imageFactory = new ImageFactory(100,100);
try
{
//load images and construct imageFactory.
String images[] = new String[3];
images[0] = "data/images/switch.png";
images[1] = "data/images/ip_network.png";
images[2] = "data/images/router.png";
String[] names = new String[] {"Switch","Network","Router"};
BufferedImage img = null;
for(int i=0; i < images.length ; i++)
{
try {
img = ImageIO.read(new File(images[i]));
imageFactory.addImage(names[i],img);
}
catch (IOException e){
}
}
}
catch(Exception exp)
{
}
Visualization vis = new Visualization();
vis.add("graph", graph);
LabelRenderer nodeRenderer = new LabelRenderer("name", "type");
nodeRenderer.setVerticalAlignment(Constants.BOTTOM);
nodeRenderer.setHorizontalPadding(0);
nodeRenderer.setVerticalPadding(0);
nodeRenderer.setImagePosition(Constants.TOP);
nodeRenderer.setMaxImageDimensions(100,100);
DefaultRendererFactory drf = new DefaultRendererFactory();
drf.setDefaultRenderer(nodeRenderer);
vis.setRendererFactory(drf);
ColorAction nText = new ColorAction("graph.nodes", VisualItem.TEXTCOLOR);
nText.setDefaultColor(ColorLib.gray(100));
ColorAction nEdges = new ColorAction("graph.edges", VisualItem.STROKECOLOR);
nEdges.setDefaultColor(ColorLib.gray(100));
// bundle the color actions
ActionList draw = new ActionList();
//MAD - changing the size of the nodes dependent on the weight of the people
final DataSizeAction dsa = new DataSizeAction("graph.nodes","size");
draw.add(dsa);
draw.add(nText);
draw.add(new FontAction("graph.nodes", FontLib.getFont("Tahoma",Font.BOLD, 12)));
draw.add(nEdges);
vis.putAction("draw", draw);
ActionList layout = new ActionList(Activity.DEFAULT_STEP_TIME);
BalloonTreeLayout balloonlayout = new BalloonTreeLayout("graph",50);
layout.add(balloonlayout);
Display d = new Display(vis);
vis.putAction("layout", layout);
// start up the animated layout
vis.run("draw");
vis.run("layout");
d.addControlListener(new DragControl());
// pan with left-click drag on background
d.addControlListener(new PanControl());
// zoom with right-click drag
d.addControlListener(new ZoomControl());
// -- 6. launch the visualization -------------------------------------
// create a new window to hold the visualization
JFrame frame = new JFrame("prefuse example");
// ensure application exits when window is closed
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(d);
frame.pack(); // layout components in window
frame.setVisible(true); // show the window
}
}
Thanks
R.Ravikumar

Categories