BorderLayout in javafx
Hey,
I need smth like BorderLayout from swing in javafx, but much simpler (only North and Center).
I used Vbox layout on scene with binding width and height values with scene size for autosizing all content inside scene.
First, in VBox I put ToolBar Control. This control fill space horizontally and it is good (like NORTH behaviiour)
But I want all other space was filling by other control eg Button.
I experimented with layoutInfo for Button, attributes: hfill=true, vfill=true, but control filled space only horizontally, not vertically.
How can i do this?
Ps.
Step 2 If I do this I want replace Button with Rectangle. Rectangle is not resizable so it's other story (jfxtras has ResizableRectangle)
Step 3 Then I want put this rectangle into Group as background (with linear gradient)
Step 4 Then I want put in Group, HBox and then put inside TreeView and other container.
In swing world it will be:
* Panel (BorderLayout):
******** NORTH: Toolbar
******** CENTER: Panel (BorderLayout) with background
****************** WEST: TreeView
****************** CENTER: Panel (...)
How can I get result as above in JavaFX?
Every clues will be important for me.
Ps. Many chaotic steps because i was trying experiment with javafx to understand how it works.
Thanks for advices.
Edited by: rafik7777 on May 12, 2010 11:04 AM
See [A JavaFX 1.3 Custom Layout Example|http://learnjavafx.typepad.com/weblog/2010/05/a-javafx-13-custom-layout-example.html] article.
Also of interest: MiGLayout, implemented in JFXtras (coming soon to support 1.3).
Similar Messages
-
What is equivalent of JInternalFrame in JavaFX 2.0?
what is equivalent of JInternalFrame in JavaFX 2.0?
Actually I want to use pure javaFX 2.0 to view report created in iReport 5.0.0.
I have used java.swing code, and now I want to use pure javaFX 2.0.
My code in swing is as follows
* To change this template, choose Tools | Templates
* and open the template in the editor.
package reports;
import java.awt.BorderLayout;
import java.awt.Container;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashMap;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JRViewer;
* @author TANVIR AHMED
public class ReportsViewer extends javax.swing.JInternalFrame {
* Creates new form MyiReportViewer
private ReportsViewer()
super("Report Viewer",true,true,true,true);
initComponents();
setBounds(10,10,600,500);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
public ReportsViewer(String fileName)
this(fileName,null);
public ReportsViewer(String fileName,HashMap parameter)
this();
try
/* load the required JDBC driver and create the connection
here JDBC Type Four Driver for MySQL is used*/
//Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "invoice", "item");
//Connection con=DriverManager.getConnection("jdbc:mysql://localhost/inventory","root","karim");
/*(Here the parameter file should be in .jasper extension
i.e., the compiled report)*/
JasperPrint print = JasperFillManager.fillReport(
fileName, parameter, con);
JRViewer viewer=new JRViewer(print);
Container c=getContentPane();
c.setLayout(new BorderLayout());
c.add(viewer);
catch(SQLException sqle)
sqle.printStackTrace();
catch(JRException jre)
jre.printStackTrace();
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 394, Short.MAX_VALUE)
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 290, Short.MAX_VALUE)
pack();
}// </editor-fold>
// Variables declaration - do not modify
// End of variables declaration
and
* To change this template, choose Tools | Templates
* and open the template in the editor.
package reports;
import java.beans.PropertyVetoException;
* @author TANVIR AHMED
public class MainUI extends javax.swing.JFrame {
* Creates new form MainUI
public MainUI() {
super("REPORTS");
initComponents();
setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize());
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jMenuItem1 = new javax.swing.JMenuItem();
desktopPane = new javax.swing.JDesktopPane();
salesTaxInv = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
supplyRegister = new javax.swing.JButton();
PartyLedger = new javax.swing.JButton();
menuBar = new javax.swing.JMenuBar();
jMenuItem1.setText("jMenuItem1");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
desktopPane.setBackground(new java.awt.Color(255, 204, 0));
desktopPane.setBorder(new javax.swing.border.MatteBorder(null));
desktopPane.setForeground(new java.awt.Color(255, 0, 102));
desktopPane.setAutoscrolls(true);
desktopPane.setFont(new java.awt.Font("Bookman Old Style", 0, 14)); // NOI18N
desktopPane.setPreferredSize(new java.awt.Dimension(1024, 768));
salesTaxInv.setBackground(new java.awt.Color(255, 255, 255));
salesTaxInv.setFont(new java.awt.Font("Bookman Old Style", 1, 18)); // NOI18N
salesTaxInv.setForeground(new java.awt.Color(204, 0, 0));
salesTaxInv.setText("Sales Tax Invoice");
salesTaxInv.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
salesTaxInvActionPerformed(evt);
salesTaxInv.setBounds(20, 53, 200, 31);
desktopPane.add(salesTaxInv, javax.swing.JLayeredPane.DEFAULT_LAYER);
jLabel1.setFont(new java.awt.Font("Bookman Old Style", 0, 24)); // NOI18N
jLabel1.setForeground(new java.awt.Color(50, 72, 255));
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Invoice System Reports");
jLabel1.setBounds(0, -1, 1024, 50);
desktopPane.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);
supplyRegister.setFont(new java.awt.Font("Bookman Old Style", 1, 18)); // NOI18N
supplyRegister.setForeground(new java.awt.Color(204, 0, 0));
supplyRegister.setText("Supply Register");
supplyRegister.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
supplyRegisterActionPerformed(evt);
supplyRegister.setBounds(20, 100, 200, 30);
desktopPane.add(supplyRegister, javax.swing.JLayeredPane.DEFAULT_LAYER);
PartyLedger.setFont(new java.awt.Font("Bookman Old Style", 1, 18)); // NOI18N
PartyLedger.setForeground(new java.awt.Color(204, 0, 0));
PartyLedger.setText("Party Ledger");
PartyLedger.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
PartyLedgerActionPerformed(evt);
PartyLedger.setBounds(20, 140, 200, 30);
desktopPane.add(PartyLedger, javax.swing.JLayeredPane.DEFAULT_LAYER);
setJMenuBar(menuBar);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(desktopPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
pack();
}// </editor-fold>
private void salesTaxInvActionPerformed(java.awt.event.ActionEvent evt) {
try
ReportsViewer myiReportViewer = new ReportsViewer("reports/INV.jasper");
myiReportViewer.setBounds(0, 0, desktopPane.getWidth(), desktopPane.getHeight());
myiReportViewer.setVisible(true);
desktopPane.add(myiReportViewer);
myiReportViewer.setSelected(true);
catch (PropertyVetoException pve)
pve.printStackTrace();
private void supplyRegisterActionPerformed(java.awt.event.ActionEvent evt) {
try
ReportsViewer myiReportViewer = new ReportsViewer("reports/supplyRegister.jasper");
myiReportViewer.setBounds(0, 0, desktopPane.getWidth(), desktopPane.getHeight());
myiReportViewer.setVisible(true);
desktopPane.add(myiReportViewer);
myiReportViewer.setSelected(true);
catch (PropertyVetoException pve)
pve.printStackTrace();
private void PartyLedgerActionPerformed(java.awt.event.ActionEvent evt) {
try
ReportsViewer myiReportViewer = new ReportsViewer("reports/CustomerLedger.jasper");
myiReportViewer.setBounds(0, 0, desktopPane.getWidth(), desktopPane.getHeight());
myiReportViewer.setVisible(true);
desktopPane.add(myiReportViewer);
myiReportViewer.setSelected(true);
catch (PropertyVetoException pve)
pve.printStackTrace();
* @param args the command line arguments
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MainUI().setVisible(true);
// Variables declaration - do not modify
private javax.swing.JButton PartyLedger;
private javax.swing.JDesktopPane desktopPane;
private javax.swing.JLabel jLabel1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuBar menuBar;
private javax.swing.JButton salesTaxInv;
private javax.swing.JButton supplyRegister;
// End of variables declaration
Best RegardsDear Sir,
I am using the swing code and running the jasper report with the above code.
Realy!
I start the thread with this code
@FXML
private void mainUiButtonAction(ActionEvent event) {
try{
new MainUI().setVisible(true);
catch(Exception ex){
} -
Hello,
I am trying to embed a JavaFX scene in swing JComponent as shown below:
import java.awt.;
import javax.swing.;
import org.jfxtras.scene.SceneToJComponent;
public class Main extends JFrame {
public static JTextField tf = new JTextField("JavaFX for SWING");
public Main() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("JavaFX in SWING Test");
Container container = getContentPane();
container.setLayout(new BorderLayout());
String sceneClass = "cdcapplication13.MyScene";
JComponent myScene = SceneToJComponent.loadScene(sceneClass);
JLabel label = new JLabel(" Below is a JavaFX Animation: ");
container.add(label, BorderLayout.NORTH);
container.add(myScene, BorderLayout.CENTER);
JPanel p = new JPanel();
p.setLayout(new FlowLayout());
tf.setColumns(28);
p.add(tf);
p.add(new JButton("SWING Button"));
container.add(p, BorderLayout.SOUTH);
pack();
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(
new Runnable() {
public void run() {
new Main().setVisible(true);
In the above cdcapplication13.MyScene is my JavaFX scene class. The above worksfine is a desktop application. However, when trying to do the same on a CDC application with Emulator platform - CDC Java(TM) Platform Micro Edition SDK 3.0, Device - SunVgaAGUIPhone1 and Device Profile - PBP-1.1, I get the following exception when running to app:
nsicom-run:
ODT agent stopped.
java.lang.SecurityException: no manifiest section for signature file entry javax/crypto/KeyGeneratorSpi.class
at sun.security.util.SignatureFileVerifier.verifySection(SignatureFileVerifier.java:278)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:190)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:259)
at java.util.jar.JarVerifier.update(JarVerifier.java:214)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:270)
at java.util.jar.JarFile.getInputStream(JarFile.java:332)
at sun.misc.Launcher$AppClassLoader.defineClassPrivate(Launcher.java:544)
at sun.misc.Launcher$AppClassLoader.access$500(Launcher.java:344)
at sun.misc.Launcher$4.run(Launcher.java:565)
at java.security.AccessController.doPrivileged(AccessController.java:351)
at java.security.AccessController.doPrivileged(AccessController.java:320)
at sun.misc.Launcher$AppClassLoader.doClassFind(Launcher.java:559)
at sun.misc.Launcher$AppClassLoader.findClass(Launcher.java:607)
at java.lang.ClassLoader.loadClass(ClassLoader.java:349)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:420)
at java.lang.ClassLoader.loadClass(ClassLoader.java:338)
at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:603)
at java.lang.ClassLoader.loadClass(ClassLoader.java:291)
at com.sun.cdc.odt.CdcAppManager.runMain(CdcAppManager.java:168)
at com.sun.cdc.odt.CdcAppManager.access$100(CdcAppManager.java:44)
at com.sun.cdc.odt.CdcAppManager$1.run(CdcAppManager.java:90)
at java.lang.Thread.startup(Thread.java:782)
Can anyone please tell me how to fix this issue?
Thanks!Hi,
I want to create a CSV file and email it as an
attachment to a specified email address once the user
presses Submit in my application. This is developed
for Sony Ericsson P990i. Can anyone help me with
this?
Thanks in advanceI just tried this yesterday, and got to the point where I realized that the Foundation 1.0 JCL, doesn't support what I need from JavaMail 1.4x. Perhaps the alternative, is to read the RFCs, and write a native client, or maybe FTP the file(s)?
Jeff -
Netbeans Platform Application and JavaFX CSS API
I'm using JavaFX in my Netbeans Platform Application. I load JavaFX scene with next code:
SwingUtilities.invokeLater(new Runnable()
@Override
public void run()
javaFxPanel.setSize(getSize());
add(javaFxPanel, BorderLayout.CENTER);
Platform.runLater(new Runnable() {
@Override
public void run() {
Group branchNode = new Group();
Scene scene = new Scene(branchNode);
try{
scene.getStylesheets().add("C:\\Xlab\\pandora\\branches\\simon-welcome-screen\\TraineeGuiApp\\modules\\ui\\welcomescreen\\main.css");
catch(Exception e)
Exceptions.printStackTrace(e);
Rectangle rect = new Rectangle(100,100);
rect.setLayoutX(50);
rect.setLayoutY(50);
rect.getStyleClass().add("my-rect");
((Group)scene.getRoot()).getChildren().add(rect);
// Add scene to panel
javaFxPanel.setScene(scene);
javaFxPanel.setVisible(true);
//Application.launch(FXApplication.class, null);
});As you can see i provide absolute path to my css file. CSS file and class that i want to use it from are in same package. I also tried providing just a "main.css" string to scene.getStylesheets().add("main.css"); method.
I have no idea why this is not working. Any suggestions?
Edited by: user8867321 on 1.9.2011 9:56Admittedly, the stylesheet path handling is pretty bad. If you can see the .css file in your browser, then you have a valid URL. You can also use Class.getResource("blah").toExternalForm() to get the right URL string. For example, if I have my .css file in the same directory as Main.java, then I could do scene.getStylesheets().add(Main.class.getResource("sample.css").toExternalForm());
-
Hello,
I am trying to embed a JavaFX scene in swing JComponent as shown below:
import java.awt.*;
import javax.swing.*;
import org.jfxtras.scene.SceneToJComponent;
public class Main extends JFrame {
public static JTextField tf = new JTextField("JavaFX for SWING");
public Main() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("JavaFX in SWING Test");
Container container = getContentPane();
container.setLayout(new BorderLayout());
String sceneClass = "cdcapplication13.MyScene";
JComponent myScene = SceneToJComponent.loadScene(sceneClass);
JLabel label = new JLabel(" Below is a JavaFX Animation: ");
container.add(label, BorderLayout.NORTH);
container.add(myScene, BorderLayout.CENTER);
JPanel p = new JPanel();
p.setLayout(new FlowLayout());
tf.setColumns(28);
p.add(tf);
p.add(new JButton("SWING Button"));
container.add(p, BorderLayout.SOUTH);
pack();
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(
new Runnable() {
public void run() {
new Main().setVisible(true);
In the above cdcapplication13.MyScene is my JavaFX scene class. The above worksfine is a desktop application. However, when trying to do the same on a CDC application with Emulator platform - CDC Java(TM) Platform Micro Edition SDK 3.0, Device - SunVgaAGUIPhone1 and Device Profile - PBP-1.1, I get the following exception when running to app:
nsicom-run:
ODT agent stopped.
java.lang.SecurityException: no manifiest section for signature file entry javax/crypto/KeyGeneratorSpi.class
at sun.security.util.SignatureFileVerifier.verifySection(SignatureFileVerifier.java:278)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:190)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:259)
at java.util.jar.JarVerifier.update(JarVerifier.java:214)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:270)
at java.util.jar.JarFile.getInputStream(JarFile.java:332)
at sun.misc.Launcher$AppClassLoader.defineClassPrivate(Launcher.java:544)
at sun.misc.Launcher$AppClassLoader.access$500(Launcher.java:344)
at sun.misc.Launcher$4.run(Launcher.java:565)
at java.security.AccessController.doPrivileged(AccessController.java:351)
at java.security.AccessController.doPrivileged(AccessController.java:320)
at sun.misc.Launcher$AppClassLoader.doClassFind(Launcher.java:559)
at sun.misc.Launcher$AppClassLoader.findClass(Launcher.java:607)
at java.lang.ClassLoader.loadClass(ClassLoader.java:349)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:420)
at java.lang.ClassLoader.loadClass(ClassLoader.java:338)
at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:603)
at java.lang.ClassLoader.loadClass(ClassLoader.java:291)
at com.sun.cdc.odt.CdcAppManager.runMain(CdcAppManager.java:168)
at com.sun.cdc.odt.CdcAppManager.access$100(CdcAppManager.java:44)
at com.sun.cdc.odt.CdcAppManager$1.run(CdcAppManager.java:90)
at java.lang.Thread.startup(Thread.java:782)
Can anyone please tell me how to fix this issue?
Thanks!Welcome to the forum. Please don't post in threads that are long dead and don't hijack other threads. When you have a question, start your own topic. Feel free to provide a link to an old post that may be relevant to your problem.
I'm locking this thread now. -
JavaFX embedded into Swing applications - success
For those of you who are trying to use JavaFX within Swing here is an easy way to do it.
Rectangle rect = new Rectangle();
rect.$width.setAsDouble(100);
rect.$height.setAsDouble(100);
SGNode sgNode = rect.getSGRectangle();
JSGPanel sgPanel = new JSGPanel();
sgPanel.setScene(sgNode);
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());
mainPanel.add(sgPanel, BorderLayout.CENTER);The same approach also works for custom nodes you have developed yourself. Note that you can change values of public variables declared in your JavaFX node with e.g. rect.$width.setAsDouble(200.0); When you do this be sure you run the value update code from event dispatch thread.
I guess this makes JavaFX more usable for us who develop desktop applications with Swing and can't start rewriting everything in JavaFX :-)
Edited by: aless on Dec 12, 2008 6:51 AMaless,
can you provide concrete example of your approach. im new to fx really unable to follow your example. I tried to follow pmd's explanation but im unable to load the fx classes by the same class loader. Im getting the following error in the runtime
Thanks and appreciate your help.
Sri
Exception in thread "main" java.lang.ClassNotFoundException: test.TestFx
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at test.TestJavaFX.main(TestJavaFX.java:27)
Profiler Agent: Initializing...
package test;
import com.sun.scenario.scenegraph.JSGPanel;
import com.sun.scenario.scenegraph.SGNode;
public class TestJavaFX {
public static void main(String[] args) throws Exception {
Class c = Class.forName("test.TestFx");
TestFxInterface test = (TestFxInterface) c.newInstance();
SGNode sgNode = test.getSGNode();
JSGPanel sgPanel = new JSGPanel();
sgPanel.setScene(sgNode);
package test;
import com.sun.scenario.scenegraph.SGNode;
import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
public class TestFx extends CustomNode, TestFxInterface {
public override function create(): Node {
return Group {
content: [
Rectangle {
x: 10,
y: 10
width: 140,
height: 90
fill: Color.BLACK
Circle {
centerX: 100,
centerY: 100
radius: 40
fill: Color.BLUE
public override function getSGNode(): SGNode {
return
this.impl_getSGNode();
package test;
import com.sun.scenario.scenegraph.SGNode;
public interface TestFxInterface {
public SGNode getSGNode();
} -
JMF + JavaFx layout problem
I can creat a GUI in javafx and call the JMF component within JavaFx, just like this
public class JMFComponent extends SwingComponent{
var panel: JPanel;
public var center: java.awt.Component on replace{
println("[center] set component: {center}");
panel.add(center, BorderLayout.CENTER);
public override function createJComponent():javax.swing.JComponent{
panel= new JPanel(new BorderLayout());
var size:Dimension = new Dimension(width, height);
panel.setPreferredSize(size);
panel.setMinimumSize(size);
panel.setMaximumSize(size);
panel.setSize(size);
return panel;
public class MyMedia extends CustomNode {
var xpos: Number;
var ypos: Number;
var dx: Number;
public var url: java.net.URL;
public var autoPlay: Boolean;
public override function create(): Node{
var comp:java.awt.Component;
var control:java.awt.Component;
var w:Number;
var h:Number;
var cw:Number;
var ch:Number;
var jmfCom:JMFComponent;
var player = Manager.createRealizedPlayer(url);
comp=player.getVisualComponent();
control=player.getControlPanelComponent();
if (autoPlay) {
player.start();
w=comp.getPreferredSize().getWidth();
h=comp.getPreferredSize().getHeight();
cw=control.getPreferredSize().getWidth();
ch=control.getPreferredSize().getHeight();
jmfCom=JMFComponent {
width:w
height:h+ch
center: comp
blocksMouse: true
bottom: control
return Group{
content: [
jmfCom
Stage {
title: "Media Example"
width: 500
height: 500
onClose: function(){ java.lang.System.exit(0);}
scene: Scene {
content: MyMedia{
url: (
new java.io.File("C://My//Videos//DELTA.MPG")).toURI().toURL()
autoPlay: true
The video can be played within JavaFx gui, but when i move my mouse cursor into the control bar of the JMF player, the video window will move at the same time.
Does anyone have an idea how I can get JMF working normally within JavaFx?Reposting the [exact same message|http://forums.sun.com/thread.jspa?threadID=5361672] (and still not using the CODE button...) won't help you more...
Explaining what is the JMF component (and where to find it, etc.) might help a bit more those willing to help. -
I'm trying to use a Java class in a JavaFX script. It's a class using the JMF to create a JPanel displaying the image of my webcam.
This code use to work in Java projects using Eclipse. Now, I want to implement this code in a JavaFX project using netbeans. Here is the Java code :
import javax.swing.*;
import javax.media.*;
import javax.media.format.*;
import javax.media.protocol.CaptureDevice;
import javax.media.protocol.DataSource;
import javax.media.util.*;
import javax.media.control.*;
import java.awt.*;
public class SwingCapture extends JPanel {
private static final long serialVersionUID = 1L;
public static Player player = null;
public CaptureDeviceInfo di = null;
public MediaLocator ml = null;
public JButton capture = null;
public Buffer buf = null;
public Image img = null;
public VideoFormat vf = null;
public BufferToImage btoi = null;
public SwingCapture() {
setLayout(new BorderLayout());
setSize(320,550);
di = CaptureDeviceManager.getDevice("vfw:Microsoft WDM Image Capture (Win32):0");
Format[] video = di.getFormats();
ml = di.getLocator();
try {
DataSource ds = Manager.createDataSource(ml);
FormatControl[] fmtControl = ((CaptureDevice)ds).getFormatControls();
fmtControl[0].setFormat(video [1]);
player = Manager.createRealizedPlayer(ds);
player.start();
Component comp;
if ((comp = player.getVisualComponent()) != null) {
add(comp,BorderLayout.NORTH);
} catch (Exception e) {
e.printStackTrace();
public static void playerclose() {
player.close();
player.deallocate();
}I implements the code Java code in the JavaFX script this way :
var cam : SwingCapture = new SwingCapture ();
var camFx : SwingComponent = SwingComponent.wrap(cam);Netbeans tells me everything is fine, but stops me I try to launch my application telling me this :
java.lang.NullPointerException
at webtv.SwingCapture.<init>(SwingCapture.java:31)
at webtv.Main.javafx$run$(Main.fx:293)
at webtv.Main.javafx$run$(Main.fx:293)
BUILD STOPPED (total time: 11 seconds)Here is the line 31 in SwingCapture :
30 : di = CaptureDeviceManager.getDevice("vfw:Microsoft WDM Image Capture (Win32):0");
31 : Format[] video = di.getFormats();
32 : ml = di.getLocator();So here are my questions :
- does someone know why my code works in Java projects but doesn't in JavaFX projects ?
- does someone know how to use the webcam without using Java code ?
Thank you ;)I have the same problem ,
I'm trying to use a Java class in a JavaFX script.
I reiterate the question:
- does someone know why this code works in Java projects but doesn't in JavaFX projects ?
- does someone know how to use the webcam without using Java code ?
thanks -
Has anyone used jdic and JavaFX?
I'd like to integrate web content (html pages and youtube video) in a JavaFX application.
I'm using the webbrowser component of jdic but I have several problems:
1) I can't see web content.
2) I can't move the panel.
I tried two ways:
1) A javafx class that extend a swingComponent class, this is my code:
//MyWebBrowserFX.fx
import javafx.ext.swing.SwingComponent;
import org.jdesktop.jdic.browser.WebBrowser;
import java.net.URL;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
public class MyWebBrowserFX extends SwingComponent{
public override function createJComponent(){
var webBrowser = new WebBrowser();
webBrowser.setSize(300, 300);
webBrowser.setURL(new URL("http://www.google.it"));
var panel : JPanel = new JPanel();
panel.setLayout(new BorderLayout());
panel.setPreferredSize(new Dimension(500, 500));
//panel.setLocation(300, 300);
panel.move(100, 100);
panel.add(webBrowser, BorderLayout.CENTER);
return panel;
//MyScene.fx
public var myScene = Scene {
content: Group{
content: [
MyWebBrowserFX{
}In this case I see a white square (500x500) in 0,0 coordinates and I don't see Google web page.
I tried to move the web browser in this way
//MyScene.fx
var webBrowser = Group {
translateX: 200
translateY: 200
content: [
MyWebBrowserFX{
public var myScene = Scene {
content: Group{
content: [
webBrowser
}In this case I don't see anything, the white square disappear
2) Integrate a swing component in a JavaFX scene:
//MyWebBrowser.java
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComponent;
import javax.swing.JPanel;
import org.jdesktop.jdic.browser.WebBrowser;
public class MyWebBrowser {
public static JComponent create() {
WebBrowser webBrowser = new WebBrowser();
try {
webBrowser.setURL(new URL("http://www.google.it"));
} catch (MalformedURLException ex) {
Logger.getLogger(MyWebBrowser.class.getName()).log(Level.SEVERE, null, ex);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.setPreferredSize(new Dimension(1000, 1000));
//panel.setLocation(300, 300);
panel.add(webBrowser, BorderLayout.CENTER);
return panel;
//MyScene.fx
var wb = null;
var wbComp1 : Node;
var wbComp : Node = bind wbComp1;
public function setWebComponent(){
wb = MyWebBrowser.create();
wb.setPreferredSize(new java.awt.Dimension(400,300));
wbComp1 = SwingComponent.wrap(wb);
public var ARScene = Scene {
content: Group{
content: [
wbComp
}Also in this case I don't see anything.
Where am I in wrong?
Edited by: lady_disaster on Jul 23, 2010 5:17 AMYou do not want to use MacKeeper. Third party maintenance utiities are not necessary on a Mac.
If you have installed it, follow the instructions here > Uninstalling MacKeeper
Let your Mac run maintenance for you > Mac OS X: About background maintenance tasks
To view other threads regarding MacKeeper, click, "More Like This" right side of this page. -
How to change default open and close effect in JavaFX TabPane
I'm interested how I can change the default effect of closing and opening a tab in JavaFX TabPAne. I found that this can be configured by using:
tabPane.setEffect(Effect ????);
But which effects are available?Hi Lionate
Welcome to the forum.
Make a document to your liking.
Change the Body style and any other styles in :
+Menu > Show Styles Drawer > click on the little triangle next to Body > redefine Style from Selection+
Capture the page:
+Menu > Format > Advanced > Capture Pages… > Name it > OK+
+Menu > Format > Advanced > Manage Pages… > Delete other Sections/Pages > OK+
Save as a template:
+Menu > File > Save as Template…+
+Menu > Pages > Preferences > General Preferences > For New Documents > click Use template: > Choose > browse to the template above+
Peter -
How can I create a single background image for a BorderLayout?
I can create a background with an image file for the individual panel (North, West, Center, East and South) in a BorderLayout, but I've been spinning my wheel for a long while now trying to figure out how to create just one background with a single image file for all of these panels?
In my application, a panel may contain various buttons, a listbox, a group of checkboxes, a combo box, or a canvas. Even if I used the same image file, when the panels are finally put together, one can clearly see that the end product is the result of a lot of patch works.
Hope someone has an answer for this. BTW, I'm using AWT because it works with existing browsers without the need for a separate Java plug-in.
Regards,
V.V.Look at this :
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.awt.image.BufferedImage;
public class PanI extends Frame
Image map;
Panel pan;
myPan p8,p4,p6,p2,p5;
BufferedImage I;
public PanI()
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent ev)
{ dispose();
System.exit(0);}});
map = getToolkit().getImage("map2.gif");
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(map,0);
try {tracker.waitForID(0);}
catch (InterruptedException e){}
I = new BufferedImage(1,1,BufferedImage.TYPE_INT_ARGB);
setBounds(10,10,map.getWidth(null)+8,map.getHeight(null)+27);
setLayout(new BorderLayout());
pan = new Panel();
add(pan,BorderLayout.CENTER);
pan.setLayout(new BorderLayout());
pan.setSize(map.getWidth(null),map.getHeight(null));
p5 = new myPan(5);
p5.setBackground(Color.red);
pan.add(p5,BorderLayout.CENTER);
p8 = new myPan(8);
p8.setBackground(Color.orange);
pan.add(p8,BorderLayout.NORTH);
p4 = new myPan(4);
p4.setBackground(Color.blue);
pan.add(p4,BorderLayout.WEST);
p6 = new myPan(6);
p6.setBackground(Color.green);
pan.add(p6,BorderLayout.EAST);
p2 = new myPan(2);
p2.setBackground(Color.pink);
pan.add(p2,BorderLayout.SOUTH);
setVisible(true);
public class myPan extends Panel
int where;
public myPan(int i)
super();
where = i;
public void paint(Graphics g)
if (I.getWidth(null) != pan.getWidth() || I.getHeight(null) != pan.getHeight())
I = new BufferedImage(pan.getWidth(),pan.getHeight(),BufferedImage.TYPE_INT_ARGB);
Graphics G = I.getGraphics();
G.drawImage(map,0,0,pan.getWidth(),pan.getHeight(),null);
G.dispose();
int x1=0;
int x2=getWidth();
int y1=0;
int y2=getHeight();
if (where == 8)
if (where == 2)
y1 = p8.getHeight()+p5.getHeight();
y2 = getHeight()+y1;
if (where == 4)
y1 = p8.getHeight();
y2 = y1+getHeight();
if (where == 5)
x1 = p4.getWidth();
x2 = x1+getWidth();
y1 = p8.getHeight();
y2 = y1+getHeight();
if (where == 6)
x1 = p4.getWidth()+p5.getWidth();;
x2 = x1+getWidth();
y1 = p8.getHeight();
y2 = y1+getHeight();
g.drawImage(I,0,0,getWidth(),getHeight(),x1,y1,x2,y2,null);
public void update(Graphics g)
paint(g);
public static void main (String[] args)
new PanI();
Noah -
Issue with DataApp Sample in JavaFX.
Okay so I downloaded the Samples pack here http://jdk8.java.net/download.html or here http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html at the bottom.
Inside is one called DataApp which requires setting up an SQL DB, and connecting to it.
In Netbeans8 I get an error about not having RestLib api inside the DataAppClient which according to the setup DataAppClient - The JavaFX 2.0 client application. inside there you can see a package with packages that wont import such as
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.json.JSONConfiguration;
So why am I in a Java 8 samples pack needing FX 2? Though I'm not sure if it's FX8 yet, I just didn't think the 2.0 client would work.
So I tried Netbeans 7.3 to see if it would work. At first the DataAppClient was fine, but I see the DataAppPreloader will not run because it uses Package javafx.something which apparently is new in Java 8.....
So now I'm stuck, wondering why Restlib doesn't exist... I looked it up, and it says it's used for Web services, but I don't have it, nor does it say to install it in the readme.
not existing, which I guess has to do with the RestLib?
Anyone have any ideas?
EDIT: So I just downloaded the version for FX2, and I am still getting the same error when I run it, though nothing shows "errors" in the packages. Maybe I just needed to run it correctly for it to work, so not what is this error tellingme
Creating "dataapp" user and "APP" database...
Executing commands
Failed to execute: INSERT INTO user VALUES ('localhost','dataapp','*B974A83D18BB105D0C9186756F485406E6E6039B','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'',NULL)
C:\Users\Konrad\Downloads\javafx_samples-2_2_7-windows\javafx-samples-2.2.7\src\DataApp\DataAppLoader\build.xml:84:
java.sql.SQLException: Column count doesn't match value count at row 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2002)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2618)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2568)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:842)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:681)
at org.apache.tools.ant.taskdefs.SQLExec.execSQL(SQLExec.java:775)
at org.apache.tools.ant.taskdefs.SQLExec.runStatements(SQLExec.java:745)
at org.apache.tools.ant.taskdefs.SQLExec$Transaction.runTransaction(SQLExec.java:1043)
at org.apache.tools.ant.taskdefs.SQLExec$Transaction.access$000(SQLExec.java:985)
at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:653)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:392)
at org.apache.tools.ant.Target.performTasks(Target.java:413)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:283)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:541)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
BUILD FAILED (total time: 6 seconds)I have put the 1.18 derby file into glassfish, download and set up MySQL using a netbeans reference,I had set my root password and such as well.
The only thing I haven't done is created a DB, but I don't think I need one, and the instructions don't say anything.
I have Netbenans 7.3, 8, and Java vers 7_15 and 8 build 82.
GlassFish 3.1.2 as well as 4.0 build 76 which I haven't installed.
I hav e MySQL 5.6
Java FX 2.0 and 8 build 82.
The instructions are
DataApp Installation Guide
Table of Contents
Prerequisites
Setting Up the DataApp Sample
Running the Sample
NetBeans Projects for the Sample
Licensing
Prerequisites
You must have the following software installed to run the DataApp sample:
Java SDK 1.6.0_24 or later
Available at http://www.oracle.com/technetwork/java/javase/downloads/index.html.
JavaFX 2.0 SDK or later
Available at http://javafx.com/downloads/all.jsp.
MySQL 5.5 or later
Available at http://dev.mysql.com/downloads/.
You need to know the root password for your installation.
Netbeans 7.1 with Java EE and GlassFish 3.1.1 or later
Available at http://netbeans.org/downloads/.
Run the NetBeans installer to install NetBeans and GlassFish to the default locations.
Setting Up the DataApp Sample
Install the MySQL drivers into GlassFish.
Manually copy the mysql-connector-java-5.1.13-bin.jar file from the netbeans-install-dir\ide\modules\ext\ to the glassfish-install-dir/glassfish/lib directory, where netbeans-install-dir and glassfish-install-dir are the directories into which the products were installed. For example, on Windows the install directory for products is typically in the C:\Program Files\ or C:\Program Files (x86)\ directories.
Open the following DataApp projects in NetBeans by selecting File ->Open Project and navigating to the location of the DataApp sample:
DataAppClient
DataAppLibrary
DataAppLoader
DataAppPreloader
DataAppServer
Configure and create the database (only needs to be done once):
In NetBeans, right-click the DataAppLoader project.
Select Run.
Enter your MySQL root password when prompted.
Wait until you see the message that the build has successfully finished, which takes approximately 5 to 15 minutes.
Running the Sample
Start the server:
In NetBeans, right-click the DataAppServer project.
Select Run.
Wait until a browser window opens that says: YOU ARE DONE!
(Optional) Start the standalone client:
In NetBeans, right-click the DataAppClient project.
Select Run.
NetBeans Projects for the Sample
DataAppLibrary - Contains the following data:
Database tables
ORM model to database tables
DataAppLoader - Application that is run once to perform the following tasks:
Creates the database.
Loads all of the static data for the data app.
Creates some historical data.
DataAppServer - Web server that performs the following tasks:
Simulates auto sales and persists them to the database.
Provides access to the database through web services.
DataAppClient - The JavaFX 2.0 client application.
Licensing
The license for the DataAppLoader/zip_code_inserts.sql file is the Creative Commons Attribution-ShareAlike license, which is available at http://creativecommons.org/licenses/by-sa/2.0/.
The license for all other files is the BSD style license:
* Copyright (c) 2008, 2011 Oracle and/or its affiliates.
* All rights reserved. Use is subject to license terms.
* This file is available and licensed under the following license:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the distribution.
* - Neither the name of Oracle Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Copyright © 2011, Oracle and/or its affiliates. All rights reservedEdited by: KonradZuse on Mar 27, 2013 9:39 AM
Edited by: KonradZuse on Mar 27, 2013 9:51 AM
Edited by: KonradZuse on Mar 27, 2013 9:58 AMI found the same issue but resolved it by myself. The user table of the MySQL changed, my guess. You need to add another 'Y' or 'N' to the end of this statement in the build.xml of DataAppLoader:
INSERT INTO user VALUES ('localhost','dataapp','*B974A83D18BB105D0C9186756F485406E6E6039B','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'',NULL,'N');
The original one is like this:
INSERT INTO user VALUES ('localhost','dataapp','*B974A83D18BB105D0C9186756F485406E6E6039B','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'',NULL);
The new column added is password_expired. Y or N to indicate the password is good or not. -
Can't run JavaFX app as a jar file from command line
I'm trying to build a JavaFX app from scratch (that is, by including the jar file from the JavaFX SDK rather than by using the special JavaFX project type from NetBeans). It runs fine in NetBeans. However, when I try to launch it as a jar file from the command line (using "java -jar dist\TestApp") I get the following. Has anybody seen this before, and if so how can I fix it?:
*** Fallback to Prism SW pipeline
Exception in thread "main" java.lang.RuntimeException: java.lang.UnsatisfiedLink
Error: Can't load library: C:\dev\TestApp\dist\bin\mat.dll
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:
289)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:68)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherIm
pl.java:145)
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:
27)
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:97)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.UnsatisfiedLinkError: Can't load library: C:\dev\RedactionT
oolPrototype\RedactionToolPrototype.Core\dist\bin\mat.dll
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com.sun.glass.utils.NativeLibLoader.loadLibraryFullPath(NativeLibLoad
er.java:155)
at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoad
er.java:85)
at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:
30)
at com.sun.glass.ui.Application$1.run(Application.java:28)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.glass.ui.Application.loadNativeLibrary(Application.java:26)
at com.sun.glass.ui.win.WinApplication.<clinit>(WinApplication.java:33)
at com.sun.glass.ui.win.WinPlatformFactory.createApplication(WinPlatform
Factory.java:20)
at com.sun.glass.ui.win.WinPlatformFactory.createApplication(WinPlatform
Factory.java:17)
at com.sun.glass.ui.Application.Run(Application.java:51)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:
279)
... 5 moreUnsatisfied link means that Java is trying to access a native library, but it cannot be found. As to why this error is being thrown, here is my guess:
If you open up one of the sample jars with a zip viewer, you will see that the Manifest file has the following entries:
>
Manifest-Version: 1.0
JavaFX-Version: 2.0
implementation-vendor: Oracle
implementation-title: BrickBreaker
implementation-version: 1.0
JavaFX-Application-Class: brickbreaker.Main
Created-By: JavaFX Packager
Main-Class: com/javafx/main/Main
>
In other words, a JavaFX project works a bit differently than a normal Java project. com/javafx/main/Main is used as the Main class and your "Main" class is called later.
If you are trying to build this from a normal Java project, then com/javafx/main/Main will not be created and it will call your Main class right away. Thus, whatever setup is needed to run JavaFX will not occur. -
JavaFX Update Line Chart on Tab pane
Hi all,
I am wondering can anybody help with this problem.
I have an application that can create a new tab when the LineChart FXML view is called by way of onMouseClicked event from a bar graph (using scenebuilder). However, I need this Line chart to update when the user clicks a new bar on the bar graph page to show this new data.
Initially the Line chart tab will open and display data from the first bar graph click and when I click another bar in Tab A (bar chart) if it has the same number of rows it will refresh the LineChart tab otherwise I get an error. Then if I try to load another line graph tab using a different bar graph as the source I get a child duplication error
(So tab A has a bar graph that calls tab B to represent data as a line graph, however it wont do it more then once when there is a different number of points to show)
(Also tab C, another Bar chart will not load a new tab) Exceptions below & Class detail below.
I am using clear() to empty the observable list I have which is used to populate the graph and table before it reads in the new data values
What is the proper way/ best way to dynamically add another tab and update the chart in the tab with new values? Any help would be appreciated.
I am getting the following exceptions:
Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: Index: 11, Size: 7
at java.util.ArrayList.rangeCheckForAdd(ArrayList.java:661)
at java.util.ArrayList.add(ArrayList.java:473)
at com.sun.javafx.collections.ObservableListWrapper.doAdd(ObservableListWrapper.java:101)
at javafx.collections.ModifiableObservableListBase.add(ModifiableObservableListBase.java:151)
at com.sun.javafx.collections.VetoableListDecorator.add(VetoableListDecorator.java:320)
at com.sun.javafx.scene.control.skin.TabPaneSkin$TabHeaderArea.addTab(TabPaneSkin.java:854)
at com.sun.javafx.scene.control.skin.TabPaneSkin$TabHeaderArea.access$500(TabPaneSkin.java:659)
at com.sun.javafx.scene.control.skin.TabPaneSkin.addTabs(TabPaneSkin.java:276)
at com.sun.javafx.scene.control.skin.TabPaneSkin.lambda$initializeTabListener$463(TabPaneSkin.java:357)
at com.sun.javafx.scene.control.skin.TabPaneSkin$$Lambda$108/885312968.onChanged(Unknown Source)
at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
at javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
at javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
at javafx.collections.ObservableListBase.endChange(ObservableListBase.java:205)
at javafx.collections.ModifiableObservableListBase.add(ModifiableObservableListBase.java:155)
at java.util.AbstractList.add(AbstractList.java:108)
at javafxapplication2.FXMLExecutionChartController$3.handle(FXMLExecutionChartController.java:262)
at javafxapplication2.FXMLExecutionChartController$3.handle(FXMLExecutionChartController.java:241)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3437)
at javafx.scene.Scene$ClickGenerator.access$7900(Scene.java:3365)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3733)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3452)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1728)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2461)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:348)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:273)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:382)
at com.sun.glass.ui.View.handleMouseEvent(View.java:553)
at com.sun.glass.ui.View.notifyMouse(View.java:925)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1146743572.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at javafxapplication2.FXMLExecutionChartController$3.handle(FXMLExecutionChartController.java:263)
at javafxapplication2.FXMLExecutionChartController$3.handle(FXMLExecutionChartController.java:241)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3437)
at javafx.scene.Scene$ClickGenerator.access$7900(Scene.java:3365)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3733)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3452)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1728)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2461)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:348)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:273)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:382)
at com.sun.glass.ui.View.handleMouseEvent(View.java:553)
at com.sun.glass.ui.View.notifyMouse(View.java:925)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1146743572.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Class Information:
//Call to the Line chart graph
n.setOnMouseClicked(new EventHandler<MouseEvent>()
@Override
public void handle ( MouseEvent e )
String s1 = dt.getXValue();
String s = s1.trim();
if ( baseHash.containsKey(s) )
String value = (String) baseHash.get(s);
String hashValue = value.substring(6, 38);
System.out.println(hashValue);
FXMLLineChartController.setHash(hashValue);
try
lineTab .setText("Line Graph (Rows Read)");
lineTab.setContent(FXMLLoader.load(getClass().getResource("/javafxapplication2/FXMLLineChart.fxml")));
Node aNode = (Node) e.getSource();
Scene scene = aNode.getScene();
thisTabPane = (TabPane) scene.lookup("#tabPane");
thisTabPane.getTabs().add(lineTab);
selectionModel.selectLast();
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
catch ( IOException ex )
Logger.getLogger(FXMLWrittenChartController.class.getName()).log(Level.SEVERE, null, ex);
//Line Chart controller
//Create the Graph
@FXML
private LineChart barChart;
public void populateGraph ()
System.out.println("Populate graph Line Chart");
final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis();
ObservableList<XYChart.Series<String, Number>> barChartData = FXCollections.observableArrayList();
barChartData.clear();
baseHash.clear();
xAxis.setLabel("Query");
yAxis.setLabel("Number of Executions");
series1.setName("Data from User DB2 for Query " +getHash() );
for ( int i = 0; i < userLine.size(); i++ )
System.out.println(getHash() + " Usersize = " + userLine.size() + " base size " +baseLine.size());
series1.getData().add(new XYChart.Data<String, Number>(userLine.get(i).getBuildNumber(), (userLine.get(i).getDYN_Num_Executions())));
barChartData.add(series1);
barChart.setData(barChartData);Hi all,
I am wondering can anybody help with this problem.
I have an application that can create a new tab when the LineChart FXML view is called by way of onMouseClicked event from a bar graph (using scenebuilder). However, I need this Line chart to update when the user clicks a new bar on the bar graph page to show this new data.
Initially the Line chart tab will open and display data from the first bar graph click and when I click another bar in Tab A (bar chart) if it has the same number of rows it will refresh the LineChart tab otherwise I get an error. Then if I try to load another line graph tab using a different bar graph as the source I get a child duplication error
(So tab A has a bar graph that calls tab B to represent data as a line graph, however it wont do it more then once when there is a different number of points to show)
(Also tab C, another Bar chart will not load a new tab) Exceptions below & Class detail below.
I am using clear() to empty the observable list I have which is used to populate the graph and table before it reads in the new data values
What is the proper way/ best way to dynamically add another tab and update the chart in the tab with new values? Any help would be appreciated.
I am getting the following exceptions:
Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: Index: 11, Size: 7
at java.util.ArrayList.rangeCheckForAdd(ArrayList.java:661)
at java.util.ArrayList.add(ArrayList.java:473)
at com.sun.javafx.collections.ObservableListWrapper.doAdd(ObservableListWrapper.java:101)
at javafx.collections.ModifiableObservableListBase.add(ModifiableObservableListBase.java:151)
at com.sun.javafx.collections.VetoableListDecorator.add(VetoableListDecorator.java:320)
at com.sun.javafx.scene.control.skin.TabPaneSkin$TabHeaderArea.addTab(TabPaneSkin.java:854)
at com.sun.javafx.scene.control.skin.TabPaneSkin$TabHeaderArea.access$500(TabPaneSkin.java:659)
at com.sun.javafx.scene.control.skin.TabPaneSkin.addTabs(TabPaneSkin.java:276)
at com.sun.javafx.scene.control.skin.TabPaneSkin.lambda$initializeTabListener$463(TabPaneSkin.java:357)
at com.sun.javafx.scene.control.skin.TabPaneSkin$$Lambda$108/885312968.onChanged(Unknown Source)
at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
at javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
at javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
at javafx.collections.ObservableListBase.endChange(ObservableListBase.java:205)
at javafx.collections.ModifiableObservableListBase.add(ModifiableObservableListBase.java:155)
at java.util.AbstractList.add(AbstractList.java:108)
at javafxapplication2.FXMLExecutionChartController$3.handle(FXMLExecutionChartController.java:262)
at javafxapplication2.FXMLExecutionChartController$3.handle(FXMLExecutionChartController.java:241)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3437)
at javafx.scene.Scene$ClickGenerator.access$7900(Scene.java:3365)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3733)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3452)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1728)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2461)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:348)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:273)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:382)
at com.sun.glass.ui.View.handleMouseEvent(View.java:553)
at com.sun.glass.ui.View.notifyMouse(View.java:925)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1146743572.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at javafxapplication2.FXMLExecutionChartController$3.handle(FXMLExecutionChartController.java:263)
at javafxapplication2.FXMLExecutionChartController$3.handle(FXMLExecutionChartController.java:241)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3437)
at javafx.scene.Scene$ClickGenerator.access$7900(Scene.java:3365)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3733)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3452)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1728)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2461)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:348)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:273)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:382)
at com.sun.glass.ui.View.handleMouseEvent(View.java:553)
at com.sun.glass.ui.View.notifyMouse(View.java:925)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1146743572.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Class Information:
//Call to the Line chart graph
n.setOnMouseClicked(new EventHandler<MouseEvent>()
@Override
public void handle ( MouseEvent e )
String s1 = dt.getXValue();
String s = s1.trim();
if ( baseHash.containsKey(s) )
String value = (String) baseHash.get(s);
String hashValue = value.substring(6, 38);
System.out.println(hashValue);
FXMLLineChartController.setHash(hashValue);
try
lineTab .setText("Line Graph (Rows Read)");
lineTab.setContent(FXMLLoader.load(getClass().getResource("/javafxapplication2/FXMLLineChart.fxml")));
Node aNode = (Node) e.getSource();
Scene scene = aNode.getScene();
thisTabPane = (TabPane) scene.lookup("#tabPane");
thisTabPane.getTabs().add(lineTab);
selectionModel.selectLast();
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
catch ( IOException ex )
Logger.getLogger(FXMLWrittenChartController.class.getName()).log(Level.SEVERE, null, ex);
//Line Chart controller
//Create the Graph
@FXML
private LineChart barChart;
public void populateGraph ()
System.out.println("Populate graph Line Chart");
final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis();
ObservableList<XYChart.Series<String, Number>> barChartData = FXCollections.observableArrayList();
barChartData.clear();
baseHash.clear();
xAxis.setLabel("Query");
yAxis.setLabel("Number of Executions");
series1.setName("Data from User DB2 for Query " +getHash() );
for ( int i = 0; i < userLine.size(); i++ )
System.out.println(getHash() + " Usersize = " + userLine.size() + " base size " +baseLine.size());
series1.getData().add(new XYChart.Data<String, Number>(userLine.get(i).getBuildNumber(), (userLine.get(i).getDYN_Num_Executions())));
barChartData.add(series1);
barChart.setData(barChartData); -
Why doesn't borderlayout work?
Borderlayout seems to not work here. I need the textfield to be north, two buttons under that, and then a label south, but it only shows the label, but if I comment out the field, I see the buttons, please help, here is my code
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import java.awt.Color;
import java.awt.Graphics;
class GUI
private JLabel label1;
private JButton clear;
private JTextField field1;
public static void main(String[] args)
final JFrame f = new JFrame("");
/*Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
screenSize.width -=42;
screenSize.height -= 42;*/
f.setSize(1024,768);
f.setLocation(20,20);
f.setVisible(true);
final JDesktopPane desktop = new JDesktopPane();
desktop.setPreferredSize(new Dimension(1024, 768));
desktop.setBackground(new Color(148,102,75));
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
f.setContentPane(desktop);
final JInternalFrame fr = new JInternalFrame("infix", false, true, true, true);
fr.setSize(203, 126);
fr.setLocation(50, 50);
fr.setVisible(true);
fr.setOpaque(false);
fr.setBackground(new Color(100,0,255,140));
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout(0,0));
panel.setSize(203,126);
panel.setBackground(new Color(0,0,255,140));
panel.setOpaque(false);
JTextField field1 = new JTextField("",60);
field1.setPreferredSize(new Dimension(200, 21));
panel.add(field1,BorderLayout.NORTH);
JButton evaluate = new JButton("Evaluate");
evaluate.setPreferredSize(new Dimension(115,25));
panel.add(evaluate,BorderLayout.CENTER);
JButton clear = new JButton("Clear");
clear.setPreferredSize(new Dimension(115,25));
panel.add(clear,BorderLayout.EAST);
JLabel label = new JLabel("");
label.setPreferredSize(new Dimension(34,100));
panel.add(label,BorderLayout.SOUTH);
fr.add(panel);
desktop.add(fr);
JInternalFrame fr2 = new JInternalFrame("test", true, true, true,false);
fr2.setSize(230, 300);
fr2.setLocation(50, 50);
fr2.setVisible(true);
fr2.setOpaque(false);
fr2.setBackground(new Color(0,0,255,140));
JPanel panel2 = new JPanel();
panel2.setLayout(new BorderLayout(0, 0));
fr2.add(panel2);
desktop.add(fr2);
//f.getContentPane().add(desktop);
f.add(desktop);
}guess what I have fixed it myself, this was the problem label.setPreferredSize(new Dimension(34,100)); wrong size, but I change it to 34, 50 and its work
Maybe you are looking for
-
Can't open Finder after Upgrade to Yosemite 10.10
After the Upgrade to Yosemite 10.10 on my MacBook Pro with Retina Display i can't open the Finder and it says it's not reacting. The bar on top when i'm at the Desktop is also gone. Can somebody help me ?
-
10.6.8 + Safari 5.1 = freeze
Hi all. My partner has this problem on her MacBook Pro, which is newer than the one I'm running 10.7 on. Opening Safari led to an immediate freeze: no page would load. I reset Safari, I wiped preferences, I emptied the cache. I reinstalled the OS. Sa
-
Java.lang.ExceptionInInitializerError
I am trying to create a link to another system from an existing application developed on Oracle9i JDeveloper 9.0.2.822 using java version 1.3.1_02. This uses an API provided by the Vendor of the target system (webMethods 6.1) which uses the entrust l
-
What should I pay attention to do a successful client copy ?
I do the remote client copy successfully , I see the message"remote client copy complete" in SCC3. but the developers say they can not do the post. so , I want to have your advices about how to do a successful copy. what should I pay attention
-
Spreadsheet beginner......where to start.
Okay, I really, really like Numbers. I can see its potential, and am already using it for my checking account, but would really like to be proficient and experiment. Here's the deal....I have zero spreadsheet experience. None. Never worked with Excel