Reputation: 461
I am developing an Eclipse plugin. I have a view in Eclipse which shows a string. The Problem is that the string is layouted different than in console/debug view in eclipse. The string separates the characters with spaces no tabs (\t) or anything. how can i achieve that the Label in my view is showing the string like the console?
Console/debug view: http://s14.directupload.net/images/140410/ebydtn3n.png
My Eclipse view with a Label: http://s1.directupload.net/images/140410/yccg36sn.png
my view class:
public class PacketDumpView extends ViewPart {
private Label dumpLabel=null;
private Composite parent;
@Override
public void createPartControl(Composite parent) {
if(dumpLabel!=null)
return;
this.parent = parent;
GridLayout layout = new GridLayout(1, true);
parent.setLayout(layout);
}
@Override
public void setFocus() {
// TODO Auto-generated method stub
}
public void setValues(String hexDump) {
if(dumpLabel==null){
dumpLabel = new Label(parent, SWT.NONE);
dumpLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
dumpLabel.setText(hexDump);
}
}
Upvotes: 2
Views: 617
Reputation: 111142
You probably need a mono-spaced font for your label. The Text font is usually mono-spaced, you can set that as the font for your label using:
Font font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
dumpLabel.setFont(font);
Upvotes: 1