org.jdesktop.swingx.JXTipOfTheDay Java Examples

The following examples show how to use org.jdesktop.swingx.JXTipOfTheDay. 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: TipOfTheDay.java    From orbit-image-analysis with GNU General Public License v3.0 6 votes vote down vote up
public void showDialog(final boolean forceShow) {
    if (tipOfTheDay != null) {
        tipOfTheDay.showDialog(parentCompo, new JXTipOfTheDay.ShowOnStartupChoice() {
            public boolean isShowingOnStartup() {
                if (forceShow) return true;
                else return isStartupChoiceOption();
            }

            public void setShowingOnStartup(boolean showOnStartup) {
                setStartupChoiceOption(showOnStartup);
                setNextStartingTipLocation(tipOfTheDay.getCurrentTip());
            }
        });
    } else {
        logger.error("tip of the day has not been loaded correctly. Does the tips.properties file exist?");
    }
}
 
Example #2
Source File: TipOfTheDay.java    From otroslogviewer with Apache License 2.0 6 votes vote down vote up
public void showTipOfTheDayIfNotDisabled(Component parent) {
  Properties p = new Properties();
  try {
    p.load(this.getClass().getClassLoader().getResourceAsStream("tipoftheday.properties"));
    TipOfTheDayModel model = new RandomTipOfTheDayModel(TipLoader.load(p));
    JXTipOfTheDay jxTipOfTheDay = new JXTipOfTheDay(model);
    jxTipOfTheDay.showDialog(parent, new ShowOnStartupChoice() {

      @Override
      public void setShowingOnStartup(boolean arg0) {
        dataConfiguration.setProperty(GUI_SHOW_TIP_OF_THE_DAY, arg0);
      }

      @Override
      public boolean isShowingOnStartup() {
        return dataConfiguration.getBoolean(GUI_SHOW_TIP_OF_THE_DAY, true);
      }
    });
  } catch (IOException e) {
    LOGGER.warn("Can't load tip of the day: " + e.getMessage());
  }
}
 
Example #3
Source File: TipOfTheDay.java    From orbit-image-analysis with GNU General Public License v3.0 5 votes vote down vote up
public TipOfTheDay(Component parentCompo) {
    prefs = Preferences.userNodeForPackage(OrbitImageAnalysis.class);
    try {
        this.parentCompo = parentCompo;
        tipOfTheDay = new JXTipOfTheDay(loadModel());
        tipOfTheDay.setCurrentTip(getStartingTipLocation());

    } catch (Exception e) {
        logger.error("error loading tips.properties", e);
    }
}
 
Example #4
Source File: TipsOfTheDayDialog.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
public void shows() {
	String key = "tooltip";
	showDialog(null, new JXTipOfTheDay.ShowOnStartupChoice() {
		public boolean isShowingOnStartup() {
			return MTGControler.getInstance().get(key, "true").equalsIgnoreCase("true");
		}

		public void setShowingOnStartup(boolean x) {
			if (x)
				MTGControler.getInstance().setProperty(key, "true");
			else
				MTGControler.getInstance().setProperty(key, "false");
		}
	});
}
 
Example #5
Source File: BasicTipOfTheDayUI.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
  // the only reason for using this file instead if the SwingX
  // version is that for historical reasons we want our version of
  // JXTipOfTheDay, and the constant JXTipOfTheDay.CURRENT_TIP_CHANGED_KEY
  // is inlined in the SwingX class file
  if (JXTipOfTheDay.CURRENT_TIP_CHANGED_KEY.equals(evt.getPropertyName())) {
    showCurrentTip();
  }
}
 
Example #6
Source File: TipsOfTheDay.java    From Pixelitor with GNU General Public License v3.0 5 votes vote down vote up
public static void showTips(JFrame parent, boolean force) {
    try {
        if (nextTip == -1) {
            nextTip = tipPrefs.getInt(NEXT_TIP_NR_KEY, 0);
        }

        var tipOfTheDayModel = loadModel();
        int tipCount = tipOfTheDayModel.getTipCount();
        if (nextTip < 0) {
            nextTip = 0;
        }
        if (nextTip > tipCount - 1) {
            nextTip = tipCount - 1;
        }

        var size = new Dimension(480, 230);
        var tipOfTheDay = new JXTipOfTheDay(tipOfTheDayModel) {
            @Override
            public Dimension getPreferredSize() {
                return size;
            }
        };
        tipOfTheDay.setCurrentTip(nextTip);
        tipOfTheDay.showDialog(parent, tipPrefs, force);  // this stops until the user hits close

        int lastTipIndex = tipOfTheDay.getCurrentTip();
        if (lastTipIndex < tipCount - 1) {
            nextTip = lastTipIndex + 1;
        } else {
            nextTip = 0;
        }
    } catch (IOException ex) {
        Messages.showException(ex);
    }
}
 
Example #7
Source File: BasicTipOfTheDayUI.java    From Pixelitor with GNU General Public License v3.0 4 votes vote down vote up
public static ComponentUI createUI(JComponent c) {
  return new BasicTipOfTheDayUI((JXTipOfTheDay)c);
}
 
Example #8
Source File: BasicTipOfTheDayUI.java    From Pixelitor with GNU General Public License v3.0 4 votes vote down vote up
public BasicTipOfTheDayUI(JXTipOfTheDay tipPane) {
  this.tipPane = tipPane;
}