JavaFX 2.0 :: Create Histogram - How To Label Bin Edges

Jan 30, 2015

How to create histogram in JavaFX ? Is it possible to do it using BarChart? how to label the bin edges (ticks)?

View Replies


ADVERTISEMENT

Create Histogram That Allow To Visually Inspect Frequency Distribution Of A Set Of Values

Apr 4, 2014

Design and implement an application that creates a histogram that allows you to visually inspect the frequency distribution of a set of values . The program should read in an arbitrary number of integers that are in the range 1 to 100 inclusive; then produce a chart similar to the one below that indicates how many input values fell in the range 1 to 10, 11 to 20, and so on. Print one asterisk for each value entered.

No input prompt
Terminate input by typing CTRL/Z (two keys typed at the same time) on a separate input line (use CTRL/D on Linux/UNIX systems)
Use hasNextInt() to terminate your input
Format as below (slightly different from the text example)
Z:dbraffittWeek10> javac Histogram.java
Z:dbraffittWeek10> java Histogram

[Code] ....

What I can not figure out is how to use hasNextInt() to terminate the loop. How to not have an input prompt. How to use ctrl z to terminate the input. Or to make it where it doesn't involve range values like -1.

import java.util.Scanner;
public class Histogram {
public static void main (String[] args) {
Scanner scan = new Scanner (System.in);
int [] nums = new int[101];
 
[Code] .....

View Replies View Related

JavaFX 2.0 :: Button Label Cutoff

Jan 9, 2015

I have a button whose text is being cutoff. How can I tell javafx that the button should be as big as the text in it and so no cutting off text happens?

View Replies View Related

JavaFX 2.0 :: How To Properly Customize Text Label Of ComboBox

Jun 8, 2014

Switching from Swing to JFX 8, I am trying to find out how to do something I would normally do in a super-simple ListCellRenderer, i.e. customize the String displayed for an item. I tried this:

ComboBox<Integer> combo = new ComboBox<>();
    combo.getItems().addAll(1, 2, 3);
    combo.setCellFactory(new Callback<ListView<Integer>, ListCell<Integer>>() {
        @Override
        public ListCell<Integer> call(ListView<Integer> param) {
  
[Code] .....
 
However, when I do this, the customized String is not used for the selected Item (rather the standard toString() value of the item). Apart from that it is no longer selectable using the mouse (I submitted a bug report for this at [URL] .... but that is not really the point of my question.

Anything else I have to do to make sure the selected item is also rendered using the custom cell or is there a different mechanism for this?

View Replies View Related

JavaFX 2.0 :: Unable To Bind Text Property Of Selected Cell Of TreeView To Label

Jun 5, 2014

I try to bind the text-property of a selected cell of a TreeView to a label. So if the user click on a cell in the treeview the label should show the cell text. Now I am quite confused about the options I got to do so. Should I use label.textProperty().bind( ... ??? ... ) The treeview.onMouseClicked()property? or something different?

View Replies View Related

Putting ImageIcon Into Label (Original Size) By Clicking On Label (Thumbnail Created Before)

Nov 6, 2014

I'm doing a software Java GUI - JFrame form like this:

1. The user wants to click on a button that opens a bunch of images that will be displayed as thumbnail in the bottom of the JFrame .
2. Then the user wants to select/click one of the thumbnail and make appear the corresponding image in it's original size on above(center) of the JFrame.

For doing this I used 3 JPanel.

One contains a JButton that opens the jfilechoser dialog window,
the second "panelPreview" is for putting the thumbnails created,
and the third "panelGrande" is for the image in it's original size.

The firs part "1." is ok.

But in the second part : I got one error when I want to put the ImageIcon in to the JLabel with the further intent of displaying it.

lblBig(imgIcoVett[i]);

In this project I'm dealing with arrays of ImageIcons and JLabels, so it's a bit advanced level for me, so I'm not sure that I wrote right the part of the MouseListener too.

The error displayed by netbeans says "cannot find symbol symbol: method lbl (ImageIcon) local variables referenced from an inner class must be final or effectively final"

Here I attach the project I did with netbeans"AAAD Unlayout 2.zip", but if you just need the highlight of the code, here it is too:
 
private javax.swing.JButton btnOpenfile;
private javax.swing.JFileChooser jFileChooser1;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel lblBig;
private javax.swing.JPanel panelGrande;
private javax.swing.JPanel panelPreview;

[Code] ....

View Replies View Related

Get Text From TextField To A Label But Label Is On Different Frame

Nov 18, 2014

I need a code to get a text from a textField to a label but the label is on a different frame, i will give u an example of what i have so far. so this is the main:

package albaestate;
public class AlbaEstate {
public static void main(String[] args) {
Frame1 first = new Frame1();
first.setVisible(true);
}

/*[B]now i have the first frame where i input the information[/B]*/
 
package albaestate;
public class Frame1 extends javax.swing.JFrame { 
public Frame1() {
initComponents();

[Code] ....

What i need is to input the code so that in jLabel5 i get the text from jTextField1 in Frame1; in jLabel6 i need the text from jTextField2 also in Frame1; and in jLabel7 i want to display the calculation of what the jbutton1 in Frame1 is calculating.

View Replies View Related

Swing/AWT/SWT :: Image Manipulation - Create Application Where Image Is Displayed On One Label

Apr 7, 2014

Sir, I'am new to Swing Programming. I have to create an application where an image is displayed on one Label. The same image has to be split in parts and stored in database pert wise. Later the user has to retrieve the entire image by viewing a small part of the image. I have already displayed the full image on the Label, now i don't know how to split the image and store it part wise in the database.

View Replies View Related

Making Letter Bounce Off Of The Edges Of Frame

Jan 9, 2015

I am trying to make a letter bounce off of the edges of the frame, but im stuck .

Java Code:

import javax.swing.*;
import java.awt.*;
public class MainProgram extends JFrame{
public static void main(String[] args) {
// TODO Auto-generated method stub
MainProgram frm = new MainProgram();
frm.setTitle("Moving a letter");

[Code] ....

View Replies View Related

Image Print In Poor Quality With Jagged Edges

Apr 14, 2014

I'm trying to print (to the printer) a small image 265x35 px and it is printed in very poor quality with jagged edges. When I'm printing it from any other program (e.g. Word, mspaint, etc) it is printed clearly.

Also, the image is printed bigger than it's normal size (approximately 25%). But, I'm not doing any scale in my code. I did scaled it down to the right size, but the quality still remained very poor and jadged.

The image is a transparent PNG file. I tried with a BMP too, but I got the same results.

I'm using

Graphics g;
g.drawImage(headerLogo, x, y, headerLogo.getWidth(), headerLogo.getHeight(), imageObserver);

View Replies View Related

Compare Two Files And Count New Edges For Each Node And Their Total

Jan 28, 2015

How can I do this: program to compare two files that which has data like node id: which it is connected to. like 3: 5 7 12 5: 7 14 9 etc. so this type of content is there in both the files. I need to compare these two files and count new edges for each node and also total new edges.

How can I do this? I tried and learnt taking files as input and read the normal text content.

This is what I tried :

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package comparetwofiles;
import java.io.*;
import java.util.*;
 
[Code]...

View Replies View Related

Type Name And Get Histogram - Getting NullPointerException

Dec 10, 2014

I recently switched some of code around to restructure how some things were working but now when I run the program I am getting a NullPointerException in multiple areas. I suspect it may have something to do with a constructor. I am very new to "object" - ish based programming.

I figured I should give a little background on the program, this program is reading from a text file of names and decade numbers(for each name) and storing each line into an object array. From there, there are menus and based on the users decision they can type a name and get a histogram, compare names with histograms, ect. Below this main method, I have provided the area where I have gotten the null pointer exception.

Here is the main method for the Client "nameApp"

Also excuse the formatting and curly braces for now!

public class NameApp{

private static boolean validInput;
private static boolean done = false;
private static boolean validDecade;
private static boolean validName;

[Code] ....

And here is the method in the same Client that is getting the null pointer exception:

The pointer exception is on line 6 which is:

if (nameInput.equalsIgnoreCase(list[i].getName())){
private static int checkListArray(String nameInput, Name[] list){
int nameLocation = -1;
int listLength = list.length;

[Code] ....

View Replies View Related

Making A Rain Histogram

Mar 10, 2014

I prompted the user to enter inches of rainfall for seven days and stored them in an array. Now, I am trying to display a histogram of this data using a nested loop, but for each inch, I have to display a * like this:

Rainfall Histogram:
****
***
**
******
********
**********
**

The only way I know how to display a number of *s according to user input is by an if statement. I copied and pasted from a similar class assignment I did, so what I have so far is pretty messy and nonsensical:

static char DetermineRainfall(int inches)

System.out.println("Histogram");
//char inches;
for(inches = 0; inches < 7; inches++)
{
for(int j = 0; j < 1; j++)
{
if (rainamount > .9 && rainamount <= 1)
inches = '*';
return inches;
}
}

View Replies View Related

Histogram Not Reading Input File

May 1, 2015

The following program should read in a file on my desktop (I have the path set in Netbeans to that location) and produce a Histogram. Instead I am receiving this error.

Exception in thread "main" javax.imageio.IIOException: Can't read input file!
at javax.imageio.ImageIO.read(ImageIO.java:1301)
at Histogram.main(Histogram.java:9)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

Here is the code for the Histogram:

import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
public class Histogram {
public static void main(String[] args) throws Exception {
int[][][] ch = new int[4][4][4];

[code]...

Why it's not reading the file?

View Replies View Related

Histogram That Allows To Visually Inspect Frequency Distribution Of A Set Of Values

Apr 4, 2014

Design and implement an application that creates a histogram that allows you to visually inspect the frequency distribution of a set of values . The program should read in an arbitrary number of integers that are in the range 1 to 100 inclusive; then produce a chart similar to the one below that indicates how many input values fell in the range 1 to 10, 11 to 20, and so on. Print one asterisk for each value entered.

No input prompt

Terminate input by typing CTRL/Z (two keys typed at the same time) on a separate input line (use CTRL/D on Linux/UNIX systems)

Use hasNextInt() to terminate your input

Format as below (slightly different from the text example)

Z:dbraffittWeek10> javac Histogram.java

Z:dbraffittWeek10> java Histogram

10 10 10 10 10 20 20 20 20 20 20

20 25 35 45 55 65 75 85 95

ctrl/z

1 - 10 | *****

11 - 20 | *******

21 - 30 | *

31 - 40 | *

41 - 50 | *

51 - 60 | *

61 - 70 | *

71 - 80 | *

81 - 90 | *

91 - 100 | *

What I can not figure out is how to use hasNextInt() to terminate the loop. How to not have an input prompt. How to use ctrl z to terminate the input. Or to make it where it doesn't involve range values like -1.

Java Code:

import java.util.Scanner;
public class Histogram
{
public static void main (String[] args)
{
Scanner scan = new Scanner (System.in);
int [] nums = new int[101];

[Code] ....

View Replies View Related

JavaFX 2.0 :: Is It Possible To Create Dynamic GUI?

Jul 7, 2014

I'd like the GUI to be drawn based on definition file. Is it possible to "generate" fxml (like PHP does html) so I could do this:
 
for (...) {
     command_to_generate (<button ....>);
}
 
?

Or is using legaxy javaFX code the only way to achieve it?

View Replies View Related

How To Create A Dragable Triangle With JavaFX

Nov 6, 2014

I'm trying to make a triangle that plots the point in where the corners show their position in the window and also that the user may drag each corner to a desired position.

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.scene.input.MouseButton;
import javafx.scene.shape.Polygon;
import javafx.scene.shape.Shape;

[code]....

View Replies View Related

Create Compound Shapes / Paths In JavaFX?

Apr 28, 2015

Is there some way to create compound shapes/paths in JavaFX?

For the record I'm not implying the use of the methods intersect, subtract, or union. These produce other shapes. A compound shape/path is one that has a knockout of some sort. For instance, a circle within a circle, such as in a 2d donut shape. Alternatives do not include a circle with a thick stroke nor an overlayed circle with the background color. Specifically, JavaFX supports the FillRule, in the case of the Path object. However, there doesn't appear to be an "add" method as there was in the Area shape in Swing.

View Replies View Related

JavaFX 2.0 :: Create Button Bar The Same As Confirmation Dialog

May 1, 2015

I want to create a button bar that is the same as the confirmation dialog button bar -- so an OK and cancel button layed out in the platform specific way, and with the same styling.
 
I have made some progress via a hack -- create an alert dialog, and extract the buttons in the dialog using lookupButton, and then put those buttons in a toolbar. But this doesn't necessarily get a toolbar with the buttons in the correct order. If I could get the button bar out of an alert dialog I would have a solution, but I can't see to do that.

View Replies View Related

JavaFX 2.0 :: Create List Of Entities - Multi-row Tableview?

Apr 10, 2015

I would like to create list of entities which is populated by a search function with the data coming from our REST webservice. However I would like it to be multi-line, with the first line being details from the entity itself and the second line buttons for options that can be performed.
 
So as an example say my entity is People, the first line would contain columns for first name, last name, gender, DOB, etc. The second line would be buttons for "Edit Person", "Print Person details".   With the standard TableView I can't see anyway to alternate between one row of data and another row of buttons.

View Replies View Related

JavaFX 2.0 :: TabPane - Create Pagination With No Page Control?

Nov 5, 2014

TabPane and Pagination controls.  However, I would like to be able to create a vertical toolbar that controls page or tab display.

Is it possible to create a Pagination with no page control?  Or is my guess of sizing the Pagination control so that the lower section is off of the displayed window, thus hiding the page info? Or, is it possible to create a TabPane with panels, but no tabs?

View Replies View Related

JavaFX 2.0 :: Why Does Scene Builder Constantly Create New Instances Of Nodes

Nov 28, 2014

I thought I had a simple idea for creating a control that would let me get some of the behavior of a card pane.  This is the entire control:
 
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.Node;

[Code] ....
 
The idea is pretty simple; extend StackPane, add an active property, bind the visible and managed properties of the pane to the active property, and, whenever the active property is changed to true, iterate sibling nodes de-activating any siblings that are also of the type Card.
 
However, this doesn't work with Scene Builder.  While trying to debug, I created an ExtStackPane:
 
import javafx.collections.ListChangeListener;
import javafx.scene.Node;
import javafx.scene.layout.StackPane;
public class ExtStackPane extends StackPane {
    {
        getChildren().addListener((ListChangeListener<Node>) c -> {
            System.out.println("ExtStackPane children change: " + c.toString());
        });
    }
}
 
All this does is log list change events.  However, I was very surprised by the output when working in Scene Builder.  I added both controls to Scene Builder and did the following:
 
0) Added an ExtStackPane
1) Added a Card to the ExtStackPane
2) Added another Card to the ExtStackPane
3) Added a Label to the first Card
4) Added a Label to the second Card
5) Changed the text of the first Label to Hello
6) Changed the text of the second Label to World
7) Set the first Card to active
8) Set the second Card to active
 
I get the following output:
 
1)
ExtStackPane children change: { [Card@5b9067b3] added at 0 }

2)
ExtStackPane children change: { [Card@6b6328bd] added at 0 }
ExtStackPane children change: { [Card@6aca8cc5] added at 1 }

[Code] ....
 
This is what things look like in Scene Builder:
 
Does Scene Builder recreate the entire hierarchy every time I make a small change?  Here's an application that does the same as the manual steps I performed in Scene Builder:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
public class CardApplication extends Application {

[Code] ....

The output when running the above is:

1)
ExtStackPane children change: { [Card@6dfaa767] added at 0 }

2)
ExtStackPane children change: { [Card@6aa2c411] added at 1 }

[Code] ....
 
The behavior is obviously a lot different than when I'm working with the control in Scene Builder. What Scene Builder is doing to change the behavior of my Card control so much?  Does my Card control break some rule(s) I'm not aware of?

View Replies View Related

JavaFX 2.0 :: Create Implementation Of Service Class That Runs On Particular Time Everyday

Jun 23, 2014

I tried using ScheduledService but  the delay and period fields accepts a Duration object. I want the Service to run at exactly 6.00 pm everyday.

View Replies View Related

JavaFX 2.0 :: How To Create Off Screen Images By Canvas In Multi-thread Environment

Feb 25, 2015

I want to create off-screen images by Canvases in multi-thread environment.
 
I know that I use methods of GraphicsContext2D to draw on Canvas. Can I do this on Canvas which is not added to Scene ?
 
How can I get an image from a canvas after I invoke GraphicsContext2D methods? Can I get images in multi-thread environment ?

View Replies View Related

How To Put A Label

Dec 12, 2014

I can't seem to put a label on this code:

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class number2 extends Frame {
int x = 0;
int y = 0;
public void run() {
addMouseListener(new mymouselistener());

[code]....

how would I put a label on it?

View Replies View Related

Unable To Add Label To GUI

Apr 17, 2014

I am trying to add a label to my gui, i am using the following code but it is not showing.

contentPane = this.getContentPane();
contentPane.setBackground(Color.GREEN);
contentPane.setLayout(null);
JLabel greeting = new JLabel("hello");
greeting.setFont(new Font("SansSerif", Font.PLAIN, 18));
contentPane.add(greeting);
greeting.setVisible(true);

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved