So I am making a responsive audio waveform, if you don't know what that is, it is something like this: (btw this is my goal to make those audio waveforms). https://i.ytimg.com/vi/J7uN-SQtOYI/maxresdefault.jpg https://www.youtube.com/watch?v=OVMuwa-HRCQ https://www.youtube.com/watch?v=SCD2tB1qILc I don't know how to describe it, so just look at the videos and image. but my question is, how do I get the values from the "AudioSpectrumListener", it has a lambda expression. And I need the value of the magnitude. So I can print out the values. Later I will use the values to make rectangles and that rectangles will change height shape because of the …

Member Avatar
Member Avatar
+0 forum 17

So, I made a simple server-client chat program, but I have a problem: if the server tries to message the client, the server lags or freezes a bit, same with the client. is there something that I do wrong? import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.TextArea; import javafx.scene.control.TextField; import javafx.scene.paint.Color; import javafx.stage.Stage; public class Server extends Application { private Group serverGR; private Scene serverSC; private Stage window; private TextField tf; private TextArea ta; private ServerSocket ss; private Socket s; private DataInputStream dis; private DataOutputStream dos; ConnectionThread cT = new …

Member Avatar
Member Avatar
+0 forum 12

I am making a program, and I don't know why my program becomes unresponsive, when I click the button ): I have a feeling its because of this: "connection = server.accept();" I don't know how to fix it. I am trying to recreate this: https://stackoverflow.com/questions/18505123/how-to-use-client-chat-on-different-pc but in javafx. package yeetYeet; import java.io.EOFException; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.ServerSocket; import java.net.Socket; import javafx.animation.AnimationTimer; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.TextArea; import javafx.scene.control.TextField; import javafx.scene.paint.Color; import javafx.stage.Stage; public class Server extends Application{ private ObjectOutputStream output; private ObjectInputStream input; private ServerSocket server; private Socket connection; //set up and …

Member Avatar
Member Avatar
+0 forum 16

When we build an application, which layer should we start with? From top (UI) to bottom(Data Layer) or bottom to top?

Member Avatar
Member Avatar
+1 forum 6

Hello. As a personal project, I am trying to create a "Java Argot" translator. However I am having some issues. The purpose of the program is to translate a sentece into the following "Secret Languages": "Pig Latin", "Leet" and "Morse Code". I have only done the "Pig Latin" translator however, everytime I try to activate case one in the "switch case" I get the error message "Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0". The program shows that the line of code that is sending this message is these two lines: "`PigLatin_Translator.main(word);`" in the "Translator Menu" and …

Member Avatar
Member Avatar
+0 forum 17

When posting code, I get error > begin a line with 4 spaces in a row (or one tab), preceded by a blank line. 4+ spaces or tabs may not be used anywhere else.

Member Avatar
Member Avatar
+0 forum 8

Are there any differencies between these two code ? if (!a.equals("")) { editDate.setText(a) } and if (a!="") { editDate.setText(a) }

Member Avatar
Member Avatar
+1 forum 2

Hi. I'm trying to create a Traffic simulator and I'm stuck on how to get a Car object to turn into a road. I've managed to have a car go straight (which is really easy anyway lol) but I can't really find a way to get it to turn into a road, specifically a left turn. The code I have currently is this: [CODE]import java.applet.*; import java.awt.*; import java.awt.geom.AffineTransform; public class Traffic3 extends Applet implements Runnable { //thread variables Thread t; int i; //double buffer variables Image offscreenImage; Graphics offscr; int width; int height; //car //coordinates for lanes //south road, …

Member Avatar
Member Avatar
+0 forum 10

Hi guys, I seem to have an issue with a boolean method returining a value. Here is the code excerpt - irrelevant code omitted: public class StreamsTest { public static void main(String[] args) { String[] arr = new String[]{"a", "b", "c"}; //convert array to string with streams List<String> list = Arrays.stream(arr).collect(Collectors.toList()); isElementInIt(list); } static boolean isElementInIt(List<String> list) { if(list.isEmpty()) { return false; } else { for (String string : list) { if (string.contains("a")) { return true; } else { return false; } } } } } STS says that the isElementInIt method should return a boolean value, but it's already …

Member Avatar
Member Avatar
+0 forum 2

//With this method, I input a string and return an array that contains a sorted list of characters as per the frequency. Eg: If i input "apple", the out put should be p,a,l,e, How do I do this? public static ArrayList<Character> characterFreqDist(String statement) { char[] Array = statement.toCharArray(); int length = Array.length; int most_frequent_count = 0; char most_freq_character = '\0'; char[] Final_Array = new char[length]; ArrayList<Character> Sorted_Array = new ArrayList<Character>(); for(int loop = 0 ; loop<length ; loop++) { most_freq_character = '\0'; most_frequent_count = 0; for(int i = 0; i<length ; i++) { char single_character = Array[i] ; int counter …

Member Avatar
Member Avatar
+0 forum 5

Hi, how do I sort the string in alphabetical order? find most occuring character("blablabla") remove most occuring("aaa") input: blablabla output: "aaa"

Member Avatar
Member Avatar
+0 forum 1

Hi guys so I was playing with some code which would determine the whether a string is a palindrome or not. Its been a mixed bag of results with some palindromes being detected while others aren't. I do apologize to the lack of polish of my comments but I hope that someone might be able to see where the error is and give me good feedback. I think the error is in the set of code that removes the special characters from the string. As a reference, I am using this webiste: http://www.palindromelist.net/ as the source for the palindrome strings. …

Member Avatar
Member Avatar
+0 forum 7

# Lab Assignment # We must create a program that will print a sorted list of all the students and the corresponding scores listing the highest score first and the lowest score last. In this case I would need a Bubble Sort. ## Question ## This is my "Bubble Sort" method shown in the code block below. public static void bubbleSort(String [] name, double [] score) { double temp; int counter; int index = 0; for(counter = 0; counter < score.length - 1 - counter; index++) { if(score[index] > score[index + 1]) { temp = score[index]; score[index] = score[index + …

Member Avatar
Member Avatar
+0 forum 6

# Lab Question# We must create a program that do the following: Allow the user to type in a student name the coorosponds with the student's exam score. The program will be able to accpet exam scores till the user types in the phrase "allDone". The code will determine which student has the highest score and give the name and the score to the user. Here is an example of what will be shown in the console.... *Sample Input* Bob 82 Mary 90 James 87 alldone *Sample Output* Mary has the highest score. Her score is: 90. ## Question ## …

Member Avatar
Member Avatar
+0 forum 6

Hi, something weird happened with my program, I mean when I run it I see only grey frame (like I had only JFrame object in my app), then I minimalize application, maximalize it and only then I see all components painted (JButton, rectangels and lines inside Jpanel,...). Changing of frame size helped too, but now I have fixed size, so this is not anoption. Can you tell me what can cause that behaviour. This is class which draw everything: public class Simulation{ JFrame frame; JPanel background; RoadSystem roads; Stats stats; Settings settings; JButton startButton; public Simulation() { frame = new …

Member Avatar
Member Avatar
-1 forum 2

I need to create a class that represents one crayon of a particular color and height(length). Then, I need to design an applet that lets me draw a box of different colored crayons. This is what I have so far: **CLASS:** import java.awt.*; public class Crayon { private final int BOTTOM = 150; private final int WIDTH = 25; private Color color; private int length, location; //---------------------------------------------------------------------------------------------- // Crayon's characteristics. //---------------------------------------------------------------------------------------------- public Crayon (Color color, int length, int position) { color = color; length = length; location = position; } //---------------------------------------------------------------------------------------------- // Draws crayon. //---------------------------------------------------------------------------------------------- public void draw (Graphics page) …

Member Avatar
Member Avatar
+0 forum 5

Is there any method in java to generate random number (integer, byte or float) ? Please tell me if any i need it in my program. If possible please give full example. Thanks!

Member Avatar
Member Avatar
+0 forum 1

Howdy All - I am just wondering if anyone has successfully converted a *massive* (subjectivity implied) COBOL application to another language. If so, into which language was your system converted and when was this done? What were the potholes you, no doubt, hit? Was the conversion far more expensive than anticipated? What hidden costs were exposed? Was there a performance gain/loss in the new language? Did anyone convert from COBOL to PL/SQL? to T-SQL? to Java? to C#.NET? Thanks, and have a great day!

Member Avatar
Member Avatar
+0 forum 10

I have a program that is meant to display the total, average, student name and letter grade for a student. I'm almost done writing it but I have no idea how to make it loop so it goes back to step 1 from step 4. Everything I've read on using "while" loops hasn't really been helpful to me with this particular application. import java.util.Scanner; public class Averages5 { public static void main(String[] args) { // variable declaration String name; int mark1, mark2, mark3 ; int grade = 0; int A, B, C, F; double average; // input Scanner input = …

Member Avatar
Member Avatar
+0 forum 2

The API docs are now found at [ Java Development Kit Version 11 API Specification](https://docs.oracle.com/en/java/javase/11/docs/api/)

Member Avatar
Member Avatar
+0 forum 3

Hi all, I need to read a text file (I've attached it, you can take a look), and then store all the numbers in it into a 2D array. After which, I need to parse it. I need urgent help here! ):

Member Avatar
Member Avatar
-2 forum 49

Question from codility test Write a function: class Solution { public int solution(int[] A); } that, given an array A of N integers, returns the smallest positive integer (greater than 0) that does not occur in A. For example, given A = [1, 3, 6, 4, 1, 2], the function should return 5. Given A = [1, 2, 3], the function should return 4. Given A = [−1, −3], the function should return 1. Write an efficient algorithm for the following assumptions: > > N is an integer within the range [1..100,000]; > each element of array A is an …

Member Avatar
Member Avatar
+0 forum 8

I have class with main method like: public class Main { public static void main(String[] args) { long timeCheck; long periodOfTime; ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(2); long initialDelay = 0; // the time from now to delay execution long period = 1; // the period between successive executions scheduler.scheduleAtFixedRate(new FeedReader(img, url, title, price), initialDelay, period, TimeUnit.DAYS); ... ... } } and another class with some code: public class FeedReader implements Runnable { private String img; private String url; private String title; private String price; public FeedReader(String img, String url, String title, String price) { this.img = img; this.url = url; this.title …

Member Avatar
Member Avatar
+0 forum 8

I am trying to display this SQL query in a table. String query = "SELECT COUNT(`appointmentId`),EXTRACT(MONTH FROM `start`) FROM `appointment` WHERE YEAR(start) = '" + year + "' GROUP BY EXTRACT(MONTH FROM `start`)"; Unfortunately I cannot alter the database. I am trying to list the total appointments per month on a table or perhaps a TextArea. Any ideas please? Thanks!

Member Avatar
Member Avatar
+0 forum 2

All, For the life of me I cannot get this program to compile. The error message "error: non-static variable this cannot be referenced from a static context" occurs on lines 23 and 24. Here is the entire program: [CODE]public class ThreadTest { public static int x = 0; public class Counter implements Runnable { private int i; private int temp; public void run() { for (i=0; i<10; i++) { temp = x + 1; x = temp; } } //End run() } //End class Counter public static void main (String[] args){ Counter myCounter1 = new Counter(); Counter myCounter2 = new …

Member Avatar
Member Avatar
+0 forum 9

Hi Guys, I ussually dont post anything here often, just get everything off of everyone elses questions, but I'm having a strange problem that im scratching my head over, I have a JTable where I can Add and remove rows... This is just for testing purposes, I'm about to make a ingrediants program. The thing is whenever I change one of the Comboboxes they all seem to change.. its really wierd, Could Someone run this and help me out, this is probably a stupid mistake? See my Code Below, My Main package doughtracker; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; /** * * …

Member Avatar
Member Avatar
+0 forum 13

Hey guys, I have a little bit confused on below code and output **Main ** public class Main { public static void main(String[] args) { ClassA classA = new ClassA(); System.out.println("====== Before ====="); classA.checking(); System.out.println("===== After ====="); classA.checking(); } } ** Class A** public class ClassA { boolean b = true; public String checking() { System.out.println("B value is " + b); if (b = true) { System.out.println("B is true"); b = false; } else { System.out.println("B is false"); } return null; } } ** Output** ====== Before ===== B value is true B is true ===== After ===== B value …

Member Avatar
Member Avatar
+0 forum 4

I have to print some text to printer. I needed to translate that text in Urdu language also. For that I used google translation API and all was set. But I am facing problem in order of output. // this is the code which is giving my desired output String text = "Honda head light large size" String translatedText = GoogleTranslate.translate("ur", text); String myString = "Saboor" String printString = String.format("%-15s %-15s %-10s",text,translatedText,myString); graphics.drawString(printString,x,y) //Above code is giving me correct output as following Honda head light large size urdu translation Saboor // Now pasting the code which create problem: String text …

Member Avatar
Member Avatar
+0 forum 1

Guys, Ive gotten it into my head to do somthing fairly difficult for me, I want to communicate with a swing application, to a proximetly sensor, and track live when it senses somthing and how many times it has sensed somthing, I want to use java. theres alot more to it than this, eventually connect a multitude of sensors, temperture, photo eyes, etc, I want to recieve these signals wirlessly as i want to see it on my office computer, and the sensors with be in another room, How would I get started with this? Treat me like a noob, …

Member Avatar
Member Avatar
+0 forum 3

Hey guys! help me out, i'm really out of ideas, how can i save the datas i inputed to have a rotation of value , like the computation in the withdraw, when i 1st use the withdraw or deposit, it computes, yes but when the 2nd time i use it, it still on 10000 value. heres my codes (sorry not my native language) /* * 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 bank; import java.util.Scanner; /** …

Member Avatar
Member Avatar
+0 forum 4

The End.