packagedev.equo;import staticorg.eclipse.swt.events.SelectionListener.*;importorg.eclipse.swt.*;importorg.eclipse.swt.events.SelectionAdapter;importorg.eclipse.swt.events.SelectionEvent;importorg.eclipse.swt.graphics.*;importorg.eclipse.swt.layout.*;importorg.eclipse.swt.program.Program;importorg.eclipse.swt.widgets.*;/** * Demonstrates the use of the Link widget with custom link colors. * <p> * This example creates a Link widget with a simple hyperlink and provides * buttons to customize the link foreground color. It shows how to: * </p> * <ul> * <li>Create a Link widget with HTML-like anchor tags</li> * <li>Set a custom link foreground color using setLinkForeground()</li> * <li>Reset the link color to the system default by passing null</li> * <li>Use ColorDialog to let users choose colors interactively</li> * </ul> */publicclassLinkSnippet{publicstaticvoidmain(String[]args){Displaydisplay=newDisplay();Shellshell=newShell(display);shell.setText("LinkSnippet");shell.setLayout(newRowLayout());Linklink=newLink(shell,SWT.NONE);link.setText("This a very simple link widget <a>https://www.equo.dev/</a> ");link.addSelectionListener(newSelectionAdapter(){@OverridepublicvoidwidgetSelected(SelectionEvente){if(e.text!=null&&!e.text.isEmpty()){try{Program.launch(e.text);}catch(Exceptionex){ex.printStackTrace();}}}});ButtonsetButton=newButton(shell,SWT.PUSH);setButton.setText("Choose link color");setButton.addSelectionListener(widgetSelectedAdapter(e->{System.out.println("default link color "+link.getLinkForeground());ColorDialogcolorDialog=newColorDialog(shell);RGBcolor=colorDialog.open();link.setLinkForeground(newColor(color));System.out.println("user selected link color "+link.getLinkForeground());}));ButtonresetButton=newButton(shell,SWT.PUSH);resetButton.setText("Reset link color");resetButton.addSelectionListener(widgetSelectedAdapter(e->{System.out.println("link color reset to system default");link.setLinkForeground(null);}));shell.pack();shell.open();while(!shell.isDisposed()){if(!display.readAndDispatch())display.sleep();}display.dispose();}}