Posts by Gustavo Fragoso • 2,321 points
112 posts
-
1
votes1
answer59
viewsA: Doubts when applying a DAO method
Usually the login validation is done in the database, it is not a good practice to store in your memory a list of users with login and password not encrypted. I’d do it this way: String sql =…
-
1
votes2
answers644
viewsA: Observable List in a list View Javafx
You are setting up Tableview again every time you call the updateTable method. In fact, if you define an Observablelist, using the method setItems of your Tableview, the changes in the former…
-
0
votes1
answer287
viewsA: Change the content value of a javafx tableview line
You can perform a Join between tables to show names instead of codes and pass this change to your code. Let’s assume your table is this way (Sqlfiddle), then select below produces the result: select…
-
0
votes2
answers80
viewsA: How to Recover Data from a Datepicket Add to Mysql/JPA Database
According to this source, JPA 2.1 does not natively support the new Date and Time API introduced with Java 8. The author’s explanation is as follows: The Answer is simple, JPA 2.1 was Released…
-
0
votes1
answer594
viewsA: Javafx Tableview setting values to Tablecolumn
I suppose the structure of your Seller class is as follows: public class Seller { private String sellerName; private Departamento department; public Seller(...) { department = new…
-
0
votes1
answer59
viewsA: Problems with Thread in Javafx
I believe the problem is in changing the combobox items you are doing, let’s try to use a ObservableList. Attributes: private ObservableList<String> items; private Service<Void> service;…
-
6
votes3
answers425
viewsA: Is it mandatory to put the same attributes on different constructors?
Has a very common practice that is used in these situations: use the keyword this(), that represents the constructor of the class itself, and fill in the most generic constructor with default…
-
0
votes3
answers658
viewsA: Javafx: Location is required
It’s just a confusion in using the getResource method, see the examples: Resource in the same package: FXMLLoader.load(getClass().getResource("arquivo.fxml")); Feature in different package: //…
-
0
votes1
answer254
viewsA: Progressibar using Threads and Scenebiulder
The correct way to mark progress in Javafx is by using a bind in conjunction with the methods updateProgress/updateMessage. See the example below: Task<Void> tarefa = new Task<Void>() {…
-
1
votes2
answers926
viewsA: Recursive function to calculate the number of lowercase letters in a character string
Your code is quite confusing for a recursive solution. To solve the problem we have done the following: We adopt as a stop condition a text of size 1; If Character is uppercase returns 1, otherwise…
-
1
votes1
answer221
viewsA: Text encoding for RTF in java
ANSI is a normalization, in fact the code 1252 is associated with charset Windows-1252. You can associate a charset to your Bufferedreader in this way: BufferedReader br = new BufferedReader(new…
-
4
votes2
answers920
viewsA: Recursiveness: Compute the sum of the first positive odd values starting at 5
I got the solution by following the following reasoning: Every odd number is generated by the formula 2*n + 1; The base case of the recursion is f(0) = 5 (must start from 5); With these hypotheses…
-
1
votes1
answer230
viewsA: Tableview bring date, mysql database
I believe it is a problem when converting dates. I will suggest that you use the new Java 8 Date API Localdate/Localdatetime. Java.sql.Date comes with a method called toLocalDate() that you can use.…
-
0
votes1
answer385
viewsA: How to add a calendar in Frame or Panel in Java
Basically you will have to implement a dayCellFactory, this will allow you to manipulate how calendar cells will be rendered. Example of commented documentation: DatePicker dp = new DatePicker();…
-
0
votes2
answers138
viewsA: Implement Paint in Javafx
The code below has been adapted from the following solution, with some amendments. private ColorPicker colorPicker; private Button drawLine; private Canvas canvas; private GraphicsContext…
-
3
votes2
answers69
viewsA: Search is not performed after connecting to the Java database
Some things should be modified in your code: You are using a Try-with-Resources on conectarBanco(), so at the end of the block execution the connection will be closed implicitly; Try returning an…
-
2
votes2
answers112
viewsA: Grab Scrollpane size when set by anchoring - Javafx
You can use the function getBoundsInParent or getBoundsInLocal. They are functions that calculate node dimensions based on their coordinates. Then use the getHeight() and getWidth() methods (or…
-
0
votes0
answers44
viewsQ: Relationship between performance and scalability
I was facing problems to carry out the maintenance in a code of my own, due to the extensive and little defined classes (grew a lot over time), to simplify the question I will divide the time line…
-
2
votes3
answers1906
viewsA: Decimal to octal conversion
Missing to store the leftovers of the division in some array (inside your Else the value of the octal variable is not changed) and then invert to show the result: #include <stdio.h> void…
-
1
votes1
answer361
viewsA: Java FX - Threading Issues
Your purpose just became clear in your comment above. If you want a loading screen with updates there is an easy way to do this: Label label = new Label("Texto inicial"); Service<Void>…
-
4
votes1
answer888
viewsA: Converting String to Arraylist
May I suggest that you move this data to a csv file and then use the following code: Using a scanner: try { Scanner scanner = new Scanner(new File("src/arquivo.csv")); // Delimitador dos dados…
-
1
votes2
answers301
viewsA: Thread Issues in Java FX
Any changes you make to elements drawn on the screen go through the FX Application Thread, which is only 1 thread. The service class, while interacting well with the FX Application Thread, see some…
-
2
votes2
answers95
viewsA: How to readjust text that is inside a Textflow?
This bug happened because of the multiple internal nodes you have. Although I do not know what kind of panel you are using for chatBox I did some tests using it as Hbox and managed to reproduce the…
-
1
votes1
answer220
viewsA: Modify the indices of each item in a Treeview Java FX or Treeview.getSelectionModel() override method. select(int index)?
I did a little different from your proposal and for me it worked correctly, I will explain step by step as I did: List<TreeItem<Conta>> treeItems = new ArrayList<>(); // Criando…
-
1
votes1
answer1206
viewsA: Textfield Javafx with dynamic monetary value mask
I made a small extension for the Javafx Textfield that formats like a monetary field. I’m using Double in this solution but you can change how it suits you: import java.text.NumberFormat; import…
-
3
votes1
answer83
viewsQ: Possibility of application of design standard
After a login effective in the application I am building I return a boolean[] with all the accesses that the user has. // Armazena o controle de acesso do usuário LoginDAO logindao = new…
-
0
votes1
answer124
viewsA: Tableview does not update when adding new values
You should keep a reference to the Observablelist you have placed as a set of items in your Tableview. Hence when adding do not: tabela.getItems().add(e); All CRUD should be done in the previously…
javafxanswered Gustavo Fragoso 2,321 -
2
votes2
answers70
viewsA: File still in use by Java / How to close file connection
You should close Fileinputstream after use, try to do this way: FileInputStream fis = new FileInputStream(new File("D:\\movie_play_red.png")); image = new Image(fis, 150, 0, true, true);…
-
1
votes2
answers323
viewsA: How to format resultset printing via System.out.println in Java?
You can use a C-type formatting using System.out.format: String ID = "10"; //rs.getInt("id"); String nomeCargo = "Analista de Sistemas"; //rs.getString("nome"); String nivelCargo = "Senior";…
-
1
votes1
answer206
viewsA: Javafx progress indicator in interface construction
I ran a test from the original code you posted and managed to make a simple progress indicator. Scene scene = new Scene(root); primaryStage.setScene(scene); primaryStage.show(); /* * Coloque o…
-
1
votes1
answer1024
viewsA: Change Icone Javafx
There are two things that draw attention in your stacktrace: WARNING: Loading FXML Document with Javafx API of version 9.0.1 by Javafx Runtime of version 8.0.111 It seems that your code and your…
-
0
votes1
answer54
viewsA: Problem starting Javafx application
In the tests I performed on my computer the problems happened in these two lines: Image image = new Image(getClass().getResourceAsStream("Fundo.png")); // ... Image image2 = new…
-
1
votes1
answer337
viewsA: Pass class values when generating a pdf in Javafx
I suggest you create a modal window to display your PDF. First let’s fix your PDF generation class by following good programming practices in Java: public class GeradorPdf { private String source;…
-
1
votes1
answer59
viewsA: Pointers in college
In the case presented the program will actually present different outputs on each machine, and sometimes at each execution, because the value stored in a pointer is a memory address. The problem is…
-
1
votes1
answer174
viewsA: Java window size
As you are using an Anchorpane (and apparently only that part of the filter is out of place) I suggest you change the anchoring of the items right to right, as I realized that you must have put…
-
0
votes1
answer94
viewsA: Recursiveness-elemindices
I’ll explain two ways that work but I don’t know if it’s really what you want: myElemIndices :: Eq a => a -> [a] -> [Int] myElemIndices x [] = [] myElemIndices a xs = indexed a (zip xs…
haskellanswered Gustavo Fragoso 2,321 -
1
votes2
answers698
viewsA: Java/SQL Login and Password Validation Issue
I suggest you take advantage of Preparedstatement and do the following: PreparedStatement p = con.prepareStatement("select idusuario from usuario where login = ? and senha = ?"); p.setString(1,…
-
3
votes2
answers1029
viewsA: Method to change CSS subclass (choicebox item text color)
In your case staying using setStyle has two disadvantages: It’s harder to keep in case of changes; There will be unnecessary code repetition. I’ll put a solution here using external CSS, (if you’ve…
-
3
votes2
answers3700
viewsA: How to Format/Separate Date and Time from a sqlite datetime field
According to the sqlite documentation the functions date(), time() and datetime() may be written in terms of function strftime(). So, to do what you want, the query is as follows: SELECT…
sqliteanswered Gustavo Fragoso 2,321 -
1
votes1
answer796
viewsA: How to display decimal number - iReport
The error you noticed happened because a cast to int occurred while placing only 180, instead of 180.0. Always keep in mind that although Jasperreports is a bit confusing it is written in Java so…
-
5
votes1
answer3489
viewsA: Error "could not be Parsed" when converting string to Datetime type
This is happening because your Pattern does not reflect the received date format. You say that the string that will be converted (parse) has the format dd/MM/yyyy HH:mm:ss when in reality the format…
-
1
votes1
answer65
viewsA: Lost date format
From what I’ve seen you’re wearing dating + 6 hours just to make the comparison. This is not required in the new Java 8 Date API, see: String dataMed = "2017-09-26 11:55:44.0"; //…
-
0
votes2
answers435
viewsA: Jfoenix library does not list Jfxbuttons after added
Step 1: Add jfoenix.jar to your classpath by clicking Library > Add Jar/Folder. (As the components appear in your Scenebuilder you can skip the next step if you want) Step 2: In your Scenebuilder…
javafxanswered Gustavo Fragoso 2,321 -
0
votes2
answers559
viewsA: Capture Textfield change from Javafx
Ask a little generic because there are several properties of Textfield that can be observed by the programmer. Looking at the documentation we have: Properties inherited from Textinputcontrol (These…
-
0
votes1
answer50
viewsA: Why doesn’t this code go wrong, but it doesn’t return anything?
The main missing point was to recall the sub function in the correct form. I don’t understand very well what you want to do, see if the iteration below is the expected result: Input: [1,2,3,4] 1.…
-
0
votes1
answer918
viewsA: Position of an element in the list
I made a little code that fits your purpose, see: localiza :: [a] -> Int -> a localiza x y | y > length x - 1 = error "Posição excede o tamanho da lista" | otherwise = head(drop y x) main =…
haskellanswered Gustavo Fragoso 2,321 -
3
votes1
answer51
viewsA: What is the difference between [a] and "a" in Haskhell?
It’s not right when some function says func :: [a] -> a is informing us that it takes as parameter any list (of any size) and returns an element of the same type of the list. The variable to can…
haskellanswered Gustavo Fragoso 2,321 -
0
votes1
answer295
viewsA: Problems connecting Postgres with java
It took me a while to realize your error, it is simple typing question because the correct name of the driver is Class.forName("org.postgresql.Driver") you put 2’s'.
-
3
votes1
answer107
viewsA: Using the Java Synchronized
Just put in the method signature doLog the keyword synchronized, thus: private synchronized void doLog(String text) { //seu código sincronizado; } For more information on how synchronized methods…
-
1
votes1
answer404
viewsA: Jasper ireport first record
This error is occurring because you have placed your fields in the "Header" section, it is correct to put them in "Detail". You move column titles to column header, meaning your Static Texts and…
jasper-reportsanswered Gustavo Fragoso 2,321