本文整理汇总了Java中org.eclipse.swt.widgets.FontDialog类的典型用法代码示例。如果您正苦于以下问题:Java FontDialog类的具体用法?Java FontDialog怎么用?Java FontDialog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FontDialog类属于org.eclipse.swt.widgets包,在下文中一共展示了FontDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addSelectionListeneronToFontButton
import org.eclipse.swt.widgets.FontDialog; //导入依赖的package包/类
private void addSelectionListeneronToFontButton(Button fontButton, TableEditor fontEditor) {
fontButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String fontdata = "";
dialog = new FontDialog(Display.getCurrent().getActiveShell(), SWT.NONE);
dialog.setText("Select Font");
String string = formatMap.get(excelFormats[4]);
fontdata = checkDefaultValue(fontEditor, fontdata, string);
RGB checkDefaultColor = checkDefaultColor(fontdata, string);
dialog.setRGB(checkDefaultColor);
FontData defaultFont = new FontData(fontdata);
dialog.setFontData(defaultFont);
FontData newFont = dialog.open();
RGB rgb = dialog.getRGB();
String convertRGBToHEX = convertRGBToHEX(rgb);
if (newFont != null) {
fontEditor.getItem().setText(1, newFont.toString() + "|" + convertRGBToHEX);
}
}
});
}
示例2: getFontChooser
import org.eclipse.swt.widgets.FontDialog; //导入依赖的package包/类
private FontData getFontChooser(final Composite parent,String title,FontData fontData){
final FontData selection = new FontData(fontData.getName(),fontData.getHeight(),fontData.getStyle());
Label label = new Label(parent, SWT.NULL);
label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true));
label.setText(title);
Button button = new Button(parent, SWT.PUSH);
button.setLayoutData(getAlignmentData(MINIMUM_CONTROL_WIDTH,SWT.FILL));
button.setText(TuxGuitar.getProperty("choose"));
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
Font font = new Font(parent.getDisplay(),selection);
FontDialog fontDialog = new FontDialog(parent.getShell());
fontDialog.setFontList(font.getFontData());
FontData fd = fontDialog.open();
if(fd != null){
selection.setName( fd.getName() );
selection.setHeight( fd.getHeight() );
selection.setStyle( fd.getStyle() );
}
font.dispose();
}
});
return selection;
}
示例3: addFontButtonListeners
import org.eclipse.swt.widgets.FontDialog; //导入依赖的package包/类
private void addFontButtonListeners(final Button button, final FontData fontData){
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
if(StylesOption.this.initialized){
Font font = new Font(getDisplay(),fontData);
FontData[] fontDataList = font.getFontData();
font.dispose();
FontDialog fontDialog = new FontDialog(getShell());
fontDialog.setFontList(fontDataList);
FontData result = fontDialog.open();
if(result != null){
loadFontData(result, fontData,button);
}
}
}
});
}
示例4: onChangeFont
import org.eclipse.swt.widgets.FontDialog; //导入依赖的package包/类
private void onChangeFont() {
FontData selectedFont;
final FontDialog fontDialog = new FontDialog(_btnChangeFont.getShell());
fontDialog.setFontList(_selectedFontData);
fontDialog.setEffectsVisible(false);
fireOpenEvent(true);
{
selectedFont = fontDialog.open();
}
fireOpenEvent(false);
if (selectedFont != null) {
fireFontChanged(selectedFont);
}
}
示例5: FontPicker
import org.eclipse.swt.widgets.FontDialog; //导入依赖的package包/类
public FontPicker(final Composite parent, Font originalFont) {
super(parent, SWT.NONE);
if (originalFont == null) throw new IllegalArgumentException("null");
update(originalFont.getFontData()[0]);
addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
FontDialog dialog = new FontDialog(new Shell(Display.getDefault(), SWT.SHELL_TRIM));
dialog.setFontList(fontData);
FontData selected = dialog.open();
if (selected != null) {
update(selected);
pack(true);
}
}
});
}
示例6: openFontDialog
import org.eclipse.swt.widgets.FontDialog; //导入依赖的package包/类
/**
*
* void
*/
private void openFontDialog() {
FontDialog dialog = new FontDialog(UiCorePlugin.getShell(), SWT.NONE);
if (fontListOfDialog[0] != null) {
if (fontListOfDialog != fontList) {
dialog.setFontList(fontListOfDialog);
} else {
dialog.setFontList(fontList);
}
} else {
dialog.setFontList(fontList);
}
fontListOfDialog[0] = dialog.open();
defaultFontPreviewLabel.setText(getFormatedFontString(fontListOfDialog));
}
示例7: main
import org.eclipse.swt.widgets.FontDialog; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args)
{
Display display = new Display();
Shell shell = new Shell(display);
// displayAllLoadedFonts(shell);
loadFont(shell, "amigaforeverpro2.ttf", 8);
loadFont(shell, "E:/AAEW/dev/ws_bts_v2/org.bbaw.bts.ui.font.egyFont/font/FreeSerif.ttf", 8);
displayAllLoadedFonts(shell);
FontDialog dialog = new FontDialog(shell);
dialog.open();
Font f = new Font(display, dialog.getFontList());
}
示例8: widgetSelected
import org.eclipse.swt.widgets.FontDialog; //导入依赖的package包/类
@Override
public void widgetSelected(SelectionEvent ignored)
{
FontDialog fontDialog = new FontDialog(parentShell, SWT.OPEN);
fontDialog.setFontList(bzStyledText.getBrailleFont().getFontData());
FontData fontData = fontDialog.open();
if(fontData == null)
return;
bzStyledText.setBrailleFont(new Font(parentShell.getDisplay(), fontData));
}
示例9: activate
import org.eclipse.swt.widgets.FontDialog; //导入依赖的package包/类
/** Opens the color dialog. */
@Override
public void activate()
{
final FontDialog dialog = new FontDialog(shell);
if (value != null)
dialog.setFontList(new FontData[] { value });
value = dialog.open();
if (value != null)
fireApplyEditorValue();
}
示例10: widgetSelected
import org.eclipse.swt.widgets.FontDialog; //导入依赖的package包/类
@Override
public void widgetSelected(final SelectionEvent e) {
final FontDialog dialog = new FontDialog(WorkbenchHelper.getShell());
dialog.setEffectsVisible(false);
FontData data = toFontData(currentValue);
dialog.setFontList(new FontData[] { data });
data = dialog.open();
if (data != null) {
modifyAndDisplayValue(toGamaFont(data));
}
}
示例11: createFontArea
import org.eclipse.swt.widgets.FontDialog; //导入依赖的package包/类
private void createFontArea(Composite composite)
{
Composite themesComp = new Composite(composite, SWT.NONE);
themesComp.setLayout(new GridLayout(3, false));
themesComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
Label label = new Label(themesComp, SWT.NONE);
label.setText(Messages.ThemePreferencePage_FontNameLabel);
fFont = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT);
fFontText = new Text(themesComp, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
fFontText.setText(toString(fFont));
fFontText.setFont(fFont);
fFontText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
Button selectFontButton = new Button(themesComp, SWT.PUSH);
selectFontButton.setText(Messages.ThemePreferencePage_SelectFontButtonLabel);
selectFontButton.addSelectionListener(new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
final FontDialog fontDialog = new FontDialog(getShell());
fontDialog.setFontList(fFont.getFontData());
final FontData data = fontDialog.open();
if (data != null)
{
setFont(new Font(fFont.getDevice(), fontDialog.getFontList()));
}
}
});
}
示例12: selectAndSaveFont
import org.eclipse.swt.widgets.FontDialog; //导入依赖的package包/类
/**
* shows font dialog and save user choice to preferences
*
* @param isTitle true if must set font for title, false for text
*/
private void selectAndSaveFont (final boolean isTitle) {
display.asyncExec(new Runnable() {
@Override
public void run() {
FontDialog fd = new FontDialog(shell);
fd.setText(DesktopDrinViewerConstants.i18nMessages.getString("selectfont"));
fd.setRGB(new RGB(0, 0, 0));
fd.setFontList(DrinViewer.getNotificationFont(display, isTitle));
if (fd.open() != null) {
// save font
String namePref = (isTitle) ? DesktopDrinViewerConstants.PREFS_TITLEFONTNAME :
DesktopDrinViewerConstants.PREFS_TEXTFONTNAME;
String sizePref = (isTitle) ? DesktopDrinViewerConstants.PREFS_TITLEFONTSIZE :
DesktopDrinViewerConstants.PREFS_TEXTFONTSIZE;
String stylePref = (isTitle) ? DesktopDrinViewerConstants.PREFS_TITLEFONTSTYLE :
DesktopDrinViewerConstants.PREFS_TEXTFONTSTYLE;
prefs.put(namePref, fd.getFontList()[0].getName());
prefs.putInt(sizePref, fd.getFontList()[0].getHeight());
prefs.putInt(stylePref, fd.getFontList()[0].getStyle());
try {
prefs.flush();
} catch (BackingStoreException e) {
e.printStackTrace();
}
}
}
});
}
示例13: handleChangeFontPressed
import org.eclipse.swt.widgets.FontDialog; //导入依赖的package包/类
/**
* This method is invoked when the user selects the "Change" font button. It
* opens the FontDialog to allow the user to change the font.
*/
protected void handleChangeFontPressed() {
FontDialog dialog = new FontDialog(getShell());
FontData data = prefs.getFontData();
dialog.setFontList(new FontData[] { data });
data = dialog.open();
if (data != null) {
prefs.setFontData(data);
}
updateFontName();
}
示例14: construct
import org.eclipse.swt.widgets.FontDialog; //导入依赖的package包/类
public Control construct(Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL)
.grab(true, true).applyTo(composite);
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(composite);
final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
final Text t = new Text(composite, SWT.BORDER | SWT.NONE);
t.setText("Example text");
t.setBounds(80, 2, 300, 20);
Button button = new Button(composite, SWT.PUSH);
button.setText("Change Font");
button.setBounds(2, 30, 100, 30);
button.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("deprecation")
public void widgetSelected(SelectionEvent e) {
FontDialog fd = new FontDialog(shell, SWT.NONE);
fd.setText("Select Font");
fd.setRGB(new RGB(0, 0, 255));
FontData defaultFont = new FontData("Courier", 10, SWT.BOLD);
fd.setFontData(defaultFont);
FontData newFont = fd.open();
if (newFont == null)
return;
t.setFont(new Font(shell.getDisplay(), newFont));
t.setForeground(new Color(shell.getDisplay(), fd.getRGB()));
}
});
return null;
}
示例15: setFont
import org.eclipse.swt.widgets.FontDialog; //导入依赖的package包/类
/**
* Sets the font related data to be applied to the text in page 2.
*/
void setFont() {
FontDialog fontDialog = new FontDialog(getSite().getShell());
fontDialog.setFontList(text.getFont().getFontData());
FontData fontData = fontDialog.open();
if (fontData != null) {
if (font != null)
font.dispose();
font = new Font(text.getDisplay(), fontData);
text.setFont(font);
}
}