Java Code Examples for org.jdesktop.swingx.JXTipOfTheDay

The following examples show how to use org.jdesktop.swingx.JXTipOfTheDay. These examples are extracted from open source projects. 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
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 Project: otroslogviewer   Source File: TipOfTheDay.java    License: 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
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
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 Project: Pixelitor   Source File: BasicTipOfTheDayUI.java    License: 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 Project: Pixelitor   Source File: TipsOfTheDay.java    License: 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 Project: Pixelitor   Source File: BasicTipOfTheDayUI.java    License: 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 Project: Pixelitor   Source File: BasicTipOfTheDayUI.java    License: GNU General Public License v3.0 4 votes vote down vote up
public BasicTipOfTheDayUI(JXTipOfTheDay tipPane) {
  this.tipPane = tipPane;
}