user2869385
user2869385

Reputation:

Integrate many java programs into a single one

I have made java application in netbeans. In that i have three different frames with a lot of things in it with code. i have to use similar frames in the program. So i want to copy them. but the problem is that if i copy it, the code doesn't gets copied and so i have to manually copy the code and as the labels and buttons names get changed it is tedious to replace them in the code. So i want a solution like, if i make many applications and then integrate them or if, if i can duplicate that in the same program. Note: i have to make tens of copies of the frames, so cant do it manually

I have a main frame, which loads on opening the program. Then opens a menue frame and after that MAIN FRAME, SEE FRAME, BLANK FRAME. All those in capital are to be duplicated. Each of them have a lot of things. for example: blank has 3 buttons, a textfield and a label; Main has a jpanel having 3 labels two buttons and one jpanel in itself which has 3 textfields and 3 labels. See is also like this. Added this on the request of a comment.

See this:

enter image description here

enter image description here

In the program [jFrame] opens first

Upvotes: 1

Views: 157

Answers (2)

grepit
grepit

Reputation: 22392

Here is what I would recommend:

  1. Decouple your application as much as possible so you can reuse some of your classes.
  2. Use Ivey or Maven to manage your dependencies this way you can write code once and then integrate it into multiple projects.

I have provided the link below for you :

Upvotes: 0

MadProgrammer
MadProgrammer

Reputation: 347314

It's sounds like you are trying to copy the controls from one frame to another, instead you should be copying the class file.

Right click the file in the Project tab and select Copy from the drop down list

enter image description here

Right click the package node you want to copy the class to and select Paste from the drown list

enter image description here

If you want to rename the file as you copy it, you can use Refactor Copy instead, otherwise you will need to rename the copy manually from the Project view

Caveats

I just want to point out this basically goes against the principles of OOP and you should seriously reconsider your design and approach to this probelm.

Instead, you should be starting with a "base" class, which provides the basic functionality, even perhaps making it abstract and extending from this class each time you need to extend it's functionality.

Secondly, you should have a read through The Use of Multiple JFrames: Good or Bad Practice?

Thirdly, JFrame is not the best choice to start with, something like JPanel would be more suitable base component, allowing to place the component onto what ever top level container you wish or place it within or with other components, making the component infinitely more flexible and reusable...

IMHO

Upvotes: 2

Related Questions