簡體   English   中英

Windows 10中Java SWT庫的可怕布局

[英]Java SWT library horrible layout in Windows 10

我使用用於GUI的SWT庫開發了一個桌面應用程序。 在Windows 7上運行應用程序運行良好,布局干凈。 我試圖在Windows 10上運行相同的應用程序,這真是災難! 字體巨大並且切開了窗戶,太可怕了!

我禁用了顯示比例縮放功能,並將100%放置在視圖選項中,但是什么也沒有,問題仍然存在。 我怎么解決這個問題?

感謝那些想幫助我的人。

 java, 
 Snippet: import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Button; import org.eclipse.wb.swt.SWTResourceManager; public class mySWTApp extends Shell { private Text txt_name; private Text txt_surname; /** * Launch the application. * @param args */ public static void main(String args[]) { try { Display display = Display.getDefault(); mySWTApp shell = new mySWTApp(display); shell.open(); shell.layout(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } catch (Exception e) { e.printStackTrace(); } } /** * Create the shell. * @param display */ public mySWTApp(Display display) { super(display, SWT.SHELL_TRIM); setBackground(SWTResourceManager.getColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT)); setBackgroundMode(SWT.INHERIT_DEFAULT); setLayout(new GridLayout(1, false)); Composite composite = new Composite(this, SWT.BORDER); composite.setBackground(SWTResourceManager.getColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT)); composite.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL)); composite.setLayout(new GridLayout(2, false)); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Label lblNewLabel = new Label(composite, SWT.NONE); lblNewLabel.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL)); lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblNewLabel.setText("Name"); txt_name = new Text(composite, SWT.BORDER); txt_name.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblNewLabel_1 = new Label(composite, SWT.NONE); lblNewLabel_1.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL)); lblNewLabel_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblNewLabel_1.setText("Surname"); txt_surname = new Text(composite, SWT.BORDER); txt_surname.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Button btn_add = new Button(composite, SWT.NONE); btn_add.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.NORMAL)); GridData gd_btn_add = new GridData(SWT.CENTER, SWT.CENTER, false, false, 2, 1); gd_btn_add.widthHint = 126; btn_add.setLayoutData(gd_btn_add); btn_add.setText("Insert"); createContents(); } /** * Create contents of the shell. */ protected void createContents() { setText("Basic Name"); setSize(450, 135); } @Override protected void checkSubclass() { // Disable the check that prevents subclassing of SWT components } } 

我最近遇到了這個問題,並認為它與Windows 10有關。一些研究表明,實際原因是Windows 10附帶的新PC的分辨率更高! Perfectmobile社區描述了一個非常簡單的解決方案:高分辨率筆記本電腦的月食解決方案 我按照說明進行了操作,確保更改下載的清單文件的名稱以匹配我的應用程序的名稱,並且一切正常! 在此幻燈片中,您還可以找到有關在高分辨率屏幕縮放SWT的有用信息,以了解如何使應用程序dpi識別。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM