Question

Re-write this program into a javafx program, using javafx components only. NO awt or swing. import...

Re-write this program into a javafx program, using javafx components only. NO awt or swing.

import java.awt.Button;

import java.awt.Label;

import java.awt.TextField;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JFrame;

import javax.swing.JPanel;

public class DecimalBinary {

public static void main(String[] args) {

JFrame frame=new JFrame(); //Create a frame

frame.setTitle("Decimal-Binary Converter"); //Set its label

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setSize(300, 300); //Set size fo frame

JPanel panel=new JPanel(); //Create a panel to contain controls

frame.add(panel); //add panel to frame

panel.setLayout(null);

Label decimalLabel=new Label("Decimal"); //Create label for decimal

decimalLabel.setBounds(10, 10, 60, 20); //Set position (x,y) and width,height

Label binaryLabel=new Label("Binary"); //Create lable for binary

binaryLabel.setBounds(10, 30, 60, 20); //Set position (x,y) and width,height

TextField decimalArea=new TextField(20); //Create textfield for decimal number

decimalArea.setBounds(100, 10, 150, 20); //Set position (x,y) and width,height

TextField binaryArea=new TextField(20); //Create textfield for binary number

binaryArea.setBounds(100, 30, 150, 20); //Set position (x,y) and width,height

Button button=new Button("Convert"); //Create button to initiate conversion

button.setBounds(70, 70, 50, 20); //Set position (x,y) and width,height

//Add all the conrols to panel

panel.add(decimalLabel);

panel.add(decimalArea);

panel.add(binaryLabel);

panel.add(binaryArea);

panel.add(button);

frame.setVisible(true);

//Add action listener to button, to handle click event

button.addActionListener(new ActionListener(){

@Override

public void actionPerformed(ActionEvent e) {

// Store entered decimal number in variable decimal

int decimal=Integer.parseInt(decimalArea.getText());

int remain=0;

String binary=""; //Variable to hold binary number

//Create a loop to go through each digit of number and find out remainder

//on division by 2. This remainder will be added to output.

while(decimal>0){

remain=decimal%2;

decimal/=2;

binary=remain+binary;

}

//Set result on binaryArea

binaryArea.setText(binary);

}

});

}

}

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Re-write this program into a javafx program, using javafx components only. NO awt or swing. import...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • I am getting this Error can you please fix my Java code. import java.awt.Dialog; import java.awt.Label;...

    I am getting this Error can you please fix my Java code. import java.awt.Dialog; import java.awt.Label; import java.awt.TextArea; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map.Entry; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class Fall_2017 {    public TextArea courseInput;    public Label textAreaLabel;    public JButton addData;    public Dialog confirmDialog;    HashMap<Integer, ArrayList<String>> students;    public Fall_2017(){    courseInput = new TextArea(20, 40);    textAreaLabel = new Label("Student's data:");    addData = new JButton("Add...

  • Add a timer to the lightbulb ON/OFF program such that the bulb stays on for 10...

    Add a timer to the lightbulb ON/OFF program such that the bulb stays on for 10 seconds after the ON button is pushed and then goes off.   Put a new label on the lightbulb panel that counts the number of seconds the bulb is on and displays the number of seconds as it counts up from 0 to 10. THIS IS A JAVA PROGRAM. The image above is what it should look like. // Demonstrates mnemonics and tool tips. //********************************************************************...

  • import java.awt.*; import javax.swing.*; import java.awt.event.*; import javax.swing.BorderFactory; import javax.swing.border.Border; public class Q1 extends JFrame {...

    import java.awt.*; import javax.swing.*; import java.awt.event.*; import javax.swing.BorderFactory; import javax.swing.border.Border; public class Q1 extends JFrame {    public static void createAndShowGUI() {        JFrame frame = new JFrame("Q1");        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        Font courierFont = new Font("Courier", Font.BOLD, 40);        Font arialFont = new Font("Arial", Font.BOLD, 40);        Font sansFont = new Font("Sans-serif", Font.BOLD, 20);        JLabel label = new JLabel("Enter a word"); label.setFont(sansFont);        Font font1 = new Font("Sans-serif", Font.BOLD, 40);       ...

  • This is all I have regarding the question import java.awt.*; import java.awt.event.*; import javax.swing.*; public class...

    This is all I have regarding the question import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Quiz8_GUI { private JFrame frame;    /** * Create an Quiz8_GUI show it on screen. */ public Quiz8_GUI() { makeFrame(); } // ---- swing stuff to build the frame and all its components ---- /** * Create the Swing frame and its content. */ private void makeFrame() { frame = new JFrame("Quiz8_GUI"); makeMenuBar(frame); Container contentPane = frame.getContentPane(); //set the Container to flow layout //Your...

  • In Java Swing, in my ButtonHandler class, I need to have 2 different showDialog messages show...

    In Java Swing, in my ButtonHandler class, I need to have 2 different showDialog messages show when my acceptbutton1 is pressed. One message is if the mouse HAS been dragged. One is if the mouse HAS NOT been dragged. /// I tried to make the Points class or the Mouse Dragged function return a boolean of true, so that I could construct an IF/THEN statement for the showDialog messages, but my boolean value was never accepted by ButtonHandler. *************************ButtonHandler class************************************...

  • Write a program that will define a runnable frame to have a ball move across the...

    Write a program that will define a runnable frame to have a ball move across the frame left to right. While that is happening, have another frame that will let the user do something like click a button or input into a textfield, but keep the ball moving in the other frame. When the ball reaches the right edge of the frame or when the user takes action - enters in textfield or clicks the button, end the thread. The...

  • JAVA problem: Upgrade and extend the previous programs Draw.java and DrawCanvas.java used in the class to...

    JAVA problem: Upgrade and extend the previous programs Draw.java and DrawCanvas.java used in the class to maintain a list of shapes drawn as follows: Replace and upgrade all the AWT components used in the programs to the corresponding Swing components, including Frame, Button, Label, Choice, and Panel. Add a JList to the left of the canvas to record and display the list of shapes that have been drawn on the canvas. Each entry in the list should contain the name...

  • I have been messing around with java lately and I have made this calculator. Is there...

    I have been messing around with java lately and I have made this calculator. Is there any way that I would be able to get a different sound to play on each different button 1 - 9 like a nokia phone? Thank you. *SOURCE CODE* import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; class Calculator extends JFrame { private final Font BIGGER_FONT = new Font("monspaced",Font.PLAIN, 20); private JTextField textfield; private boolean number = true; private String equalOp = "="; private...

  • Please fix and test my code so that all the buttons and function are working in...

    Please fix and test my code so that all the buttons and function are working in the Sudoku. CODE: SudokuLayout.java: import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JTextField; public class SudokuLayout extends JFrame{ JTextArea txtArea;//for output JPanel gridPanel,butPanel;//panels for sudoku bord and buttons JButton hint,reset,solve,newPuzzel;//declare buttons JComboBox difficultyBox; SudokuLayout() { setName("Sudoku Bord");//set name of frame // setTitle("Sudoku Bord");//set...

  • I started this but need to convert it using JavaFX import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage;...

    I started this but need to convert it using JavaFX import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.awt.Font; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class ArtProject { public static void main(String[] args) throws IOException { /*this will be the size of the rectangle background with circles inside the image*/ int width = 400; int height = 250; int circleWidth = height; //create an image object BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D g2d = bufferedImage.createGraphics(); //this sets the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT