swing: saving dialog box resize dimensions - swing

I have a dialog box with a bunch of dimensions that a user can change by moving/dragging, including a JTable with resizable/draggable columns.
What I would like to do is to make the state of these resizable columns / dialog boxes / etc. persistent, so the next time my application starts up, the user doesn't have to go through the resizing step all over again.
What's the most convenient way to do this?

You should probably take a look at the code in (the now probably dead) JSR-296. A part of it was focused on persistent session state, and I know for sure that the code for persisting window locations and such was already functional and in the basic framework. It should either already do what you want, or provide a good starting point.
Cfr. dev.java.net site for JSR-296

Related

How to activate the main window of PhpStorm after clicking its floating Find in Path window

Let me explain the situation.
I need to copy a lot of instances of a text inside a project of PhpStorm. So, I perform a 'Find in Path' action and a floating window appears with the matching results.
Now my problem is that after copying once from the floating window, if I click on another app window, then PhpStorm's main window/PhpStorm itself go to background, then if I want to copy text from the floating window again, I can not use any keyboard shortcut, I can not modify any line in the floating window because PhpStorm stays in background/inactive-mode even if I click on its floating window.
If I click anywhere in the PhpStorm except the main top-white bar of PhpStorm, then the floating window disappear, which causes me to perform the search again.
It is reducing my productivity a lot. Is there any way to make the PhpStorm active or bring it foreground when clicking its floated search window?
Please see the screenshot:
Is there any way to make the PhpStorm active or bring it foreground when clicking its floated search window?
You are approaching the problem from the a bit wrong angle. There is a better solution than fighting the focus/foreground state.
There is a button in the bottom right corner of "Find in Path" window ("Open in Find" it says on your screenshot) -- click it and it will open search results in traditional / standard Search Results tool window (with grouping by folders/files, preview area etc)... so no floating and no auto closing on clicking somewhere.
P.S. Lots of people forgetting that results shown in this new "Find in Path" dialog/popup is still just a preview (TOP 100 matches only). Super functional (you can edit and stuff) but still preview only. This mainly applies to those who remember the way how this dialog (back then it was dialog window) looked before redesign (now it's more of a popup).
Because of the way how it is all presented now (results occupy majority of the popup space) people somehow automatically forgetting about "traditional" way of searching (clicking actual "Find" button to get search working) and focusing only on what they see on a screen right now.
This new "Find in Path" dialog/popup adds a lot of convenience for sure (you typed search text and results are straight away before your eyes). At the same time quite often you may see/hear "it does not show me all results" frustrated comments (as it shows top 100 .. and a single file may have 100+ hits in some cases) and alike. JetBrains needs to improve UX a bit in this area for sure.

how to fast convert bootstrap button into png image file?

that I would like to say, there is a good (or maybe not) bootstrap framework that can generate buttons with simple code.
I really like how these buttons look, and I want to use them in another software, but for this I need them in PNG format.
Why is not satisfied with the option "manually" - the buttons need a lot and not always needed, but when needed - they need fast, do not really want to spend a lot of time creating buttons ...
Current process:
Open page (for example https://www.tutorialrepublic.com/twitter-bootstrap-button-generator.hhp) to set the necessary parameters (button name, size, type, color, icon ...)
Copy the whole screen to the buffer
Insert a screenshot from the buffer into an image editor
Make necessary cropping of this picture, leave only the image of the button itself
Save the result in png format
Use the image in your application.
That I would like to receive:
Open (no difference - internet page, any software, etc...)
Specify the required parameters (button text, size, color, icon)
Press the button - save to PNG, without loss of quality.
Use the image in your application
Maybe someone already solved a similar problem and translated it into a semi-automatic mode, share the implementation.
I use Win10 at workstation
The easiest way would be to manually crop them by Snipping Tool. This works great if you have just a few buttons.
But if you want to take them automatically, I think you can use an python/opencv script to idendify buttons, crop and save them.
Ok, solution found - ShareX (https://getsharex.com/) software with 1 hotkey (ctrl + printscreen) - open crop dialog with zoom, after crop - makes the png-file automatic

Game show buzzer screens

I'm doing a training class right now and one of the games I plan on doing is a Jeopardy style of Q & A. The problem I'm trying to figure out is the buzzer. My idea is to use the projector as the question board I control. The trainees would go to an HTML page with nothing more than a single button. They would turn their monitors around to face me up front. As soon as I read the question they would click the button and it would change their screens the color red.
The button and background color change is easy enough, I got that. There are two problems I'm facing: 1) I need it so that they can't click the button until I'm done reading the question - this one isn't as important, I can just make up a rule. 2) Only the fastest person will have a red screen. To show me who clicked first. The others' buttons will be disabled.
I just have no idea how to even Google these two things. Like: "Disable button for other users"...? Or maybe, "only one click"...?
Any direction to search is appreciated. Eventually, I'd like to add other aspects to like the presenter could click an "incorrect button" then it would clear the screen and enable all the buttons again, for the answer steal.
You can do it with modern WebSocket or applications interact via TCP. However, WebSocket may be overkill for the simple application with a few teams. I faced the same problem before and developed a simple solution with PHP using Flock to write into a shared file on disk. Only request from one team gets the chance to write into that file. Stick to not to use WebSocket, the web page on client site does some polling to receive the "restart" signal from the server for the new question/round. It can run in LAN, different team gets different site, i.e. http://[server-ip]/team1, http://[server-ip]/team2.
You can have control over the round: allow them to press button/ restart, start a new question in http://[server-ip]/admin.
Further improvement can be made in several ways to facilitate your needs (i.e. assign team name, register team, use database instead of a flock file). The code is available here : https://github.com/minhhn2910/buzzergameshow

How to tell if a control is no longer visible to the user?

I have a control in which I repeatedly run some animations (e.g. DoubleAnimation). Can I detect if my control is no longer visible to the user? E.g it gets scrolled away from, the user navigates forward to another page, or it gets obscured behind other controls.
I don't want to run those animations unless at least some part of my control is visible for the user.
You could analyze the visual tree or get a transform from control coordinates to screen coordinates to see if its positioning is within the view port and also check things like opacities, visibilities etc. of controls down the visual tree path, but that is so processing intensive that it is not worth doing all the time for a general solution.
The only thing that would make sense is to handle the ScrollViewer.ViewChanged event and check if the offsets make it visible or not while limiting the TransformToVisual or VisualTreeHelper calls only to times when the actual layout within your ScrollViewer changes.

Monodevelop: can't drag widgets

I am trying to use monodevelop. Just at the beginning I came across an issue:
I was following a tutorial on building a Gtk application (http://monodevelop.com/Stetic_GUI_Designer). I was trying to drag a button from the Widgets Palette. Nothing happened. I'd been trying quite a few times without any luck.
After a break I launched monodevelop again and I simply placed a button on the window of the application. After that I removed it, dragged VBox container, and placed menu bar on the window, according to the tutorial instructions. I was pleasantly surprised.
By the second try the same problem occurred - I was not able to drag any widgets. Dragging was beginning, there was a “+” sign at the cursor and then - nothing was happening. I cannot figure out what happened by the first time, what the difference was. Have anyone had a similar problem? Monodevelop looks promising, but I can't go on with it. (I tried placing 'Fixed' container on the window, with no result - I could not drag it.)
(monodevelop v. 2.4, ubuntu 11.04, Polish language.
I did look for an answer to my problem, without much luck, that is why I post this question. The problem is described quite precisely. There is a probability that others encountered the same issue.)
You need to drag a container on the form first before you can add widgets to it. The VBox container is an example of a place where you can put your widgets.
If you want to place widgets where ever you want you can use the Fixed container. If you want things to align you can use the VBox, HBox or Table containers. Placing in a widget in one of the fields will automatically adjust the size of this field to fit the widget you have dragged into it.
So basically,
Create a form
Drag a container on the form
Drag a widget inside the container.
These widgets are not to be confused with the custom made widgets (in your Solution browser, right click the folder User Interfaces and click Add Widget...). These are like forms. I use these to create GUI's in advance so I can call these while the program is running.
FYI: if you want to create code for a widget (like a button) you can't just double click it like in Visual Studio. You need to select it, the go to the properties pane, and change the tab from Properties to Signals. You can then double click the "signal" to create the event for which you want to create code. For a button this is usually the Clicked event (somewhere at the bottom of the list, you'll need to open the Button Signals)
You can always visit the IRC channel of Monodevelop on irc://irc.gimp.org/monodevelop (IRC.Gimp.org #monodevelop)
I also sit in this channel and can help with smaller problems and I also still use Monodevelop 2.4.