SWT/JFace : How to setFont on StatusLine? Windowbuilder broken? - java

I am a newbie to SWT. There are two problems which have taken up 3 days of resarch, trying, looking and searching. It's a good way to learn about new things, but I'm totally stumped by the following two persistent issues.
Question the first.
public class SWTMN extends ApplicationWindow
{
public final static Display d = new Display() ;
public SWTMN()
{
super(null);
Util.getImageRegistry() ;
addMenuBar();
addStatusLine();
... and so on. Later on ...
'SetStatus("This works fine!") ; // Works fine!!
I want to change the Font of the messages displayed by the statusline - and cannot find a way to do it.
Question the second.
Using a fresh Eclipse Indigo install (updated), creating a fresh (SWT/JFace- support) project, creating a New SWT ApplicationWindow all seems OK. The new file is available in the editor, and compiles - run produces a new, empty window, as it should.
Pressing the "Design" tab cause a modal progress dialogue to appear, with the message "Parsing...", which hangs at about 15% in. The editor windows underneath the progress message are replaced with a general message about a WindowsBuilder internal error - the last line of which is always
ClassCastException cannot cast org.eclipse.swt.shell.Shell to org.eclipse.swt.widget.Widget
(Because the "Parsing ..." progress bar is Application (buggering) modal, Eclipse is now stuffed, and I have to force a quit. Error message offers buttons to re-parse, switch to code which are tempting, and unusable).
Can you help me get Windowbuilder to start-up?
Many thanks for your help!

I'm going to ignore the built-in statusline, as being a solution only for those who are willing to have that exact and limited package of functionality.
It seems odd to me that a GUI-framework so focussed on looking good, would have something so poor as a statusline with a font that does not match the rest of the application.
Go figure.
I'm going to use panel as a custom toolbar, positioning it to the bottom of the frame.
Solution: Found, decided.

Related

Java: Close Specific JFrame Window

I hope everyone is doing well.
I've built a hangman game with a swing gui and everything works well enough, HOWEVER I am trying to make a popup show up by constructing a new JFrame object when the user wins or loses with a "you lose" message or what have you. No problem, but I want a specific window to close when activating the button listener on the popup, or when the 'x' is clicked. Assume my program has 3 windows up, and I only want to close 2 of them with one click.
I tried stuff in the area of
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
But that specific one closes all the windows. If you want to see more specific sample code, I would happy to provide it, but it didn't seem necessary for this question.
Either way, I can't figure out how to do this. Is this possible using Swing?
Thank you so much in advance. You guys are always so helpful.

extension of eclipse XMLMultiPageEditorPart - trigger refresh of tree-view manually

I am working on an eclipse-plugin which makes use of a custom XMLMultiPageEditor by extending XMLMultiPageEditorPart and XMLTableTreeView by extending XMLTableTreeViewer the second one as well implements a IResourceChangeListener.
I provide this plugin in eclipse-mars and eclipse-neon, however the wired behavior only shows up in eclipse-neon.
The editor works fine so far, the only problem is, that the tree-view is completely blank when a related xml-document is opened with it:
I can even modify the document in the source-view and save it .. the tree-view stays blank.
The only events which bring the tree-view to life are:
re-size the editor-window with the mouse
open some other document and than switch back to the tab of the open xml-doc.
After that, the tree-view works like it should. If I now change the xml in the source-view, the tree-view is updated immediately.
Any ideas how I could trigger a refresh of the tree-view manually ?
Is this maybe a bug in eclipse-neon ?
Ok, the problem seems to be, that the x/y size of the TreeViewer in eclipse-neon is initialized with (0,0). Here a hack to fix that:
...
public class MyXMLTableTreeViewer extends XMLTableTreeViewer implements IResourceChangeListener{
....
public MyXMLTableTreeViewer(Composite parent, IEditorPart parentEditor)
{
super(parent);
....
Point size = getControl().getSize();
size.x = 1000;
getControl().setSize(size);
}
It seems to be sufficient to only set x to some value ... 10 already gives an image, but the "node" section than looks a bit pressed, so I picket 1000.
Even if it is just internal API, it looks like a bug for me. So if you are further interested, take a look to the eclipse bugreport.
Both XMLMultiPageEditorPart and XMLTableTreeViewer are in internal packages. This means that they are not part of the Eclipse APIs and can be changed by the Eclipse developers without warning (see Eclipse API Rules of Engagement).
It may well be the case that something was changed between Eclipse Mars and Neon. You cannot rely on internal classes working the same between releases. It is not an Eclipse bug because you are not using official APIs.

Eclipse -> Java -> GUI Builder -> Can't get my UI to show properly in design mode

I am new to Java and Eclipse.
Somehow, my ui is not showing up the right way. Instead of seeing my frame, with the x to close at the top right, etc, and all the controls, I see a frame with no border.
See here: http://s7.postimg.org/miprf5ul7/Noooooooooooo.png
Here's my code: https://www.dropbox.com/s/74mltgsxcs9vjnf/PDF%20Monster.zip
I've spent countless hours working on this.
Please help me restore my UI, I'm desperate.
Thank you,
Whenever you can't view your ui the right way look at the code to see if there's red blocks in the right side. This indicates errors that may cause this.
In my case I had deleted a semicolon by accident somewhere...
If you fix the errors, it should be fine.
Also, you can simply try to comment out the errors to see if you can see the ui.

I am having troubles displaying a View as a popup window for a ToS

First post here, sorry if I do(did?) something wrong.
I have been developing an android application for a few weeks now and decided to add a User Agreement/Terms of Service to it. I created an xml called agreement.xml, and found this code...
https://gist.github.com/slaypni/3817116
(I found it on here somewhere actually but I couldnt find the original, this one is extremely similar, just a different class name.)
This worked perfectly for me for awhile but I recently altered a little bit of the code that calls it and tested on a new device and there is a strange issue.
I call it via...
View licenseView = View.inflate(UI, R.layout.agreement, null);
PopUpView ToS = new PopUpView(UI, licenseView);
ToS.show();
I run the code once on first application execution (and alter a few things such as button text and visibilities) to collect some user information. I then call it again after everything is done to display the newly downloaded agreement. The second time around it appears that none of the following code is working.
checkboxAcceptLicense = (CheckBox)UI.findViewById(R.id.checkLicenseAgreement);
textviewLicense = (TextView)UI.findViewById(R.id.textviewLicenseAgreement);
textviewLicense.setText(agreement);
buttonOK= (Button)UI.findViewById(R.id.buttonOK);
buttonCancel = (Button)UI.findViewById(R.id.buttonCancel);
etName = (EditText)UI.findViewById(R.id.etName);
etNumber = (EditText)UI.findViewById(R.id.etNumber);
etName.setText(prefs.getString("Name", null));
etNumber.setText(prefs.getString("Number", null));
buttonCancel.setOnClickListener(cancel);
buttonOK.setOnClickListener(accept);
which immediately follows the first block. I assume the issue is with the class I am using to display the item as a popup as I had some strange null pointer exceptions from it before. Currently there are no errors or anything, the code runs and the logging all around it shows up but the buttons are unresponsive and the text isnt set.
Thanks for any and all help!
Edit: I removed my null check because I assume this is evidence of the problem. On the second call it crashes with a nullpointerexception at line 74 of the popup class. I feel like it is a problem with the inflater but I really do not have a clue.
you can try to make a dialog instead it comes with a positive and negative buttons (ok/cancel)
and a content area which you can customize as you need check out this LINK

Hear text (screenreader) when mouse hovers over a JMenu object in Java / Windows

When using a screenreader, like NVDA, I want to be able to hear the text of the menu when I hover my mouse over it. I am able to hear the text when I push the buttons in the menubar, but not when I hover over them (the screenreader does reads the menu's of other programs when only hovering over the buttons).
I have set the AccessibleContext like below:
JMenu.getAccessibleContext().setAccessibleName("text");
JMenu.getAccessibleContext().setAccessibleDescription("more text");
I can set listeners to the objects that detects when a mouse hovers over them, but I do not know if/how I can cast a text to the screenreader to read. I tried ToolTipText, but that text is not read by the screenreader either. RequestFocus on the JMenu works, but setting the focus to an object just by hovering over it with the mouse provides other problems.
Does anyone knows how I can let a screenreader reads the JMenu-text when hovering with the mouse over the menubar?
I am using Java6 EE and the Java AccesBridge (version 2.02) on a Windows machine (XP and w7).
Swing is the weaker of the GUI technologies relating to accessibility in Java, compared to SWT at any rate. There's a few things you can try.
First is to make sure any accessibility fields are set (which you've started on). I can't remember if Java has an AccessibleRole field, but you can try setting that to menu and menuitem for your menu items.
Another thing you can try is the AccessibleMenu JMenu.AccessibleJMenu component. This one's the product of further reading, so I can't verify it from experience. But it and its surrounding classes may suit your needs.
If those don't work, you could try the option of talking to people's screen readers directly. Quentin C has a good library to do this, Universal Speech. I'm new to this library myself, but it does have a Java implementation in there that should show you how to use it in a Java program. Normally I wouldn't recommend this approach unless making the UI accessible really isn't working.
The last option would be to use the SWT components instead of the Swing ones, even if just for your menu bar. I wasn't sure how keen you'd be on this one, but it is an option and should resolve it.
I hope one of these suggestions helps you solve your problem.

Categories