java.awt.Taskbar Java Examples

The following examples show how to use java.awt.Taskbar. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GhidraApplicationConfiguration.java    From ghidra with Apache License 2.0 6 votes vote down vote up
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.
			}
		}
	}
 
Example #2
Source File: GUIMain.java    From PacketProxy with Apache License 2.0 5 votes vote down vote up
/**
 * 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());
}
 
Example #3
Source File: StandAloneApplication.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void setDockIcon() {
	if (Taskbar.isTaskbarSupported()) {
		Taskbar taskbar = Taskbar.getTaskbar();
		if (taskbar.isSupported(Taskbar.Feature.ICON_IMAGE)) {
			taskbar.setIconImage(ApplicationInformationDisplayFactory.getLargestWindowIcon());
		}
	}
}
 
Example #4
Source File: DesktopFeatures.java    From demo-java-x with MIT License 5 votes vote down vote up
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. :(");
	}
}
 
Example #5
Source File: DesktopSetup.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
@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");

}
 
Example #6
Source File: DownloadWindow.java    From xdm with GNU General Public License v2.0 4 votes vote down vote up
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());
		}
	}

}
 
Example #7
Source File: MainWindow.java    From xdm with GNU General Public License v2.0 4 votes vote down vote up
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);
}