Code example for JLabel

Methods: getBackgroundgetFont

0
	 *  
	 * @param options contains navigation buttons such as OK & Cancel 
	 * @return user response 
	 */ 
	public static int confirmCollectionMethod(Object[] options, String message, String linkMessage){
		JLabel label = new JLabel();
		Font font = label.getFont();
 
		// create some css from the label's font 
		StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";");
		style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";");
		style.append("font-size:" + font.getSize() + "pt;");
 
		String line2 = "";
		if (message != null) {
			line2 = "<p>" + message + "</p>";
		} 
		if (linkMessage == null){
			linkMessage = "";
		} 
		 
		// html content 
		JEditorPane ep = new JEditorPane("text/html", "<html><body style=\"" + style + "\">" //
				+ "<p>The device appears to have root access but does not have the ARO Collector installed.</p>" 
				+ line2
				+ linkMessage
				+ "</body></html>"); 
 
		// handle link events 
		ep.addHyperlinkListener(new HyperlinkListener() {
 
			@Override 
			public void hyperlinkUpdate(HyperlinkEvent e) {
				if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
					// ProcessHandler.launchUrl(e.getURL().toString()); // roll your own link launcher or use Desktop if J6+ 
 
					try { 
						Desktop.getDesktop().browse(new URI("https://developer.att.com/application-resource-optimizer/get-aro/download"));
					} catch (IOException e1) {
						// TODO Auto-generated catch block 
						e1.printStackTrace();
					} catch (URISyntaxException e1) {
						// TODO Auto-generated catch block 
						e1.printStackTrace();
					} 
 
				} 
			} 
		}); 
		ep.setEditable(false);
		ep.setBackground(label.getBackground());
 
		/* 
		 * -1 = window closed 
		 *  0 = OK 
		 *  1 = CANCEL 
Experience pair programming with AI  Get Codota for Java