use of java.awt.HeadlessException in project bigbluebutton by bigbluebutton.
the class ScreenCapture method getMouseLocation.
private Point getMouseLocation() {
PointerInfo pInfo;
Point pointerLocation = new Point(0, 0);
try {
pInfo = MouseInfo.getPointerInfo();
} catch (HeadlessException e) {
pInfo = null;
} catch (SecurityException e) {
pInfo = null;
}
if (pInfo == null)
return pointerLocation;
return pInfo.getLocation();
}
use of java.awt.HeadlessException in project GNS by MobilityFirst.
the class ReplicaLatencyTest method main.
/**
* The main routine run from the command line.
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
try {
CommandLine parser = initializeOptions(args);
if (parser.hasOption("help") || args.length == 0) {
printUsage();
System.exit(1);
}
String alias = parser.getOptionValue("alias");
String host = parser.getOptionValue("host");
String port = parser.getOptionValue("port");
boolean debug = parser.hasOption("debug");
String closeActiveReplica = parser.getOptionValue("closeAR");
ReplicaLatencyTest test = new ReplicaLatencyTest(alias, host, port);
// Need this on to read the which replica is responding
//client.setEnableInstrumentation(true);
test.findSlowGuid(closeActiveReplica);
// send the reads and writes
test.readsAndWrites(closeActiveReplica);
//test.removeSubGuid();
client.close();
System.exit(0);
} catch (HeadlessException e) {
System.out.println("When running headless you'll need to specify the host and port on the command line");
printUsage();
System.exit(1);
}
}
use of java.awt.HeadlessException in project GNS by MobilityFirst.
the class CreateGuidTest method main.
/**
* The main routine run from the command line.
*
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
try {
CommandLine parser = initializeOptions(args);
if (parser.hasOption("help") || args.length == 0) {
printUsage();
System.exit(1);
}
String alias = parser.getOptionValue("alias");
new CreateGuidTest(alias != null ? alias : ACCOUNT_ALIAS);
System.exit(0);
} catch (HeadlessException e) {
System.out.println("When running headless you'll need to specify the host and port on the command line");
printUsage();
System.exit(1);
}
}
use of java.awt.HeadlessException in project GNS by MobilityFirst.
the class UserAuthPubKey method main.
/**
*
* @param arg
*/
public static void main(String[] arg) {
try {
JSch jsch = new JSch();
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle("Choose your privatekey(ex. ~/.ssh/id_dsa)");
chooser.setFileHidingEnabled(false);
int returnVal = chooser.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println("You chose " + chooser.getSelectedFile().getAbsolutePath() + ".");
// , "passphrase"
jsch.addIdentity(// , "passphrase"
chooser.getSelectedFile().getAbsolutePath());
}
String host = null;
if (arg.length > 0) {
host = arg[0];
} else {
host = JOptionPane.showInputDialog("Enter username@hostname", System.getProperty("user.name") + "@localhost");
}
String user = host.substring(0, host.indexOf('@'));
host = host.substring(host.indexOf('@') + 1);
Session session = jsch.getSession(user, host, 22);
// username and passphrase will be given via UserInfo interface.
UserInfo ui = new UserInfoPrompted();
session.setUserInfo(ui);
session.connect();
Channel channel = session.openChannel("shell");
channel.setInputStream(System.in);
channel.setOutputStream(System.out);
channel.connect();
} catch (HeadlessException | JSchException e) {
System.out.println(e);
}
}
use of java.awt.HeadlessException in project jdk8u_jdk by JetBrains.
the class RasterPrinterJob method printDialog.
/**
* Presents the user a dialog for changing properties of the
* print job interactively.
* @returns false if the user cancels the dialog and
* true otherwise.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
*/
public boolean printDialog() throws HeadlessException {
if (GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
attributes.add(new Copies(getCopies()));
attributes.add(new JobName(getJobName(), null));
boolean doPrint = printDialog(attributes);
if (doPrint) {
JobName jobName = (JobName) attributes.get(JobName.class);
if (jobName != null) {
setJobName(jobName.getValue());
}
Copies copies = (Copies) attributes.get(Copies.class);
if (copies != null) {
setCopies(copies.getValue());
}
Destination dest = (Destination) attributes.get(Destination.class);
if (dest != null) {
try {
mDestType = RasterPrinterJob.FILE;
mDestination = (new File(dest.getURI())).getPath();
} catch (Exception e) {
mDestination = "out.prn";
PrintService ps = getPrintService();
if (ps != null) {
Destination defaultDest = (Destination) ps.getDefaultAttributeValue(Destination.class);
if (defaultDest != null) {
mDestination = (new File(defaultDest.getURI())).getPath();
}
}
}
} else {
mDestType = RasterPrinterJob.PRINTER;
PrintService ps = getPrintService();
if (ps != null) {
mDestination = ps.getName();
}
}
}
return doPrint;
}
Aggregations