I would like to know normally how they let a user choose the background color? For example, user chooses the background color to be red color, next time when the user runs the application again the background color will automatically become red color instead of the default color. Do they store the value in the database, so next time user runs the application will first retrieve from the database?
Java Preferences works for this pretty well.
Edit: I can't remember which one I used, but this one looks OK. Just use putInt("background", value). I'd get the value from getRGB(), like they say to here.
Related
I'd like to create a layout displaying a music album's tracks, with the text and background colors being taken from the album cover's color palette. I know how to retrieve the color palette, but I am unsure how to easily apply it programmatically to an entire layout, without manually finding each individual view and changing the colors appropriately. I have only found solutions where themes are changed before creating the views, but those themes are already predefined in the resources, not dynamically generated on the album cover.
Is there some way for me to write a layout in XML referencing colors like "color1" and "color2", and then at runtime assigning an actual value to these colors, such that I don't need to painstakingly modify every view programmatically myself?
I'm not sure it's possible to do that through XML normally, since you're referring to resource IDs and those resources are fixed at runtime. The Theme class also links attributes to resources, so you can't just inject the values you want (as far as I know) into a Theme and then apply that to the Activity. (I don't know a lot about the styling/theming system though so it's possible you can do some wild stuff with it!)
There's a couple of things you could look into though. If you're happy to use the new Material 3 system, that has dynamic colour baked into it, including theming parts of the app with colours derived from content like album art.
But from that outline, it looks like it pulls a single colour from the image, and derives a couple of complementary, neutral colours from it - so it's not pulling multiple colours from the image like the Palette library does. The Material 3 stuff has a particular tone to it (limited colour variation, not too much contrast, consistent look) and if that works for you, great! But if you want a more vibrant palette, you might need to use Palette instead (that link up there shows how you're meant to use it, the examples are basically "apply colour to each view/component in code")
The other thing you could try is using data binding, and instead of using resource IDs and attributes in your XML, you could reference properties on a ViewModel. So you could create LiveDatas for things like primaryColour, secondaryColour etc, and bind to those when setting the colour attributes in your XML. And then by updating a value in the ViewModel, any views bound to that property will see the change. And that binding is defined in the XML, you don't need to know which View is using which colour in your code.
I've never actually used data binding, never mind for colour updates, so I'm not sure how well it would work or if you need to give things a kick to get them to refresh visually - I'd imagine it just works like setting a new value through code, but I'm not sure so I just want to be clear about that!
But if you want smooth colour transitions (e.g. switching albums fades the colours) then I'm not sure there's anything that does that out of the box - maybe the Material 3 stuff does it. You could probably do it with the ViewModel approach though - when you set a new colour, kick off a coroutine that interpolates between the current value and the new one over 1 second or whatever, updating the LiveData every tick.
Little background. I am using test complete and java scripting language for automating the java based desktop application.
I need to click on the row in the table depending on the image colour. If image colour is red it need to be passed and only green should be clicked.
I tried most of the function is test complete none of these returns me image colour.
Do anyone have an idea how do i do this.
This task does not seem to be a usual standard functionality of a GUI testing tool. So, you need to implement this feature using JScript yourself. In general, algorithm is this: get the list object and iterate through its displayed rows working with them as with native Java objects. Use the native field or method to test the current row's color and if the color is appropriate, perform an action of this color. You can get an identified of this native row object and use this identifier to interact with the row with TestComplete's means.
Cannot be more specific due to lack of specific information on the controls used in your application.
Almost every TestComplete on-screen object has reflected upon it the Picture method. You could look at a pixel within that picture object to determine the appropriate color, and then click on that row.
The problem is to create a dynamic label printing where in I will present to the user the fields that are available (ex. Name, ID No, Address etc) and I will let them draw their own label.
It is something like on the left side, there are the available fields, and on the right side is a big field where I let them drag and drop the fields and draw boxes and grids.
The system should be able to save the drawing (in any format as long as it can be saved in the database) that they created and the fields in that drawing can be called in the backend.
The saving part is important because if the user created so many labels, I want them to be able to choose which drawing they can use to Print their labels.
I would like to integrate this with my existing web Maven Spring 3.x system.
If anybody could point to where to look, either in the drawing creation or in the saving it would be great.
I did that drawing/saving stuff in a webapp some time ago using Javascript. Use the HTML canvas element to define a place users can draw on.
Guess there are several js/jquery libraries for that (It is also possible to do everything on your own)
There are also exporting functionalities (I do not remember exactly) but it is possible to convert the drawing to a data-url and upload it with a hidden text field. Of course it can be directly stored on the user's computer as well.
Start by having a look at introduction to canvas drawing on w3cschools.com
I have a JCheckBox that should not be checked by the user when a certain other field is empty.
So now I want to have an error popup and then reset the checkbox (I've considered disabling the checkbox, but the connection to the other field is non-obvious, and a tooltip text IMO not visible enough).
What's the correct way to do that in Swing? Through a PropertyVetoException? Where do I throw it and where do I catch it? My first (probably ugly) idea would be to add a ChangeListener that itself shows the popup and resets the value.
Edit: The question is about Nikki (screenshot below), an app I am developing which geotags images and exports them to Google Earth's KMZ format. The checkbox is used to select the images to include in the export. But this requires the images to be gotagged first (which in turn requires either a timestamp, or manual assignment). I don't think this requirement can be made obvious through the UI layout.
(source: brazzy.de)
I would simply disable the check box and add a message explaining why the option is not available. A nice way to show the message is to display a mini exclamation mark next to the check box and put the message in a tooltip.
Poping up an exception often feels wrong because users don't read error messages. For most users an error message popup means that the application did something wrong, in your case it's the normal behavior.
Edit if you insist on letting the check box enabled, another way to show the user that some info is missing would be to flash the missing data. Eg. if latitude and longitude are missing and the user clicks on export, set a red background onto these fields for a just a second. This will clearly show the user what's missing.
In this screen, don't you want to put the mouse over the red circle to understand what's going on?
validation http://www.vogella.de/articles/EclipseDataBinding/images/validation10.gif
I don't think the Export JCheckBox should be disabled at all. Instead, the Export JButton itself should examine the current export list and display any anomalous entries in a way that allows navigation to a chosen photograph. If all entries are correct, Export would proceed as usual.
Addendum: It think you are right to keep the interface as non-modal as possible. My model for this would be unsaved files when exiting an editor or uncommitted changes when closing a project in an IDE.
If that's a status line at the bottom of the window, you might indicate the number of photographs currently selected for export, adding a count if any still need geocoding.
The field should simply be allowed to disable the checkbox. If the coupling is unintuitive then the GUI layout may have to be reconsidered.
EDIT: I ran it from your page, and I believe the issue here is that you actually have a third and fourth step in addition to select folder, select images. The third step is validate image, and fourth is select images for export. I think your problem is that this is not clearly conveyed in the current layout, and that reflects in your question.
I would suggest that you create a separate column containing the checkbox for each image, and that THAT checkbox is disabled until the image passes validation (step 3). Perhaps with an explanatory text in the column about why the image hasn't passed yet.
I'm currently making a GWT project where I display some HTML in a RichTextArea, and I want the RichTextArea to be selectable/highlight-able by a mouse but NOT be editable/modifiable by the user. In addition to this question, could you also tell me how to retrieve some highlighted text in string from without me having to add a text-background toolbar, which, after highlighting a text from the RichTextArea, you change the color of the text-background, upon which, you add a separate periodically looping thread which checks to see when the text-background changes substantially from white (or a native color of the webpage) and finally extracting the string whose text-background color differs as the selected text.
I really hate to give any pointers without explanation but i think your requirements are bigger ::: so --->
http://examples.roughian.com/index.htm#Widgets~RichTextArea
http://www.java2s.com/Code/Java/GWT/RichTextArea.htm