java控制台输出的字符没对齐_用java swt text显示字符串内容,但在text中 为什么格式是不对齐的呢?但在控制台上显示就是整齐的...

importorg.eclipse.swt.widgets.Display;importorg.eclipse.swt.widgets.Shell;importorg.eclipse.swt.SWT;importorg.eclipse.swt.widgets.Text;importorg.eclipse.swt.layout.GridDa...

import org.eclipse.swt.widgets.Display;

import org.eclipse.swt.widgets.Shell;

import org.eclipse.swt.SWT;

import org.eclipse.swt.widgets.Text;

import org.eclipse.swt.layout.GridData;

public class myGui {

protected Shell shell;

private Text text;

public static void main(String[] args) {

try {

myGui window = new myGui();

window.open();

} catch (Exception e) {

e.printStackTrace();

}

}

public void open() {

Display display = Display.getDefault();

createContents();

shell.open();

shell.layout();

while (!shell.isDisposed()) {

if (!display.readAndDispatch()) {

display.sleep();

}

}

}

protected void createContents() {

shell = new Shell();

shell.setSize(950, 800);

shell.setText("my Application");

text = new Text(shell, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL);

text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));

text.setBounds(50, 20, 776, 519);

String ss = "************************************************************\r\n"

+ "* *\r\n"

+ "* welecome my Gui *\r\n"

+ "* *\r\n"

+ "* Copyright by haha_xiao , 2014 *\r\n"

+ "* *\r\n"

+ "************************************************************\r\n";

text.setText(ss);

String rr = text.getText();

System.out.println(rr ); // 显示在控制台上的很整齐,但是在text中显示的,就不整齐,是什么原因呢

}

}

展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值