类java.awt.Taskbar源码实例Demo

下面列出了怎么用java.awt.Taskbar的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: ghidra   文件: GhidraApplicationConfiguration.java
private static void platformSpecificFixups() {

		// Set the dock icon for macOS
		if (Taskbar.isTaskbarSupported()) {
			Taskbar taskbar = Taskbar.getTaskbar();
			if (taskbar.isSupported(Taskbar.Feature.ICON_IMAGE)) {
				taskbar.setIconImage(ApplicationInformationDisplayFactory.getLargestWindowIcon());
			}
		}

		// Set the application title for Linux.
		// This should not be necessary...hopefully in a future version of Java it will just work.
		Class<?> toolkitClass = Toolkit.getDefaultToolkit().getClass();
		if (toolkitClass.getName().equals("sun.awt.X11.XToolkit")) {
			try {
				final Field awtAppClassName = toolkitClass.getDeclaredField("awtAppClassName");
				awtAppClassName.setAccessible(true);
				awtAppClassName.set(null, "Ghidra");
			}
			catch (Exception e) {
				// Not sure what went wrong.  Oh well, we tried.
			}
		}
	}
 
源代码2 项目: PacketProxy   文件: GUIMain.java
/**
 * MacのDock上でにPacketProxyアイコンを表示する
 */
private void addDockIconForMac() throws Exception {
	if (!PacketProxyUtility.getInstance().isMac()) {
		return;
	}
	ImageIcon icon = new ImageIcon(getClass().getResource("/gui/icon.png"));
	Taskbar.getTaskbar().setIconImage(icon.getImage());
}
 
源代码3 项目: ghidra   文件: StandAloneApplication.java
private void setDockIcon() {
	if (Taskbar.isTaskbarSupported()) {
		Taskbar taskbar = Taskbar.getTaskbar();
		if (taskbar.isSupported(Taskbar.Feature.ICON_IMAGE)) {
			taskbar.setIconImage(ApplicationInformationDisplayFactory.getLargestWindowIcon());
		}
	}
}
 
源代码4 项目: demo-java-x   文件: DesktopFeatures.java
public static void main(String[] args) {
	if (Taskbar.isTaskbarSupported()) {
		System.out.println("Taskbar is supported - feature support breakdown:");
		Taskbar taskbar = Taskbar.getTaskbar();
		stream(Feature.values())
				.forEach(feature -> System.out.printf(" - %s: %s%n", feature, taskbar.isSupported(feature)));
	} else {
		System.out.println("Taskbar is not on your platform. :(");
	}
}
 
源代码5 项目: mzmine3   文件: DesktopSetup.java
@Override
public void run() {

  logger.finest("Configuring desktop settings");

  // Set basic desktop handlers
  final Desktop awtDesktop = Desktop.getDesktop();
  if (awtDesktop != null) {

    // Setup About handler
    if (awtDesktop.isSupported(Desktop.Action.APP_ABOUT)) {
      awtDesktop.setAboutHandler(e -> {
        MZmineGUI.showAboutWindow();
      });
    }

    // Setup Quit handler
    if (awtDesktop.isSupported(Desktop.Action.APP_QUIT_HANDLER)) {
      awtDesktop.setQuitHandler((e, response) -> {
        ExitCode exitCode = MZmineCore.getDesktop().exitMZmine();
        if (exitCode == ExitCode.OK)
          response.performQuit();
        else
          response.cancelQuit();
      });
    }
  }

  if (Taskbar.isTaskbarSupported()) {

    final Taskbar taskBar = Taskbar.getTaskbar();

    // Set the main app icon
    if ((mzMineIcon != null) && taskBar.isSupported(Taskbar.Feature.ICON_IMAGE)) {
      final java.awt.Image mzMineIconAWT = SwingFXUtils.fromFXImage(mzMineIcon, null);
      taskBar.setIconImage(mzMineIconAWT);
    }

    // Add a task controller listener to show task progress
    MZmineCore.getTaskController().addTaskControlListener((numOfWaitingTasks, percentDone) -> {
      if (numOfWaitingTasks > 0) {
        if (taskBar.isSupported(Taskbar.Feature.ICON_BADGE_NUMBER)) {
          String badge = String.valueOf(numOfWaitingTasks);
          taskBar.setIconBadge(badge);
        }

        if (taskBar.isSupported(Taskbar.Feature.PROGRESS_VALUE))
          taskBar.setProgressValue(percentDone);

      } else {

        if (taskBar.isSupported(Taskbar.Feature.ICON_BADGE_NUMBER))
          taskBar.setIconBadge(null);
        /*
         * if (taskBar.isSupported( Taskbar.Feature.PROGRESS_STATE_WINDOW))
         * taskBar.setWindowProgressState( MZmineCore.getDesktop().getMainWindow(),
         * Taskbar.State.OFF);
         */
        if (taskBar.isSupported(Taskbar.Feature.PROGRESS_VALUE))
          taskBar.setProgressValue(-1);
        /*
         * if (taskBar.isSupported( Taskbar.Feature.PROGRESS_VALUE_WINDOW))
         * taskBar.setWindowProgressValue( MZmineCore.getDesktop().getMainWindow(), -1);
         */
      }
    });

  }

  // Let the OS decide the location of new windows. Otherwise, all windows
  // would appear at the top left corner by default.
  // TODO: investigate if this applies to JavaFX windows
  System.setProperty("java.awt.Window.locationByPlatform", "true");

}
 
源代码6 项目: xdm   文件: DownloadWindow.java
public void update(Downloader d, String file) {
	titleLbl.setText(file);
	if (d.getProgress() > 0) {
		setTitle("[" + d.getProgress() + "%]" + file);
	} else {
		setTitle(file);
	}
	String statTxt = "";
	if (d.isConverting()) {
		statTxt = StringResource.get("TITLE_CONVERT");
	} else if (d.isAssembling()) {
		statTxt = StringResource.get("STAT_ASSEMBLING");
	} else {
		statTxt = StringResource.get("STAT_DOWNLOADING");
	}
	lblStat.setText(statTxt);
	// StringBuilder sb = new StringBuilder();
	// sb.append((d.isAssembling() ? StringResource.get("STAT_ASSEMBLING")
	// : StringResource.get("DWN_DOWNLOAD")));
	// sb.append(" ");
	// sb.append(FormatUtilities.formatSize(d.getDownloaded()));
	// sb.append(" ");
	// sb.append(d.getType()==XDMConstants.HTTP?)

	lblDet.setText((d.isAssembling() ? StringResource.get("STAT_ASSEMBLING") : StringResource.get("DWN_DOWNLOAD"))
			+ " " + FormatUtilities.formatSize(d.getDownloaded()) + " "
			+ ((d.getType() == XDMConstants.HTTP || d.getType() == XDMConstants.DASH)
					? "/ " + FormatUtilities.formatSize(d.getSize())
					: "( " + d.getProgress() + " % )"));
	lblSpeed.setText(FormatUtilities.formatSize(d.getDownloadSpeed()) + "/s");
	lblETA.setText("ETA " + d.getEta());
	prgCircle.setValue(d.getProgress());
	SegmentDetails segDet = d.getSegmentDetails();
	long sz = ((d.getType() == XDMConstants.HTTP || d.getType() == XDMConstants.FTP
			|| d.getType() == XDMConstants.DASH) ? d.getSize() : 100);
	segProgress.setValues(segDet, sz);
	if (Taskbar.isTaskbarSupported()) {
		Taskbar taskbar = Taskbar.getTaskbar();
		if(taskbar.isSupported(Feature.PROGRESS_VALUE_WINDOW)) {
			taskbar.setWindowProgressValue(this, d.getProgress());
		}
	}

}
 
源代码7 项目: xdm   文件: MainWindow.java
private void initWindow() {
	setIconImage(ImageResource.getImage("icon.png"));
	/* Set Dock icon in macOS */
	try {
		Taskbar.getTaskbar().setIconImage(ImageResource.getImage("icon.png"));
	} catch (final UnsupportedOperationException | SecurityException e) {
		System.out.println("Error setting Dock icon");
	}
	/* Re-open XDM from dock on macOS */
	if (XDMUtils.detectOS() == XDMUtils.MAC) {
		Desktop.getDesktop().addAppEventListener((AppReopenedListener) e -> XDMApp.getInstance().showMainWindow());
	}

	showTwitterIcon = true;
	showFBIcon = true;
	showGitHubIcon = true;
	fbUrl = XDMApp.APP_FACEBOOK_URL;
	twitterUrl = XDMApp.APP_TWITTER_URL;
	gitHubUrl = XDMApp.APP_HOME_URL;

	JLabel lblTitle = new JLabel(XDMApp.XDM_WINDOW_TITLE);
	lblTitle.setBorder(new EmptyBorder(scale(20), scale(20), scale(20), 0));
	lblTitle.setFont(FontResource.getBiggestFont());
	lblTitle.setForeground(ColorResource.getWhite());
	getTitlePanel().add(lblTitle);
	this.rightbox = Box.createVerticalBox();

	createMainMenu();
	rightbox.add(Box.createVerticalGlue());
	createTabs();
	getTitlePanel().add(rightbox, BorderLayout.EAST);

	BarPanel bp = new BarPanel();
	bp.setLayout(new BorderLayout());
	bp.add(Box.createRigidArea(new Dimension(0, scale(30))));
	bp.add(createSearchPane(), BorderLayout.EAST);

	JPanel panCenter = new JPanel(new BorderLayout());
	panCenter.setBackground(Color.WHITE);
	panCenter.add(bp, BorderLayout.NORTH);

	JPanel pClient = new JPanel(new BorderLayout());
	pClient.add(panCenter);
	pClient.add(createSidePanel(), BorderLayout.WEST);

	toolbar = createToolbar();
	pClient.add(toolbar, BorderLayout.SOUTH);

	add(pClient);

	sortStatusText = new String[4][2];

	sortStatusText[0][0] = StringResource.get("SORT_DATE_DESC");
	sortStatusText[0][1] = StringResource.get("SORT_DATE_ASC");

	sortStatusText[1][0] = StringResource.get("SORT_SIZE_DESC");
	sortStatusText[1][1] = StringResource.get("SORT_SIZE_ASC");

	sortStatusText[2][0] = StringResource.get("SORT_NAME_DESC");
	sortStatusText[2][1] = StringResource.get("SORT_NAME_ASC");

	sortStatusText[3][0] = StringResource.get("SORT_TYPE_DESC");
	sortStatusText[3][1] = StringResource.get("SORT_TYPE_ASC");
	// test ui

	// setMenuActionListener(this);

	lv = new DownloadListView(panCenter);
	filter();

	createPopupMenu();

	ToolTipManager.sharedInstance().setInitialDelay(500);
}
 
 类所在包
 同包方法