2014-01-08 55 views

回答

0

如果我正确地阅读了源代码(而且它非常复杂),欢迎页面实际上是使用HTML而不是ImageHyperlink来完成的。

您的重写的paintHyperlink方法ImageHyperlink

protected void paintHyperlink(GC gc, Rectangle bounds) 

,所以你应该能够做同样的事情。

0

或者,作为一种选择,你可以尝试模仿外观,通过使用复合材料制造的标准方法(只是样式它作为你想,)):

private void demoHyperlinks() { 
    form.getBody().setLayout(new GridLayout()); 

    Composite container = new Composite(form.getBody(), SWT.NONE); 
    container.setLayout(new GridLayout()); 
    ImageHyperlink imageHyperlink = toolkit.createImageHyperlink(container, SWT.NULL); 
    imageHyperlink.setText("This is an image hyperlink."); 
    imageHyperlink.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_BLUE)); 
    imageHyperlink.setFont(new Font(form.getDisplay(), new FontData("Verdana", 20, SWT.BOLD))); 
    imageHyperlink.setImage(new Image(getShell().getDisplay(), "images/help.gif")); 
    imageHyperlink.addHyperlinkListener(new HyperlinkAdapter() { 
     @Override 
     public void linkActivated(HyperlinkEvent e) { 
      System.out.println("Image hyperlink activated."); 
     } 
    }); 

    Composite descriptionContainer = new Composite(container, SWT.NONE); 
    GridLayout gl = new GridLayout(); 
    gl.marginLeft = 25; 
    descriptionContainer.setLayout(gl); 
    Hyperlink hyperlink = toolkit.createHyperlink(descriptionContainer, "This is a hyperlink link", SWT.NULL); 
    hyperlink.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_BLUE)); 

    HyperlinkGroup group = new HyperlinkGroup(getShell().getDisplay()); 
    group.add(imageHyperlink); 
    group.add(hyperlink); 
    group.setHyperlinkUnderlineMode(HyperlinkSettings.UNDERLINE_NEVER); 

} 
相关问题