Steve Datz

Greenhorn
+ Follow
since Mar 10, 2019
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Steve Datz

Paul Clapham wrote:

The API docs wrote:Returns the cell index closest to the given location in the list's coordinate system. To determine if the cell actually contains the specified location, compare the point against the cell's bounds, as provided by getCellBounds. This method returns -1 if the model is empty.



Ahhh Thisss thank you.
3 years ago

Paul Clapham wrote:

Steve Datz wrote:I still dont understand why clicking the empty space in the jList auto selects the last item in the list.



Which other item would you expect it to select?

Oh, I get it, you want it to not select any item if you didn't click on an item. I looked in the JList documentation and it says

The Docs wrote:Use the locationToIndex method to determine what cell was clicked.



It gives an example too:



What that does if you click in a blank area, I don't know but you can adapt that code and try it out.



Yes, locationToIndex is what I am using. I want it to return -1 if I click an empty space, instead, it returns the index of the last item in the JList which is what i am trying to solve. If I don't click an item, I want to clear the selection, not select the last one in the list.

3 years ago
Couldnt figure out how to add a a border to a jList but I added it to the scrollpane,

the white is the jList the grey is the scrollpane.

https://i.imgur.com/hJSo32Q.png


I still dont understand why clicking the empty space in the jList auto selects the last item in the list.
3 years ago

Paul Clapham wrote:But I did look at the video and it looks like you're trying to click in an empty area of the JList and cause a "Create" dialog to pop up. Wouldn't it be easier to just have a "Create" button to do that? It could go directly above the JList.

Edit: Put, say, a red border around the JList. Then you'll see what screen real estate the JList actually covers. You may find that you're clicking on the background of the JScrollPane instead.



Thanks, I will try that later. Yes thats "easier" but feels more novice of a design in my opinion and less clean. I had the same idea but am trying to avoid it and replicate something I see in popular UIs I use and like.
3 years ago
Hello I hope youtube videos are okay for posts,

I feel like it does a better job explaining things in this case.

https://youtu.be/h-_iRdcKBu8


I will also post the code :




Note my JList is in a sidepanel of a border layout (in a nutshell):



Is a possible solution to just have a dummy item at index 0?? Feels bad though.

Thanks again for your help, this websites been epic at getting me unstuck lately
3 years ago
Youre a legend! thank you
3 years ago
Hello all!

I am having trouble appending to a CSV file.

for some reason it just over writes all the entries despite using append()




Any idea what I am doing wrong?
3 years ago
Thanks Paul it returns :
C:\Users\Steve\Documents\IntelliJProjects\CS358HW1

which is where my project is, and I can write here.


And I am an Admin, when I go to create a folder in C:\\Users I see an admin symbol there when I click the button.
(this is my home PC, ironically when I was at work this was the only place I had permission to write to and I wasnt an admin , both win10)
3 years ago
I found a solution :
_filePath = System.getProperty("user.dir");

however I would still like to know why I cant write to user despite it saying its writeable
3 years ago
Hello



I am having an issue where I cant seem to make a folder in the C:\\Users" directory


https://i.imgur.com/UJM3sTC.png



Results:
https://i.imgur.com/4xDkrN9.png

WE found C Users
MAKE FOLDER  true
false


Does anyone have any suggestions??

Thank you for your help
3 years ago

Rob Camick wrote:Where is your SSCCE?



Rob, I apologize, I am not sure how'd id make an SSCCE without ripping apart all my code and logic.
If I were to paste parts in and make it solely in the browser I would probably miss some steps that would make it look bugged on its own.

I believe that breaking down my code into steps (and small ones!) would be enough to make it clear what my code is doing.

I am not expecting someone to debug the entire project, I hope you'll forgive me for this.


I am getting much closer!
https://i.imgur.com/DiRJ3ku.png
3 years ago
I've added in some dummy spacing with :



looks  a bit better now, but something is still very off about the bottom GridLayout,
I will have to come up with another solution and split it into 2 Panels I think

https://imgur.com/Jk7IyJQ
3 years ago
Thanks paul for your suggestion.

I've went with the BoxLayout because It seems flow layout is only horizontal?


This is the new result:


https://i.imgur.com/QczbouZ.png

Still have tons of extreme spacing issues and random sizes
3 years ago
Hello,
This is a continued post from earlier today as the situation as evolved.

I am trying to make a GUI in Java (code only) looking like this :

https://i.imgur.com/9fzkElQ.png


I've started by adding a MainPanel with a BorderLayout
and assigning a JList to the WEST. This seems to be working well.


Next added a Center Panel with 2 columns for mid section to the CENTER of the MainPanel.



Then I added the left panel to the centerPanel which will be my input area.

(one extra row because I might add stuff later, or try to find a way to add a gap spacer to keep it away from bottom of page)

Then I wrote methods to
add my various Panels to this centerPanel_Input.




However, when displayed, there are all sorts of questionable Gaps.
For instance, there's a GIANT gap between Jpanel top and Jpanel midList, but no gap at all between JPanel midList and JPanel bottom??


https://i.imgur.com/aY66mkv.png


Any idea why?


lastly,

I have two problems with SetUpManualArea

I can't control the size of the elements, so the JTextFields are blarringly gross sizes,
along with the button as well.
Tried set Min, Max and preferred size.

I also can't seem to control the order despite trying to add them to the right column/row.
For example, inLabelTop at (0,0) appears last like its at (0,2)


https://i.imgur.com/I84TjZ2.png



Your help is greatly appreciated in these trying times!



3 years ago
Thanks for your help ,

I finally got it via this:



I will keep your way in mind as well.

Thanks so much for your help everyone. I am going to go back to writing this via code only and give up on the visual stuff
3 years ago