How do I get the height of a menu bar control in a Java SWT shell window?
看来,不同的非洲顾问办公室在双壳窗口顶端的菜单上具有不同的高度。 因此,如果我能够达到菜单的确切高度,那将是巨大的。 男用二苯乙胺的甲型异构体并没有达到该目标。
How do I get the height of a menu bar control in a Java SWT shell window?
看来,不同的非洲顾问办公室在双壳窗口顶端的菜单上具有不同的高度。 因此,如果我能够达到菜单的确切高度,那将是巨大的。 男用二苯乙胺的甲型异构体并没有达到该目标。
页: 1 Rectangle RecBounds ( of the org.eclipse.swt.widgets. Menu
。 但问题是,该方法有缺省无障碍环境>。 其签名表明,它曾被用于“public
, 有时是先期。 无论如何,解决你的问题可能有许多途径:
height of the shell
and subtracting the height of title area
and height of client area
. Problem is how to find the title area height?
Reflection
. See the below code for more details. Specially the static int getMenuHeight(Menu parent)
method.<><>> 代码>说明: <>strong>/strong>Menu
para amount should be the top and the visible menu instance. 因为,对一些非洲顾问办公室来说,暗藏的子器是在传单上建立的。 此外,APICA在Vista机器上测试,在SUN JDK1.6_b18下运行3.62ec。
<>>>>>t>>Code:
import java.lang.reflect.Method;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
public class MenuTest {
public static void main (String [] args)
{
Display display = new Display ();
final Shell shell = new Shell (display);
final Menu bar = new Menu (shell, SWT.BAR);
shell.setMenuBar (bar);
final Composite c = new Composite(shell, SWT.NONE);
c.setLayout(new GridLayout());
c.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,true));
MenuItem fileItem = new MenuItem (bar, SWT.CASCADE);
fileItem.setText ("&File");
Menu submenu = new Menu (shell, SWT.DROP_DOWN);
fileItem.setMenu (submenu);
MenuItem item = new MenuItem (submenu, SWT.PUSH);
item.addListener (SWT.Selection, new Listener () {
public void handleEvent (Event e) {
System.out.println(shell.getSize().y - shell.getClientArea().height);
System.out.println(getMenuHeight(bar));
}
});
item.setText ("Select &All Ctrl+A");
item.setAccelerator (SWT.MOD1 + A );
shell.setSize (200, 200);
shell.open ();
while (!shell.isDisposed()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
static int getMenuHeight(Menu parent)
{
try {
Method m = Menu.class.getDeclaredMethod("getBounds", null);
m.setAccessible(true);
Rectangle r = (Rectangle) m.invoke(parent, null);
return r.height;
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
}
为了做到这一点,你将达到菜单和产权条条顶峰,并降低产权酒吧的高度。
int menuTitleHeight = x.getWindow().getHeight() - x.getWindow().getContentPane().getHeight();
int titleHeight = x.getWindow().getHeight() - x.getWindow().getRootPane().getHeight();
int menuHeight = x.getWindow().getHeight() - x.getWindow().getRootPane().getHeight();
Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...
Check this, List<String> list = new ArrayList<String>(); for (int i = 0; i < 10000; i++) { String value = (""+UUID.randomUUID().getLeastSignificantBits()).substring(3, ...
I am in the middle of solving a problem where I think it s best suited for a decorator and a state pattern. The high level setting is something like a sandwich maker and dispenser, where I have a set ...
I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I ...
I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...
If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...
I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....
I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...