I will explain my question clearly.
I need to zoom in/zoom out the world map.
When I click on the particular country in map, control should redirected to new page with respective the country.
I dont have any idea about this in java. Please explain the steps to acheive the above task.
As the question is quite general, here is a general answer: Zooming often means, that you want to display a certain percentage of somethin, and not the whole, where your size of the displayed will not change.
But in your case it seems more like a "find a mouse click in a polygon" thing. So you have to add a selection/click listener to whatever widgets you use (Swt? swing? ....?) where you change what your program renders.
It sounds like you may be trying to reinvent the wheel. Google etc have already solved this problem rather well. It might be better to incorporate an existing solution into your application. Have a look at GoogleEarth inside Java Swing.
Related
I am new to Java and I am working on a project where depending on number of files in a directory,
buttons will be created respectively. Each button will have a customized right click context menu.
How can I achieve this or is this feasible?
I just want to know the approach to do this.
The approach that you may try:
While you iterate your directory/file list (or other process that will determine the button creation), you can generate (create an instance of) a new button (JButton), I assume you know how to use new, and put it on your form / panel.
However, most of the time, layout would become an annoying issue here.
Thus, you may try to use MigLayout to handle this.
It will help you a lot in putting your stuffs in a tidy and convenient way.
Try this approach and when you have a specific coding-part question, you can try to search the existing solution in SO (StackOverflow) or if it doesn't exist, you can ask that specific code-related question.
Hope it helps.
I want to write an address in the address bar of a browser as well as click on a link using java Robot class. How can I track the different objects in a certain window?
Just giving a look at the API http://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html, anyone who do this should know that via Robot Class there is no "trackComponent(Component specificComponent)" method, you got 2 things that may help you:
1-getPixelColor (more than help, seems useless for you by now, maybe i'm wrong).
2-createScreenCapture.
the second method is maybe the answer for your problem, you could take a picture of the screen and with some image processor (javaCV could help you on this: https://code.google.com/p/javacv/) you could then track the components on the screen you took (for instance: from pixels xxx to pixels yyy is the Address bar of browser), of course you need to read some documentation about javaCV (OpenCV) for get this done, after that just use the method for move cursor and enter keys for fill the components, hope someone give a simpler way to do this, but i think this way you learn a bit of JavaCV a really powerful tool.
As a way of learning Java, I'm writing this little application for grade schoolers to practice basic math. The idea is that the kid does any number of math problems, as long as they are in the app, it just continues to throw problems at them until they click a 'Done' button. When they decide to be done, I want a new JFrame to come up that will show them all of the problems they attempted, along with their answer, and whether they got the problem right or wrong.
The advice that I am looking for is what is the best way for me present these results. I looked into the GridLayout and the GroupLayout, but I don't think that these are exactly right. I did something similar in VBA for Excel, and there I just ran a for loop with one iteration for every problem they attempted. Each iteration would add a row of labels to the frame with the elements of the problem displayed in the various labels. I tried this in Java, but I'm not even able to get the labels to even display.
So before I get all specific and start posting my code, I want to ask a bigger question, which is "what is the best method to create a view like this?" Often, I go off in one direction only to waste time before somebody suggests a totally different (and better) approach.
Thanks!
(edit: here's an image of how I did this in Excel. I'm trying to repeat basically the same thing in Java)
One simple way to make that design would be to use a mix of components. You could have a bunch of JLabels and JPanels stacked in a vertical FlowLayout. The grid you have described would be best designed in a JTable, something like the below:
If you like tables like Excel then, Java provides JTable class to create tables, if you want.
Tutorial : http://docs.oracle.com/javase/tutorial/uiswing/components/table.html
I would like to create a quiz for my Java GUI.
I'd like it to display a question on one page, then have a next button which takes the user to another page telling them if that question was correct or not, and if it is correct they can move on to the next question (by clicking another next button) and if they got it wrong, have to go back and answer it again. However I have no clue how to do this!!
So far I have a simple GUI with a welcome page and tabs down the side, one of which includes a quiz. Would it be a better idea to create the quiz in Flash or something and then embed it into my Java application? Or just do the whole thing in Java? I'm really new to java so I'm not at all sure what to do, any help would be greatly appreciated!
Thanks
It would be best to use just Java. Consider using CardLayout with your GUI to allow swapping questions, or else you can create and modify key components on the fly such as the text displayed by JLabels and JRadioButtons.
Key though before considering any GUI structures is to first create solid OOPS based non GUI classes to handle your questions. For instance, you may want classes for:
Question class that holds a question String, a List of possible answer Strings, a correct answer String. This class can randomly order the incorrect and correct answers, can have a method for checking if the answer selected is correct.
A Test class that holds a collection of questions, that can present questions in random order, that can hold the score obtained.
A QuestionReaderWriter class that can read and write questions to a text file (you definitely do not want to hard-code the question text).
For this type of app it would be best to use the language you are more familiar with.
Since this is just a simple display this then do that there really is nothing very difficult about it.
Personal, I would lean towards Flash as the flash IDE is drag and drop and an experienced flash guru could make this in a few hours. Flash IDE is geared towards this.
Is it possible to overlay multiple JSliders so I can see the "thumbs" on both (I've tried disabling the painting of the track and setting opacity to false but one still hides the other)? Basically I'd like to create a component that allows the user to define a range (and I didn't really want to write a custom one since it has most of the attributes of a slider). If there is another way I could do that with a slider, that would work too.
thanks,
Jeff
Ah, I found it (i must not have been seraching on the right terms). Swing labs as a JXMultiThumbSlider that I think will do the trick.
http://swinglabs.org/hudson/job/SwingX%20Weekly%20Build/javadoc/org/jdesktop/swingx/JXMultiThumbSlider.html
I recently had the same problem, I wanted a slider with two thumbs. I didn't get into it too much, and what I ended up doing to get the range is simply putting two sliders and in the "onSliderChange" event listener prevented one beeing smaller than the other and the other bigger than the one. I don't beleive Swing has a two-thumb-Slider, although it might be a cool new feature to add, so I think this is your best bet.
JIDE has a RangeSlider with 2 thumbs (and a nice extra one on top to move both thumbs at once (e.g. drag the range around) in their open source common layer: http://www.jidesoft.com/products/oss.htm