Save Button from Menu Bar - java

Good Morning,
I have built a Main Form with a MenuBar, in this MainForm I put a layeredpane where I show a JInternalFrame.
In my MenuBar I had put a JButton (Save). I would like that when I click on Save button I can retrieve the data from the mentioned JInternalFrame.

Related

Hide/Open JTable by a press of a button in JScrollPane

I want to represent data split into groups (categories) and when pressing a button of a category I want JTable to show below category button. I've built JScrollPane on it is placed JPanel which is a container of costume made panels (BoxLayout is used for placement in the container).
Costume made panel (CMP) to show category with a function to hide or show JTable
Now the problem is when i press button to show or hide table function is executed in code of CMP but JScrollPane does not refresh and does not show the action. It refreshes when you click on scroll bar. What can i do about it? Is there any better way to build something like this?

JFrame window with sub components

So I have created this JFrame window which has a lot of items like JLabel, JComboBox JTextField etc… At the bottom it has a "next" JButton.
I want that when a user clicks the next button, everything on the screen should be removed and replaced with stuffs from other class that I have created.
I only manage to open a new JFrame window whenever I click the next button. Can somebody please tell me how to remove all items from the screen and replace them with items from another class.
Thanks. I am a newbie so please give me the easiest way possible.
This sounds like a job for CardLayout
You could create a base panel in the BorderLayout.SOUTH position of your JFrame that would have your navigation buttons and have a number of panels added to your main panel being managed by CardLayout.
See Creating Wizard Dialogs with Java Swing
While the systematic thing for it is using CardLayout, you can imitate it if you don't want to learn how to use it!!
Create a Panel, add all items except the next button to this panel. Use BorderLayout to put the panel on top of the next button in the frame.
Now when the user press the next button you remove the panel (jframe.remove(panel)). create a new JPanel and add it using the BorderLayout again on top of the next button.

Panel not appearing on clicking button

I am using group radio buttons.What i want is that when i have selected the particular radio button then i press the button(call it show button) to display the results(on a chart placed in a panel) according to the selected radio button.The problem is when i press the show button it does not display results until i click the panel though i have not written any code when i press the panel.Here is my code
private void Show1MouseClicked(java.awt.event.MouseEvent evt) {
if (jRadioButton1.isSelected()) {
Panel.removeAll();
//some code
}
Panel.setVisible(true);
Panel.add(frame1);
Panel.setSize(700, 260);
}
Use a CardLayout, as shown here.
As to the chart itself, change the model if the data changes.
You probably need to call repaint() on your panel after the change. When you interact with the panel with your mouse it is calling repaint() behind the scenes.

Java gui frame overlapping

I have an applet which has two buttons on it:
When we click Button1 a Frame is opened.
When we click Button2 a Dialog (which is a child the new frame) is presented.
Now suppose if when we click on Button1 then the new frame that is opened is now positioned behind my applet and not completely aligned with it (not minimized)
Now, when I press Button2 the Dialog that pops up is in front of my applet, but when I click on the header of the dialog, then both the applet and frame are brought forward (they both get displayed simultaneously).
So I basically want to have just the applet behind the dialog whenever it is clicked (leaving the Frame in the background)
Add a frame.setVisible(false); in Button2's ActionListener.

Opening a new panel by just clicking a portion of the panel

I am using Net beans drag and drop GUI and in that i am displaying a chart in a jPanel and i want that when i click a portion of that chart then another panel opens up.I know we can write an event , when we click a whole panel(anywhere in panel) but i just want that when i click the small potion of that chart only then another panel opens up, how is this possible?
Attach a MouseListener to the panel. Detect the events, take action. See How to Write a Mouse Listener for more details.

Categories