loading multiple files using the options from menu bar in java - java

I have developed an editor using java Jpanel, component, etc....I have 2 text areas in the editor. When i choose open a file option from the menubar i'm able to load the content of the file to one textarea. But how can i add another option to the menu bar to load the content of another file to the second text box?

You can add two menu items, passing a reference to the desired destination text area to each Action. Alternatively, depending on your design, add a single menu item whose Action alternates between the two destination text areas.

Related

AEM(Adobe Experience Manager) | SPA Create React popup component that allows users to add other react components

Does anyone know how to create a react component with responsive grid and options so that we can drag and add other additional components?
The goal for us is to create a popup component and within this popup component we are going to name the component within the options menu. In the meantime also has the ability to drag and add other react components we have created. The purpose of the Popup Name is to be able to pass the data into react and link it with other AEM React component so that it can be triggered with an event.
For example
Add a button component
within the button component, there a option we can indicate which popup should it open if a user clicks on it
options menu for any other react components
once the user clicks on the button, it then looks for the popup component with the same name and the popup should be revealed.
options menu for the popup component
within the popup we can add whatever the component we want, for example, video component or image component.
the popup component, and within it, ability to add other component
Problem:
we tried several ways of doing it, adding responsive grid from #adobe/aem-react-editable-components into the functional popup component we created, it didnt work.
we also tried creating a class based popup component which extents from the responsive grid, this works however when we try to add the options menu in by creating the java file and the .content.xml, we weren't able to add any of the components in(even though the options are there, but its not responding). However, the name of the popup component is being passed into React correctly.
class based popup component that extents from responsive grid
when we console.log props, we do see the name of the component is being passed into react correctly along with other data
console.logged props
below are the xml files created
_cq_dialog is there for the option menu to work.
_cq_template, new, and _cq_editConfig is there for the responsive grid of adding additional components to work
it works all fine, until we add the java files which handles the functionality of passing the data from the options menu into react
Note: I also see other people trying to achieve the same thing as us, but the solutions they get points them to the SPA documentation which did not mention any complex use case.

JAVA Swing - Having multiple pages and using buttons to go through them

I am trying to make a program that essentially allows the user to switch through different areas of content for the user. The content area is essentially a place where you can draw different shapes.
For example, when the user starts up the program, they are able to edit and do things to the content area that pops up. However, there is the menu with the buttons "New", "Previous", "Next", "Delete".
When you click "New" you should be able to essentially create a new content area (not a new page).
When you make multiple content areas, you should be able to click "Next" or "Previous" to essentially go through the different content areas as soon as you click the button.
When you click "Delete" you should be able to delete the current content area you are at.
Finally, you should be able to not be able to click "Next" when you are at the end of the content areas and same with "Previous" when you are at the start.
Also, there should not be a creation of multiple pages, but rather the content area is essentially changing only. So, the menu bar stays in the same place with the content only changing when clicking the button. In this case, the content area is a space where you can draw shapes and when you add a new content area it should be a blank space and you can draw new things. As you access the previous content space, you should be able to see the old drawings
The card layout option seems like an option, but how would I take into account for there being a large number of pages?
Any ideas of how to approach this?

How Can I Clone a tab in a JTabbedPane?

I'm looking for a way to clone (duplicate) a whole tab (the selected one) in a JTabbedPane. Every time I take the tabwith getSelectedComponent() and add it to the pane, the title of the tab disapnö rs and I get no second tab. But there is no exception.
I tried to copy the currently selected tab. Each tab is a JPanel with a simple JTable on it and I want to get the selected tab two times.
As far as I know, the same swing component can't appear in multiple places in your GUI, so you would actually have to create new instances of all your UI elements for the "copied" tab and set their values to the same values of the first tab / connect them to the same domain objects.
In Swings, a component can be added to only one container. Adding it again to another container will have no effect.

Adding a Form to Swing Menu application

I am writing a Swing Menu based application. In the Menu I have File->New->Add Person
Here Add Person is a form and the new option will have many other forms.
When I click on any of this form it has to be added to the menu display area.
My question is how do I add it to the display area. should the display area already consist of any swing container to which I can add my Forms?
Also, note that each of these Forms that I have created are individual JFrames
Also, note that each of these Forms that I have created are individual JFrames
never to use lots of JFrames, this is road to the hell
My question is how do I add it to the display area. should the display area already consist of any swing container to which I can add my Forms?
if you need popup window then to use JDialog, only one JDialog and re_use that for another action
I am writing a Swing Menu based application. In the Menu I have File->New->Add Person Here Add Person is a form and the new option will have many other forms. When I click on any of this form it has to be added to the menu display area.
use CardLayout for swithing betweens views
You can go with the JInternalFrame option. It helps you to do your requirement, refer the links,
http://docs.oracle.com/javase/tutorial/uiswing/components/internalframe.html
Also refer this link for examples,
http://www.java2s.com/Code/Java/Swing-JFC/InterestingthingsusingJInternalFramesJDesktopPaneandDesktopManager2.htm
U can Display JFrame Forms on Click of Menu on Top of Parent Window.
U can make it act like a dialog by making the Parent Form disable and when Child Form Exits again we can Enable the parent Form.

Get selected menu item & display the corresponding item on frame

I have 3 conditions (3 menu items in menu). In those 3 items, how to get one menu item selected as soon as the frame opens and displays the content of that item by default?
Later on if we select other menu items, then corresponding contents on the frame will be displayed as usual. I have written very lengthy code for this GUI, so unable to paste here. But got stuck up at this point.
Simply invoke the actionPerformed() method of your ActionListener after your GUI is fully constructed. This is particularly easy if you have implemented the Action interface, as shown in How to Use Actions.
Using this example, add the following line near setVisible() to simulate adding a few random nodes to the graph:
gp.control.random.actionPerformed(new ActionEvent(gp, 0, null));
To simulate clicking a button, this line simulates adding a selected node:
gp.control.defaultButton.doClick();
By default all menu items are not selected when they are created. To make a menu item selected before you show it in your application you should change the state of the model. For the JMenu items it's easy by setSelected(true) and setPopupMenuVisible(true). For the JMenuItem items you have to setArmed(true). You can return back to the default state in the actionPerformed.

Categories