Chris Whitcomb

Greenhorn
+ Follow
since Feb 06, 2017
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Chris Whitcomb

Thank you! Your suggestion worked. Now that you point it out it makes total sense to me. Thank you for helping me on my journey of learning!
1 year ago
I have a relatively simple program where I'm trying to display values from a 2 column mySql table into a TableView in Java. My program is getting choked up with an error that says "java: incompatible types: java.lang.String cannot be converted to int."

My setup is as follows:

I've created a separate Java class that creates an object with 2 variables (brandId and brandName) called "Brand"



I have another Java class called "DatabaseHandler" that has all the code that interacts with the mySql database. In that code I have the following method that is supposed to connect to mySql database table called "dim_brand," retrieve all values, and populate them in an ObservableList  that I will use to populate the TableView.



In testing and debugging the code, I've gotten the connection to the database to succeed and I've be able out sout the results. My program is choking on the statement:



I have no idea why since I'm able to use the getString() method in the sout statement without any issue. I'm thinking it has something to do with the ObservableList<Brand> that I'm trying to insert the values into. Any help our insight would be greatly appreciated.

View of mySql table dim_brand:

brand_id: VARCHAR10
brand_name: VARCHAR45

brand_idbrand_name
JONMURPHYJohnston & Murphy
JOSABANKJos A Bank
NIKENike
TOMJAMESTom James
1 year ago
I'm fairly new to JavaFX using Scenebuilder and FXML and am looking for some help. I have a GUI that I've built in SceneBuilder and a large part of that GUI is the right hand side which contains a TabPane. The TabPane has Tabs that  each represent a type of article of clothing. I have set up buttons on the left that, when clicked, will change the view on the Tab. By default, the content on the Tab will display a bunch of information about each article of clothing. I have a button on the left label "Pictures Only." When this button is pressed, I want the AnchorPane in the Tab of the TabPane to be replaced by a different Pane which will include only pictures of the different articles of clothing. I have defined the replacement Pane (VBox in this case) in the <fx:define> context. The application runs but when I click on the "Pictures Only" button, nothing happens. What am I doing wrong?

GUI: see attachment

From FXML.Document.fxml: - Content for Tab labeled "Belt"



FXMLDocumentController.java:

3 years ago
As you suggested I put PicView in front of pictureNamesArrayList and it can see it now. Thank you!
6 years ago
I have 2 classes; one called PicView and another one called PicDisplay. In PicView I declare:



I later fill this array with all the JPG's in a particular directory.

In the PicDisplay class, I have a few methods that manipulate the picture. Without getting into a great deal of detail, I need for a method in PicDisplay to be able to "see" the pictureNamesArrayList variable but even when I list it as static, I'm getting the following error: "cannot find symbol, variable pictureNamesArrayList."

Below is the method where I'm trying to access the pictureNamesArrayList within the PicDisplay class (of which I've created an instance of):

6 years ago
Thank you so much! I would have never figured that out on my own.
6 years ago
I'm new at using NetBeans and I have a class that creates a JButton. I want to display a small image in the JButton but no matter where I put the image, I can't get NetBeans to recognize that it's there. I've searched on the internet but all the answers I see use the JForm part of NetBeans to attach an image and don't use just straight coding. I know the program works because I originally wrote it in a text editor and it displayed the image. Any help would be appreciated.

You can see below where I create the JButton and where the images currently are. Also included is a screenshot of what the program looks like when I compile and run using NetBeans

6 years ago
Thank you. That worked! I am adding a few more things to the JPanel and have some functions that I also have to add but wanted to keep the code here simple so people didn't have to wade through a ton of it. I haven't had much experience with layout managers yet but that's next on the list to conquer. Thanks again!
6 years ago
That makes sense to me. Thanks for explaining. I'm not getting an error anymore but I'm also not seeing the JLabel. Here is my program that contains the main() method and calls the PicDisplay object:



And here is the code for PicDisplay:


I've attached an image of the result I get when I run the code.

Any help would be appreciated and thank you for the help so far.
6 years ago
Yes. I do want to attach a label to the Container (JPanel). I'm not sure I understand your response. I apologize, I'm very much a beginner. I tried to add a line like (at 32) PicDisplay.add(archiveOrTrashText); but I'm getting an error.
6 years ago
I have written a basic Java program that has a number of different Swing components on a single JFrame. One of those components is a JPanel that has some buttons and a JLabel on it. The program will get pictures from a directory and display them in the just mentioned JLabel. I have 4 instances of JPanel's attached to my JFrame. (Attached screenshot below bc "a picture is worth 1000 words")

At first, I had all this code in 1 large class but, realizing there was a lot of redundancy, decided to make a class called PicDisplay which would extend JPanel and that I could call from my main program. This class would create the JPanel, all the buttons and label, and hold the methods that allow me to manipulate the Icon (in the label). However, when I got to the point where I needed to attach some of the buttons and labels to the JPanel I realized I didn't know how to do this.


6 years ago
Piet Souris - THANK YOU!! Thank for you not believing me because you were right. I took off the ArrayList<File> and it worked. Very much appreciate it!
6 years ago
Piet - I checked the mistake in the topic you listed (that was my post as well) and this one is a little different although it's the same program. You were right that I had declared pictureNamesArrayList twice in the previous post and once I took care of that I didn't have that problem anymore. I'm going to give what you listed below in Java 8 a try.

Campbell - this shows that my pictureNamesArrayList is not null I believe


Carey - here is the code I use to set the initial images

6 years ago
All,

My understanding of inner anonymous classes is very limited so I need some help. I'm getting a NullExceptionPointer java error and I think I've isolated it to one particular line. However, despite all my searching on the internet I can't find an answer. From a 10,000 foot level, I have a program that creates a JFrame and has panels which contain some buttons and also a JLabel that displays an ImageIcon. I get the ImageIcon by letting the user read choose a directory to read and then reading that directory and loading all images from that directory into an ArrayList<File> variable.  I have a button that you can press that calls a method which is supposed to call a method that will accept a few parameters and use them to resize the image and rotate it a certain number of degrees. I've attached an image to help with the visual of the JFrame.

Here is the code:


Within that class I set up:


I then have code that sets up all the menus and panels and such that I don't think is really pertinent to my question.

Here is my code that is still within the createUserInterface method and that creates the button you can click to resize the image and rotate it 90 degrees:



My createUserInterface method ends after creating all the other GUI components

I then have a method that populates pictureNamesArrayList and I know that works because it does display the images in the JLabels before any buttons are pressed.

Here is my problem code. This method is supposed to call the ResizeImage method I've created.


As I was trying to pinpoint my error, I inserted the JOptionPane.showMessageDialog statement you see above and I still get the Null exception pointer error. However, if I change the second argument statement  from pictureNamesArrayList.size() to "Testing" then I do get a pop-up box with the text "Testing." So, I think that one90JButtonActionPerformed method is not "seeing" the pictureNamesArrayList. How do I solve for this?



6 years ago
I did and I do see a getIcon() method for JLabel. The problem is that I can't get the Image out of the Icon so to speak because the Icon interface only has 3 methods: getIconHeight, getIconWidth, and paintIcon.
6 years ago