Swing: content of multiple frames appear in each other - java

I'm making a Java Swing application, which loads data from a MySQL database and puts it in a Gantt Chart (I'm using the swiftgantt 4.0 library for this).
I have a start window from where you can instantiate multiple JFrame objects which contains a Gantt chart, you can select from the start window what data you want to retrieve from the database.
The program opens the frames with the charts correctly generated, but the problem is, that at certain action e.g.:resizing the window, or scrolling, or clicking on the chart, the content of the last frame appears in the other frame.
If I use the refreshing function of the Gantt chart, the content switches back, to the original content, but I think it's not a good solution to put the refreshing function
to all events where this anomalies happen.
Does anyone have a clue what's happening here?
I'm thinking of some event handling of the frames, might mix up the charts of the windows, but I'm not sure what causes this.

Related

Can JTable be resized by the user dragging the mouse

So I am creating a GUI and it has a JTable that is set inside of a JScrollpane. When the user opens the window it displays everything how I want it to. The user can add rows to the table to fill in data and then they can scroll through the information. I also have a JButton which I have set to print the whole window. Now my problem is the table prints but only shows the data in the viewing area. What i was thinking was if the user could drag the bottom corner of the JTable to re size it to show everything then everything would be ok, I'm just not sure if that's even possible or how to do it. Ive been searching and i haven't seem to come across anything like this yet.
Edit:
So for anyone else here is the link to the class I found. It allows you to use the mouse to resize any component.
http://tips4java.wordpress.com/2009/09/13/resizing-components/
To get an image of the entire table you can try using Screen Image, which allows you to take an image of a specific component.

can we generate clickable jfree charts with tooltip using jsp and servlet?

I am able to generate stacked bar charts (whatever charts i want) in my application using jsp and servlet.
I need to add tooltips when i hover over the bars and make it clickable so that it calls some mouse click event.
I have gone through chart panels and mouseclick events but want to make sure whether it works in jsp and servlet first.
yeah i know in code we write as saveaspng so it shows the output as image only, can anyone please tell me whether is it possible have clickable output on jsp page using servlet output ??
i know this is possible in swing i have another application which can do this.
note:same is possible in google charts (it uses javascript so no relation between my question and google charts but just for knowledge sake i am mentioning here),but stacked bar considers the whole bar as same no clickable event separatley(this is another issue).

Creating a datatable in JavaFx

i want to create a table that is connected with my chart the idea is that it display the information on the chart in details.
here is a picture i found to give you an idea of how it should be builded (however i want the graph to be made in JavaFx and therefore the graph and table it self should be more smooth and with better graphics):
As you can see on the picture the information under for day (D1,D2,D3) is displayed right under the bars. how would i create a similar thing in JavaFx?

HTML gallery page in Swing with drag-drop functionality

I was asked to write a JDialog separated into left and right panel. The left panel shows a demo HTML template gallery (small sized), and right panel shows series or list of images. I want to make it such that I can drag image on the list and place it on the gallery (or maybe drag out some image from the gallery). The problem is I don't know where to start with this, can anybody give me some idea?
An HTML gallery typically uses JS to do the 'heavy lifting' (I'm guessing it will require a slideshow as well). While Swing components support HTML (to an extent) they do not support JS.
I recommend not trying to render the HTML/JS in the GUI, instead, provide a JList in the GUI of the image+name objects chosen by the user (using JFileChooser). When each image is selected, you can show the 'preferred name' in a JTextField that allows the user to edit it.
Image order can be shown by the order in the list. To change the order, implement Drag'n'Drop. See the Drag and Drop and Data Transfer lesson for more details.
You will probably need a JLabel in the CENTER of the GUI to display the (full size) selected image, and show the order & timing of the slideshow.
Once the user is happy with the image selections, the order, the names & timing. Offer them a button to write all the details to a single directory including the HTML, script & images (easier). Once the HTML is written, invoke Desktop.open(File) to display the finished product to the user.
As to how you do all that, it is really beyond the scope of an answer on SO. You would need to do the tutorial on each part, and come back with more specific questions.

Painting in Java

My app needs to display information (lines and rectangles). I was thinking of using JPanel, but I am not sure.
The problem is that the information is stored in a DB, but when the app is launched, eventually new information will get into the DB, and should be displayed as well. Also, the existing displayed information must remain.
Also, it would need at leats two zones for displaying info. One for lines and another for rectangles. Both with the problem of incoming information.
What is the (best) way to add new elements to a graphic without loosing what has been displayed before?
Have a look at Canvas and Graphics (Tutorial). You need to add the Canvas to a JContainer for example JPanel. With JDBC you can connect to a Database and execute SQL Statement.

Categories

Resources