MessageBox
(this is a JFrame)
Yes No
-
int r = JOptionPane.showConfirmDialog (null, "Could not find the IC_SVN_Utilities.settings file. Create one?","Warning",JOptionPane.YES_NO_OPTION);
-
try {
-
LS = new LocalSettings("IC_SVN_Utilities.settings",true);
-
}
-
}
User text input
-
String schema = UIUtilities.dialogUserInput(m_parent, "What Schema will this object exist in? Note this must be case seneitive e.g. \"APPS\"","Select Schema","");
-
if (schema.equals(metcarob.com.common.ui.dialogUserSelect.RET_CANCEL)) return;
-
if (schema.equals("")) return;
User Selection
import metcarob.com.common.ui.dialogUserSelect;
import metcarob.com.common.ui.dialogUserSelectInput;
import metcarob.com.common.ui.dialogUserSelectOutput;
OBJECT as id value
-
{ //This scope uses an OBJECT as the return value
-
List<String> cols = new ArrayList<String>();
-
-
dialogUserSelectInput inp = new dialogUserSelectInput();
-
inp.addCol("Col_ONE");
-
inp.addCol("Col_Two");
-
inp.addCol("Col_Three");
-
inp.addCol("Col_Four");
-
inp.addCol("Col_5");
-
RJMInteger id_obj = null;
-
for (int c=0;c<10;c++) {
-
-
id_obj = new RJMInteger(c);
-
try {
-
e.printStackTrace();
-
}
-
};
-
dialogUserSelectOutput output = metcarob.com.common.ui.UIUtilities.dialogUserSelectObject(null, "TITLE", "PROMP","Not in List",inp);
-
-
if (output.getSelectionOutcome().equals(metcarob.com.common.ui.dialogUserSelect.RET_CANCEL)) {
-
} else if (output.getSelectionOutcome().equals(metcarob.com.common.ui.dialogUserSelect.RET_NOTINLIST)) {
-
} else {
-
RJMInteger output_obj = (RJMInteger) output.getSelectedObject();
-
}
-
}
-
STRING as id value
-
{ //This scope uses a STRING as the return value
-
List<String> cols = new ArrayList<String>();
-
-
dialogUserSelectInput inp = new dialogUserSelectInput();
-
inp.addCol("Col_ONE");
-
inp.addCol("Col_Two");
-
inp.addCol("Col_Three");
-
inp.addCol("Col_Four");
-
inp.addCol("Col_5");
-
for (int c=0;c<10;c++) {
-
-
try {
-
e.printStackTrace();
-
}
-
};
-
-
String s = metcarob.com.common.ui.UIUtilities.dialogUserSelect(null, "TITLE", "PROMP","Not in List",inp);
-
-
if (s.equals(metcarob.com.common.ui.dialogUserSelect.RET_CANCEL)) {
-
} else if (s.equals(metcarob.com.common.ui.dialogUserSelect.RET_NOTINLIST)) {
-
} else {
-
}
-
}
Long running process
Code in init
-
super.paint(g);
-
g.fillRect(0, 0, getWidth(), getHeight());
-
-
}
-
});
Code in JFrame/Dialog
-
private void startLongOperation() {
-
this.getGlassPane().setVisible(true);
-
this.getGlassPane().repaint();
-
}
-
private void endLongOperation() {
-
this.getGlassPane().setVisible(false);
-
}
Code in actions
-
startLongOperation();
-
@Override
-
public void run() {
-
try {
-
//SOME CODE TO RUN A PROCESS
-
} finally {
-
endLongOperation();
-
}
-
}
-
});
File Chooser
(e.g. Browse for a file ...)
-
-
return f.getName().toLowerCase().endsWith(".db")
-
|| f.isDirectory();
-
}
-
-
return "DB Files";
-
}
-
});
-
int rVal = c.showOpenDialog(m_This);
-
tmp = c.getSelectedFile().getName();
-
tmp2 = c.getCurrentDirectory().toString();
-
}
-
return;
-
}
JFileChooser has a method called setFileSelectionMode, which can take three values:
- JFileChooser.FILES_ONLY
- JFileChooser.DIRECTORIES_ONLY
- JFileChooser.FILES_AND_DIRECTORIES
RJM Article Type
Work Notes