Hack Forums
[Java] Sorting Algoritm DrawString Problems - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Java] Sorting Algoritm DrawString Problems (/showthread.php?tid=5833809)



Sorting Algoritm DrawString Problems - xpgbeast - May 7, 2018

Hello,

Just started my journey learning programming languages and i am kinda stuck on 1 part of the book.

The problem : I have to create a GUI with JPanel/JFrame with 3 JTextFields and 1 button.
With this i have to make sure that whatever number i fill in to those JTextFields get to be sorted from highest to lowest by drawString output underneath the JTextFields.
Could anyone help me out understand this piece of code so that i could use these things in the right context and figure out how to make the program print out those values in the right order.

Thank you for helping!


bumperrrrrr bumperrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr


bumperrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr


RE: Sorting Algoritm DrawString Problems - Vanagander - May 7, 2018

Well what have you tried so far?
In short, take the input and compare it to any existing numbers and then show the sorted numbers. Which part are you stuck on?


RE: Sorting Algoritm DrawString Problems - Sheeple - May 7, 2018

I wouldn't focus on the GUI part of coding for right now.


RE: Sorting Algoritm DrawString Problems - deluxe - May 8, 2018

Never heard of drawString, but you can just use setText() method to set the text in the right order after pressing the button. So you have to add an eventlistener when the button is pressed and the parse Integers out of the textfields string output and then put them in the right order. Maybe but the numbers into a list and sort it and then output it to the textfield. But like Sheeple said you should stick to the console programming. I promise you that its way better to get started to code just by making the console applications. I just finished one course which was 14 weeks long. Never coded java before. And after 11 weeks i got only touch with the gui stuff. I still prefer console applications over GUI ones.