So I have multiple forms for my current project and I have made classes that interact and do some utility work behind these forms.
However I am unable to access controls on other forms.
Say I have a text control on Form A and I want to use a class that receives/manipulates data from a completely different Form B.
My classes and Form B cannot see this control.
I have tried going to properties
code
variable modifiers set to "Public"
Unfortunately this does not seem to do the trick. Any ideas? I appreciate the help!!
I managed to solve the problem if anyone was curious.
Instead of being lazy I create public methods that allow me to communicate with them via setters and getters.
Thank you for anyone who tried to solve this for me.
Here's how you do it in Netbeans 7.2.1.
Open the form in Form Designer view.
Right click on the control whose visibility you want to change. You can click in the designer window, or in the Navigation pane to the left.
Select "Customise Code". This will bring up the Code Customizer window.
At the bottom of the Code Customizer window is a combo box labelled "Access", which is by default set to "Private". Set this to public.
Your control should now be accessible from other classes.
Related
Is there a solution for automatic creation of a complete class diagram from a Java project?
I've spent significant time looking online, trying Papyrus, Jar2UML, UML2Tools, DiaGen, jGraps, Class-visualizer, but have not found any currently working solution. Although most of the mentioned tools work (some do not currently work), they do not automatically generate a diagram of the full class hierarchy. I realise this might be the holy grail, and may require parameterisation, but thought it should be possible this day.
Requirements for wider use would be:
Currently working
Easy to use, or up-to-date tutorial on exactly how to do this
Does not require manual coding
Stand alone or Eclipse/NetBeans/IntelliJ plugin
Free
If there is nothing like this available, I'm considering creating something like this.
Out of the fact I am not sure to have all the classes of a project into one class diagram is a good idea because the result is unreadable with lot of classes, you can do that for instance with my tool BoUML. After you download/install/run it :
create a new project
select Java in the global menu Languages
for the first directory dialog appearing press the button cancel (you do not have a java catalog) then for the second directory dialog select the root directory containing all the sources of Java you want to model, then wait for end
in the browser on the left in any of the created class view or in a new one you create yourself do a right mouse click and choose New class diagram and double click on it to open it
probably you need to hide details of classes in the diagram to limit its size (you can do that later but better to do that right now in case you have lot of classes), in that case do a right mouse click into the diagram or on it into the browser to edit the drawing settings and set to yes the settings hide classes attributes and hide classes operations then confirm (button ok)
use the button binocular on the top (near print button), change kind to class then use buttons search then mark them then close
into the open diagram (shown into the right part of the window) do a right mouse click and choose add marked elements placing classes in random position then redo a right mouse click and choose automatic layout (you can also move the classes by yourself of course)
As you can see all the relations between classes are drawn, not only the generalization/realization. If you want only them without having for instance to hide all other relations one by one by hand you can develop a plug-out marking all the classes and generalization/realization of the model, then changing the procedure I given :
when you edit the drawing settings also go into the second tab and set to no the setting draw all relations
rather than to use the browser search (binocular button) to select all he classes use your plug-out
Anyway, again, to show all the classes into one diagram is a bad idea except if you have few.
In the page documentation you have the reference manual and (old) video tutorials including the two ones dedicated to Java and an other one about to write a plug-out
Note you can also use Doxygen to make your diagram without using an UML modeler
Although BoUML does an ok job on this, for a large project it's not pretty.
For a better solution to fully automatically create a basic but complete class diagram from source code, try the simple extractor I put together in Java:
https://github.com/folterj/ClassDiagramExtractor
The project uses reflection, and produces a diagram from all the packages in a folder (and sub-folders).
Notes:
No command line options - clone & run setting source folder in code
This produces a gv file for use with GraphViz (dot), available here: https://www.graphviz.org/
The result looks quite good, as it groups packages together and even uses coloring.
I have created a wizard in swt/jface. and i would like to remove the wizard container bar. I checked the documentation of the wizard page but couldn't find anything. Is their is a way to do this.Here a pic to explain better
So i need to remove this red rectangaled part
The first thing I'd try would be to try returning null from the methods that populate that area of the wizard UI.
If that doesn't work, you can always look into the Eclipse implementation of Wizard and WizardPage to see what draws that area and implement your own version that draws what you want - IWizard and IWizardPage are just interfaces after all. I've done something similar (though this was a few years ago) for implementing a much more customized wizard that ended up containing a GEF editor inside it as well.
When you open a dialog in Eclipse, where is a form layout, you can see that when you hover your mouse over some item, its label or space between them, there's an auxiliary arrow shown. Screenshot:
My question is: is there any (simple) way to achieve the same in Java with SWT and JFace?
Regards
No there is no standard way to achieve this through SWT or JFace, as it is not a built in feature. It is not that difficult to add on your own though.
Have a look at this ConfigurationBlock.java file from the PDE source. This class is the base for all option blocks in PDE preference pages. This exact same code snippet is also used by JDT but it has a different copy in OptionConfigurationBlock.java.
The method that gets called for each combo control is ConfigurationBlock#addHighlight(..), which is responsible for adding the highlight when the control is in focus or when mouse is hovering over its label.
I'm trying to build a small application using Java and SWT for the GUI. I'm looking for a way to store in some file the preferences set by the user, I mean, if the window was resized then that new size should be saved for next time the application starts. The same thing with some controls like textbox and so on.
I came up with two ideas to solve this:
Use the classic hand-made .ini files to store those preferences. But it appears to be ugly and hard to maintain.
Serialization/Deserialization of the whole class that contains the GUI. Dunno if this is even possible.
Any ideas? What should I do?
Thanks in advance.
Added:
I'm not doing an Eclipse RCP project, it's just a normal SWT application.
More:
I've already tried with serialization, but SWT widgets doesn't support it, so the only other option that I've found is create another class, say Configuration, mark it as serializable and hold there the values of my widgets. Almost like using java.util.prefs.Preferences, but not as simple.
I'm still waiting to see if there is another way to do this, maybe with some binding involved.
Have a look at Memento design pattern.
Eclipse RCP already reuses this principle, you can refer to the following interface for more information:
org.eclipse.ui.IMemento
If I have Java program and I need to alter it to an interface and include icons,
is there any easy I can do this and is there a good application that can help me to do it ?
or do I have to code it in myself?
Nop, /me thinks ur need 1337 mad Java programin' skillz!
Translation for the rest of the world: Sorry, you'll need to program in Java.
Added: Hey, what's with the downvotes? He started it! :P Besides - no matter if he wants to add or modify (the original text wasn't clear on this) the UI of a Java program, he will need to program in Java to bring his UI together with the code. There is no miracle tool that can allow you to draw an UI and it will suddenly do what you do.
Netbeans has a Swing GUI Builder. Quoting from their website. Let's hope this doesn't count has hidden advertising :)
Design Swing GUIs by dragging and
positioning GUI components from a
palette onto a canvas. The GUI builder
automatically takes care of the
correct spacing and alignment. Click
into JLabels, JButtons, ButtonGroups,
JTrees, JTextFields, ComboBoxes and
edit their properties directly in
place. You can use the GUI builder to
prototype GUIs right in front of
customers.
If you want to add a UI to your Java program there are tools to help you, such as the Swing GUI Builder inside of IntelliJ Idea. However, you're still going to have to write the appropriate code to hook into the UI.
It's just a website? Well depending on whether it uses CSS you might be able to just modify a .css file. This will only let you modify how the site looks as opposed to works.
See here for an example of how this technology works. However this depends on how css-dependent the website is and it's possible you may still run into some difficulties.
You want to use a Java framework to help you with the UI. For example, you can use JSF (Javaserver faces), which allows you to drag and drop components for a UI onto the site. Otherwise, you can use web programs such as Dreamweaver to design the UI, before coding the backend logic yourself in java.