Skip to content

Instantly share code, notes, and snippets.

@Aroueterra
Last active February 10, 2020 06:55
Show Gist options
  • Save Aroueterra/bcec3b015b16a2487e255615b2a90731 to your computer and use it in GitHub Desktop.
Save Aroueterra/bcec3b015b16a2487e255615b2a90731 to your computer and use it in GitHub Desktop.
//Bound to windowOpened event of jFrame
public void TutorialStuff() {
List<String> list = new ArrayList<>();
// add 5 element in ArrayList
list.add("Input <NP> in the input pattern box to copy the name column values");
list.add("Input <#> in the input pattern box to copy the name column values");
list.add("Input <##> in the input pattern box to copy the name column values");
list.add("Input <###> in the input pattern box to copy the name column values");
list.add("Input <#####> in the input pattern box to copy the name column values");
//Use java settings properties to save state between application use
//Reference: https://stackoverflow.com/questions/31127908/how-to-make-a-do-not-ask-me-again-dialog-pop-up-box-with-java
JCheckBox dontAskMeAgain = new JCheckBox("Leave me alone!");
Object[] options1 = {dontAskMeAgain," Next Tip ",
" Close "};
JPanel panel = new JPanel();
Random r = new Random();
int randomitem = r.nextInt(list.size());
String randomElement = list.get(randomitem);
panel.add(new JLabel(randomElement));
panel.add(dontAskMeAgain);
int result = JOptionPane.showOptionDialog(null, panel, "Tip of the day!",
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
null, options1, null);
if (result == JOptionPane.NO_OPTION) {
//Action command / Listener stuff to change the label
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment