I am trying to display an image in a jlabel, which is in the default jFrame created by Netbeans. I know how to display an image in a new Jframe, but I dont know how to acces the default Jframe since I cant customize the code and create a variable name for it. Any work arounds?
The application is supposed to display pictures from a directory, so when u press next, next image, and if you press previous the previous image will be shown. What will be the best data structure to do this efficiently so that I can keep track of the index as well?
Instead of letting the GUI designer manage your frame, let it manage the content, as suggested in this example.
Addendum: There's an example of flipping through images here.
Regarding displaying the images, you can number the images in the directory as 1,2,3...and so on. If you do this, you can use a simple counter variable (increment with the next button and decrement with the previous button ) to scan through the images. You can use this counter variable for your image name with the format.
Related
I am trying to create a program in Javafx + Scenebuilder that has a tab pane for creating/loading a card set and another tab for quizzing yourself using that card set, I want to know how to take input from the user in a series of TextFields for a Title to the flash card set and tie that to the flashcard's Question & Answer(entered in TextFields). The user can then enter the flashcard's Title and hit a load button and then go to the other tab and be quizzed with that flashcard set. I also need to know how to store the set so that it doesn't have to be entered every time the program opens.
I had researched on my own for some way to do this but couldn't find a good way to do this, that is why I asked for help.
A HashMap is what I need, after asking someone that actually would give a straightforward answer this is what I was told.
I was wondering if it was possible to drag the text from a JLabel, out of the java application onto a pdf form for example.
If it is possible, could you point me in the right direction please?
Its easy.What i woud do- Put listener onto JLabel, take text on event that you pick.Copy text from the JLabel value into Clipboard,
Now you have text that you can manipulate.
Drag effect.=Use (with combination of the previous listener) JNativeHook lib to get GLOBAL EVENTS of java application and outside.
Listen for dragging(Do on your own its easy) , on mouse release onto your pdf input text.
You might have to simulate mouse click(right after release) to select field (via robot class) to actualy SELECT THAT FIELD,so you can input text.
Input text part=Use robot class to insert string char by char.
This will work well.I dont have any other idea atm that woud be this easy to implement.
You can also (fool user) with effect of floating text etc if you put transparent window over the top and check mouse location on screen.
I am trying to make an image Viewer like the one shown in the figure below:-
Before i can start i have following questions in mind :-
How would i check for the number of images in the target folder so that i can iterate and include all the images in my app.
Secondly,i am thiking to scale the images down to 75x75 .But what i can't think is that how will i slide the images as scrollbar is moved
To be specific,what is the appropriate container for those 75x75 images queue and how that queue is shifted to left or right?(I already know how to get current scrollbar value and add event listeners on it to respond)
To check the number of images in the target folder you can use the File class.
As for the container you might need to create the animation your self. There is no a container ready for doing so.
This site ( and book ) has some ideas about it. I don't know how out-dated it might be though
http://filthyrichclients.org/
Unless I am misunderstanding, making a scrolling list of images is quite simple.
First, create a JList with a datamodel that allows images.
A great example is shown here:
Java drag and drop images in a list
Second, add the JList to a JScrollPane.
The scaling aspect can be easily performed using Scalr:
http://www.thebuzzmedia.com/software/imgscalr-java-image-scaling-library/
I have questions according to my final project in my IT Faculty.. I have to make A simple text editor (like notepad) without using JTextArea (GUI Java), I have to make my own JTextArea..
Idea/Topic= Own Text Editor
Algorithms= doesnt have any idea yet
Data Structure= Rope(Member of Binary Trees)
Requirement= Typing without JTextArea...
Is that possible to make that? Can a panel (or something else like that) has a listener or make a listener to do that?
simply thinking, First step I just want to try for typing on a panel, absolutely algorithms needed but i dont get right algorithms so far.. Is that possible?
My thinking is, for text that im typing is stored to a tree.. Is that Rope(Member of Binary Trees) for my data Structure?
Thanks for helping...
It's possible.
Use as you mentioned JPanel attaching KeyListener and MouseListener.
You need a model (Document). For simplest case it could be e.g StringBuilder where you can add content and show the StringBuilder content.
You need caret position (int field) to indicate where the edit should happen.
You need Font field to keep all the font info to be used in the editor.
Override paintComponent() and use FontMetrics to measure the text and calculate necessary width/height. For the start I would create a text area without line wrap.
Implement viewToModel/modelToView methods. They should calculate position of caret for given x,y and x,y for given caret position.
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.