I created a new shell using the following code:
Shell shell = new Shell( parent, SWT.RESIZE);
I am getting a resizable shell but with a small title bar on the top which I dont want.
This is what I am getting after using this code.
Is there any way to remove that title bar/border in the top but with retaining resizable functionality.
Help would be appreciated. Thanks!
Related
I am using Jface MessageDialogWithToggle.openYesNoQuestion() to pop up the question dialog. But the dialog is not popping up in the center of the application.
Is there any way to make the dialog to display in the center of the application?
The dialog is normally shown centred on the parent shell you specify on the openYesNoQuestion method.
If you want to centre on some other shell you will have to create a new class extending MessageDialogWithToggle and override the
protected Point getInitialLocation(Point initialSize)
method to calculate the postion based on that shell.
I've created a dialog in the designer.
What is the best way to add a close icon to the dialog (for example in the title area, top left)?
I've tried adding a command in the designer, but could not get it to work: it didn't show up.
Could I access the dialog programmatically and add a close icon?
Normally the title area is hidden so there isn't much I can do there.
Commands in Dialog are a bit of a special case where they act like buttons in some cases but never appear in the title since this doesn't make as much sense in a dialog.
If you are using the GUI builder the simplest workaround for something like this is to not set a title and set the layout of the Dialog to BorderLayout.
In the center area just place your UI as usual. In the north do something like this:
Button closeButton = new Button(...);
Container myTitle = new Container(new BorderLayout());
myTitle.setUIID("DialogTitleArea");
myTitle.add(BorderLayout.CENTER, new Label("My Title", "DialogTitle")).
.add(BorderLayout.EAST, closeButton);
dlg.add(BorderLayout.NORTH, myTitle);
I´ve got some questions which shouldn´t be hard for a plugin developer.
My Plugin should read an INI File and then put the strings into a list. So how do I read a INI File in PDE is there any class? A example code would be amazing.
Further on I´m using Grid Layout, but I don´t know how I can control the columns. I have to set it at the beginning with:
layout.numColumns = 3;
But how do I change the row for a added control? (Button first row, text second row, list third row)
How can I add when I´m using GridLayout a vertical Scrollbar for my Listbox. It does not work for me in a GridLayout with the following code:
List listbox = new List(newproject, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
Rectangle clientArea = getShell().getClientArea ();
SAFETYVersions.setBounds (clientArea.x, clientArea.y, 100, 100);
I think when I´m using GridLayout i also have to define the size of the listbox?
-Last thing is there a simple checkbox in the widget library from SWT?
About listbox size, try following:
GridData gd = new GridData();
gd.heightHint = 100;
gd.widthHint = 100;
listbox.setLayoutData(gd);
listbox should be in GridLayout, of course.
My Plugin should read an INI File and then put the strings into a list. So how do I read a INI File in PDE is there any class? A example code would be amazing.
Take a look at the IFile interface.
Further on I´m using Grid Layout, but I don´t know how I can control the columns.
You use SWT.PUSH to put the widgets onto the Grid Layout. If layout.numColumns = 3;, that's 3 pushes for each row.
If you want a more complicated layout than a simple grid, you have to use Composites to group the widgets.
Last thing is there a simple checkbox in the widget library from SWT?
Yes, it's a Button with a SWT.CHECK style.
I would recommend you to use a property file instead.
Check out the java.util.Properties for more details.
You have everything there to help you out.
Drop me a line if you have problems and i will write a quick blog post for this at my blog.
Geirr
I am developing a Java application using Swing. I am using menu bar in my application. Whenever I click a menu item I need to open a new panel/frame within the window containing menu options.
To be precise I don't want to open a new window on clicking a menu item. What is the possible solution to this problem?
Thanks in advance.
If you want to put windows inside of other windows, you should look at JInternalFrame:
http://download.oracle.com/javase/tutorial/uiswing/components/internalframe.html
If you don't want to open a new window when clicking a menu item, CardLayout is a good choice. Also, don't overlook the convenience of using actions in your menus.
I am trying to undecorate a JInternalFrame, i.e. remove the default titlebar using the following code;
BasicInternalFrameUI ui = (BasicInternalFrameUI)internalFrame.getUI();
ui.getNorthPane().setPrefrredSize(new Dimension(0,0));
I works on windows but the second line throws a NullPointerException on MacOS
Any ideas why and how to get round it?
On Mac, the JInternalFrame doesn't have a north pane. Only execute the code on none Mac OS platforms;
// only remove the northpanel for none Mac OS
if(!(System.getProperty("os.name").startsWith("Mac OS"))){
BasicInternalFrameUI ui = (BasicInternalFrameUI) getUI();
ui.getNorthPane().setPrefrredSize(new Dimension(0,0));
}
So much about cross platform :-(
I don't use a Mac so I don't know what is causing the problem.
A JInternalFrame without the title bar loses its ability to be dragged. You should be able to accomplish the same goal by just adding a JPanel to the desktop. You would need to set the bounds of the panel. You might also want to use one of the internal frame custom borders on the panel:
UIManager.getBorder("InternalFrame.paletteBorder");
UIManager.getBorder("InternalFrame.optionDialogBorder");
Or maybe another option is to use:
internalFrame.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
This will replace the title bar with a small palette that can be used to drag the internal frame without the buttons or title.