use of javax.swing.JTextArea in project zaproxy by zaproxy.
the class DynamicSSLWelcomeDialog method initLayout.
private void initLayout() {
if (Model.getSingleton().getOptionsParam().getViewParam().getWmUiHandlingOption() == 0) {
this.setSize(480, 300);
}
this.setPreferredSize(new Dimension(480, 300));
JTextArea txtSslWontWork = new JTextArea();
txtSslWontWork.setEditable(false);
// XXX: this doesn't work like expected, it should be the same color as the control's background :-/
txtSslWontWork.setBackground(SystemColor.control);
txtSslWontWork.setTabSize(4);
txtSslWontWork.setWrapStyleWord(true);
txtSslWontWork.setLineWrap(true);
txtSslWontWork.setForeground(Color.BLACK);
txtSslWontWork.setText(Constant.messages.getString("dynssl.text.sslwontwork"));
getContentPane().setLayout(new BorderLayout());
final JPanel contentPanel = new JPanel();
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
contentPanel.setLayout(new BorderLayout(0, 0));
final JPanel contentIconPane = new JPanel();
contentPanel.add(contentIconPane, BorderLayout.WEST);
final JLabel lblCertificateIcon = new JLabel("");
lblCertificateIcon.setIcon(new ImageIcon(DynamicSSLWelcomeDialog.class.getResource("/resource/certificate48x54.png")));
contentIconPane.add(lblCertificateIcon);
final JPanel contentTextPane = new JPanel();
contentTextPane.setBorder(new EmptyBorder(0, 10, 5, 5));
contentPanel.add(contentTextPane, BorderLayout.CENTER);
contentTextPane.setLayout(new BorderLayout(5, 5));
JPanel panelTitle = new JPanel();
panelTitle.setBorder(new MatteBorder(0, 0, 1, 0, UIManager.getColor("InternalFrame.borderShadow")));
contentTextPane.add(panelTitle, BorderLayout.NORTH);
{
JLabel lblTitle = new JLabel("SSL " + Constant.messages.getString("dynssl.label.rootca"));
panelTitle.add(lblTitle);
lblTitle.setFont(FontUtils.getFont(Font.BOLD));
}
contentTextPane.add(txtSslWontWork);
final JPanel panelButtons = new JPanel();
contentTextPane.add(panelButtons, BorderLayout.SOUTH);
GridBagLayout gbl_panelButtons = new GridBagLayout();
gbl_panelButtons.columnWidths = new int[] { 25, 0, 0 };
gbl_panelButtons.rowHeights = new int[] { 23, 23, 0 };
gbl_panelButtons.columnWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
gbl_panelButtons.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE };
panelButtons.setLayout(gbl_panelButtons);
GridBagConstraints gbc_btnCreate = new GridBagConstraints();
gbc_btnCreate.anchor = GridBagConstraints.WEST;
gbc_btnCreate.fill = GridBagConstraints.HORIZONTAL;
gbc_btnCreate.insets = new Insets(0, 0, 5, 5);
gbc_btnCreate.gridx = 0;
gbc_btnCreate.gridy = 0;
panelButtons.add(btnCreate, gbc_btnCreate);
GridBagConstraints gbc_lblCreateCertificateNow = new GridBagConstraints();
gbc_lblCreateCertificateNow.anchor = GridBagConstraints.WEST;
gbc_lblCreateCertificateNow.fill = GridBagConstraints.HORIZONTAL;
gbc_lblCreateCertificateNow.insets = new Insets(0, 0, 5, 0);
gbc_lblCreateCertificateNow.gridx = 1;
gbc_lblCreateCertificateNow.gridy = 0;
final JLabel lblCreateCertificateNow = new JLabel(Constant.messages.getString("dynssl.text.createnow"));
panelButtons.add(lblCreateCertificateNow, gbc_lblCreateCertificateNow);
GridBagConstraints gbc_btnLater = new GridBagConstraints();
gbc_btnLater.anchor = GridBagConstraints.WEST;
gbc_btnLater.fill = GridBagConstraints.HORIZONTAL;
gbc_btnLater.insets = new Insets(0, 0, 0, 5);
gbc_btnLater.gridx = 0;
gbc_btnLater.gridy = 1;
panelButtons.add(btnLater, gbc_btnLater);
GridBagConstraints gbc_lblNotNowBut = new GridBagConstraints();
gbc_lblNotNowBut.anchor = GridBagConstraints.WEST;
gbc_lblNotNowBut.fill = GridBagConstraints.HORIZONTAL;
gbc_lblNotNowBut.gridx = 1;
gbc_lblNotNowBut.gridy = 1;
final JLabel lblNotNowBut = new JLabel(Constant.messages.getString("dynssl.text.notnow"));
panelButtons.add(lblNotNowBut, gbc_lblNotNowBut);
}
use of javax.swing.JTextArea in project Smack by igniterealtime.
the class EnhancedDebugger method addAdhocPacketPanel.
private void addAdhocPacketPanel() {
// Create UI elements for sending ad-hoc messages.
final JTextArea adhocMessages = new JTextArea();
adhocMessages.setEditable(true);
adhocMessages.setForeground(new Color(1, 94, 35));
tabbedPane.add("Ad-hoc message", new JScrollPane(adhocMessages));
tabbedPane.setToolTipTextAt(3, "Panel that allows you to send adhoc packets");
// Add pop-up menu.
JPopupMenu menu = new JPopupMenu();
JMenuItem menuItem = new JMenuItem("Message");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
adhocMessages.setText("<message to=\"\" id=\"" + StringUtils.randomString(5) + "-X\"><body></body></message>");
}
});
menu.add(menuItem);
menuItem = new JMenuItem("IQ Get");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
adhocMessages.setText("<iq type=\"get\" to=\"\" id=\"" + StringUtils.randomString(5) + "-X\"><query xmlns=\"\"></query></iq>");
}
});
menu.add(menuItem);
menuItem = new JMenuItem("IQ Set");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
adhocMessages.setText("<iq type=\"set\" to=\"\" id=\"" + StringUtils.randomString(5) + "-X\"><query xmlns=\"\"></query></iq>");
}
});
menu.add(menuItem);
menuItem = new JMenuItem("Presence");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
adhocMessages.setText("<presence to=\"\" id=\"" + StringUtils.randomString(5) + "-X\"/>");
}
});
menu.add(menuItem);
menu.addSeparator();
menuItem = new JMenuItem("Send");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!"".equals(adhocMessages.getText())) {
AdHocPacket packetToSend = new AdHocPacket(adhocMessages.getText());
try {
connection.sendStanza(packetToSend);
} catch (InterruptedException | NotConnectedException e1) {
LOGGER.log(Level.WARNING, "exception", e);
}
}
}
});
menu.add(menuItem);
menuItem = new JMenuItem("Clear");
menuItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
adhocMessages.setText(null);
}
});
menu.add(menuItem);
// Add listener to the text area so the popup menu can come up.
adhocMessages.addMouseListener(new PopupListener(menu));
}
use of javax.swing.JTextArea in project apjp by jvansteirteghem.
the class Main method main.
public static void main(final String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
Security.addProvider(new IAIK());
Properties properties = new Properties();
properties.load(new FileInputStream("APJP_LOCAL.properties"));
APJP.APJP_KEY = properties.getProperty("APJP_KEY", "");
APJP.APJP_LOGGER_ID = "APJP";
APJP.APJP_LOGGER_LEVEL = 1;
APJP.APJP_LOCAL_PROXY_SERVER_ADDRESS = properties.getProperty("APJP_LOCAL_PROXY_SERVER_ADDRESS", "");
try {
APJP.APJP_LOCAL_PROXY_SERVER_PORT = new Integer(properties.getProperty("APJP_LOCAL_PROXY_SERVER_PORT", "0"));
} catch (Exception e) {
APJP.APJP_LOCAL_PROXY_SERVER_PORT = 0;
}
APJP.APJP_LOCAL_PROXY_SERVER_LOGGER_ID = "APJP_LOCAL_PROXY_SERVER";
APJP.APJP_LOCAL_PROXY_SERVER_LOGGER_LEVEL = 1;
APJP.APJP_LOCAL_HTTP_PROXY_SERVER_ADDRESS = properties.getProperty("APJP_LOCAL_HTTP_PROXY_SERVER_ADDRESS", "");
try {
APJP.APJP_LOCAL_HTTP_PROXY_SERVER_PORT = new Integer(properties.getProperty("APJP_LOCAL_HTTP_PROXY_SERVER_PORT", "0"));
} catch (Exception e) {
APJP.APJP_LOCAL_HTTP_PROXY_SERVER_PORT = 0;
}
APJP.APJP_LOCAL_HTTP_PROXY_SERVER_LOGGER_ID = "APJP_LOCAL_HTTP_PROXY_SERVER";
APJP.APJP_LOCAL_HTTP_PROXY_SERVER_LOGGER_LEVEL = 1;
APJP.APJP_LOCAL_HTTP_SERVER_ADDRESS = properties.getProperty("APJP_LOCAL_HTTP_SERVER_ADDRESS", "");
try {
APJP.APJP_LOCAL_HTTP_SERVER_PORT = new Integer(properties.getProperty("APJP_LOCAL_HTTP_SERVER_PORT", "0"));
} catch (Exception e) {
APJP.APJP_LOCAL_HTTP_SERVER_PORT = 0;
}
APJP.APJP_LOCAL_HTTP_SERVER_LOGGER_ID = "APJP_LOCAL_HTTP_SERVER";
APJP.APJP_LOCAL_HTTP_SERVER_LOGGER_LEVEL = 1;
APJP.APJP_REMOTE_HTTP_SERVER_REQUEST_URL = new String[10];
APJP.APJP_REMOTE_HTTP_SERVER_REQUEST_PROPERTY_KEY = new String[10][5];
APJP.APJP_REMOTE_HTTP_SERVER_REQUEST_PROPERTY_VALUE = new String[10][5];
for (int i = 0; i < APJP.APJP_REMOTE_HTTP_SERVER_REQUEST_PROPERTY_KEY.length; i = i + 1) {
APJP.APJP_REMOTE_HTTP_SERVER_REQUEST_URL[i] = properties.getProperty("APJP_REMOTE_HTTP_SERVER_" + (i + 1) + "_REQUEST_URL", "");
for (int j = 0; j < APJP.APJP_REMOTE_HTTP_SERVER_REQUEST_PROPERTY_KEY[i].length; j = j + 1) {
APJP.APJP_REMOTE_HTTP_SERVER_REQUEST_PROPERTY_KEY[i][j] = properties.getProperty("APJP_REMOTE_HTTP_SERVER_" + (i + 1) + "_REQUEST_PROPERTY_" + (j + 1) + "_KEY", "");
APJP.APJP_REMOTE_HTTP_SERVER_REQUEST_PROPERTY_VALUE[i][j] = properties.getProperty("APJP_REMOTE_HTTP_SERVER_" + (i + 1) + "_REQUEST_PROPERTY_" + (j + 1) + "_VALUE", "");
}
}
APJP.APJP_LOCAL_HTTPS_PROXY_SERVER_ADDRESS = properties.getProperty("APJP_LOCAL_HTTPS_PROXY_SERVER_ADDRESS", "");
try {
APJP.APJP_LOCAL_HTTPS_PROXY_SERVER_PORT = new Integer(properties.getProperty("APJP_LOCAL_HTTPS_PROXY_SERVER_PORT", "0"));
} catch (Exception e) {
APJP.APJP_LOCAL_HTTPS_PROXY_SERVER_PORT = 0;
}
APJP.APJP_LOCAL_HTTPS_PROXY_SERVER_LOGGER_ID = "APJP_LOCAL_HTTPS_PROXY_SERVER";
APJP.APJP_LOCAL_HTTPS_PROXY_SERVER_LOGGER_LEVEL = 1;
APJP.APJP_LOCAL_HTTPS_SERVER_ADDRESS = properties.getProperty("APJP_LOCAL_HTTPS_SERVER_ADDRESS", "");
try {
APJP.APJP_LOCAL_HTTPS_SERVER_PORT = new Integer(properties.getProperty("APJP_LOCAL_HTTPS_SERVER_PORT", "0"));
} catch (Exception e) {
APJP.APJP_LOCAL_HTTPS_SERVER_PORT = 0;
}
APJP.APJP_LOCAL_HTTPS_SERVER_LOGGER_ID = "APJP_LOCAL_HTTPS_SERVER";
APJP.APJP_LOCAL_HTTPS_SERVER_LOGGER_LEVEL = 1;
APJP.APJP_REMOTE_HTTPS_SERVER_REQUEST_URL = new String[10];
APJP.APJP_REMOTE_HTTPS_SERVER_REQUEST_PROPERTY_KEY = new String[10][5];
APJP.APJP_REMOTE_HTTPS_SERVER_REQUEST_PROPERTY_VALUE = new String[10][5];
for (int i = 0; i < APJP.APJP_REMOTE_HTTPS_SERVER_REQUEST_PROPERTY_KEY.length; i = i + 1) {
APJP.APJP_REMOTE_HTTPS_SERVER_REQUEST_URL[i] = properties.getProperty("APJP_REMOTE_HTTPS_SERVER_" + (i + 1) + "_REQUEST_URL", "");
for (int j = 0; j < APJP.APJP_REMOTE_HTTPS_SERVER_REQUEST_PROPERTY_KEY[i].length; j = j + 1) {
APJP.APJP_REMOTE_HTTPS_SERVER_REQUEST_PROPERTY_KEY[i][j] = properties.getProperty("APJP_REMOTE_HTTPS_SERVER_" + (i + 1) + "_REQUEST_PROPERTY_" + (j + 1) + "_KEY", "");
APJP.APJP_REMOTE_HTTPS_SERVER_REQUEST_PROPERTY_VALUE[i][j] = properties.getProperty("APJP_REMOTE_HTTPS_SERVER_" + (i + 1) + "_REQUEST_PROPERTY_" + (j + 1) + "_VALUE", "");
}
}
APJP.APJP_HTTP_PROXY_SERVER_ADDRESS = properties.getProperty("APJP_HTTP_PROXY_SERVER_ADDRESS", "");
try {
APJP.APJP_HTTP_PROXY_SERVER_PORT = new Integer(properties.getProperty("APJP_HTTP_PROXY_SERVER_PORT", "0"));
} catch (Exception e) {
APJP.APJP_HTTP_PROXY_SERVER_PORT = 0;
}
APJP.APJP_HTTP_PROXY_SERVER_USERNAME = properties.getProperty("APJP_HTTP_PROXY_SERVER_USERNAME", "");
APJP.APJP_HTTP_PROXY_SERVER_PASSWORD = properties.getProperty("APJP_HTTP_PROXY_SERVER_PASSWORD", "");
APJP.APJP_HTTPS_PROXY_SERVER_ADDRESS = properties.getProperty("APJP_HTTPS_PROXY_SERVER_ADDRESS", "");
try {
APJP.APJP_HTTPS_PROXY_SERVER_PORT = new Integer(properties.getProperty("APJP_HTTPS_PROXY_SERVER_PORT", "0"));
} catch (Exception e) {
APJP.APJP_HTTPS_PROXY_SERVER_PORT = 0;
}
APJP.APJP_HTTPS_PROXY_SERVER_USERNAME = properties.getProperty("APJP_HTTPS_PROXY_SERVER_USERNAME", "");
APJP.APJP_HTTPS_PROXY_SERVER_PASSWORD = properties.getProperty("APJP_HTTPS_PROXY_SERVER_PASSWORD", "");
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
PasswordAuthentication passwordAuthentication = null;
if (this.getRequestorType() == Authenticator.RequestorType.PROXY) {
if (this.getRequestingURL().getProtocol().equalsIgnoreCase("HTTP") == true) {
passwordAuthentication = new PasswordAuthentication(APJP.APJP_HTTP_PROXY_SERVER_USERNAME, APJP.APJP_HTTP_PROXY_SERVER_PASSWORD.toCharArray());
} else {
if (this.getRequestingURL().getProtocol().equalsIgnoreCase("HTTPS") == true) {
passwordAuthentication = new PasswordAuthentication(APJP.APJP_HTTPS_PROXY_SERVER_USERNAME, APJP.APJP_HTTPS_PROXY_SERVER_PASSWORD.toCharArray());
}
}
}
return passwordAuthentication;
}
});
logger = Logger.getLogger(APJP.APJP_LOGGER_ID);
final ProxyServer proxyServer = new ProxyServer();
final JTextArea outputTextArea = new JTextArea();
outputTextArea.setEditable(false);
outputTextArea.setLineWrap(true);
outputTextArea.setBackground(new Color(0, 0, 0));
outputTextArea.setForeground(new Color(255, 255, 255));
outputTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
final JScrollPane outputScrollPane = new JScrollPane(outputTextArea);
final OutputStream outputStream = new OutputStream() {
public void write(final int b) throws IOException {
outputTextArea.append(new String(new char[] { (char) b }));
}
public void write(final byte[] b, final int off, final int len) throws IOException {
outputTextArea.append(new String(b, off, len));
}
};
final PrintStream printStream = new PrintStream(outputStream, true);
System.setOut(printStream);
final JButton startButton = new JButton();
startButton.setText("Start");
startButton.setPreferredSize(new Dimension(100, 30));
startButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent actionEvent) {
outputTextArea.setText("");
logger.log(1, "START_PROXY_SERVER");
try {
proxyServer.start();
logger.log(1, "START_PROXY_SERVER: OK");
} catch (Exception e) {
logger.log(1, "START_PROXY_SERVER: EXCEPTION", e);
logger.log(1, "START_PROXY_SERVER: NOT OK");
}
HTTPRequests httpRequests = HTTPRequests.getHTTPRequests();
logger.log(1, "TEST_HTTP_REQUESTS");
try {
httpRequests.test();
logger.log(1, "TEST_HTTP_REQUESTS: OK");
} catch (Exception e) {
logger.log(1, "TEST_HTTP_REQUESTS: EXCEPTION", e);
logger.log(1, "TEST_HTTP_REQUESTS: NOT OK");
}
HTTPSRequests httpsRequests = HTTPSRequests.getHTTPSRequests();
logger.log(1, "TEST_HTTPS_REQUESTS");
try {
httpsRequests.test();
logger.log(1, "TEST_HTTPS_REQUESTS: OK");
} catch (Exception e) {
logger.log(1, "TEST_HTTPS_REQUESTS: EXCEPTION", e);
logger.log(1, "TEST_HTTPS_REQUESTS: NOT OK");
}
}
});
final JButton stopButton = new JButton();
stopButton.setText("Stop");
stopButton.setPreferredSize(new Dimension(100, 30));
stopButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent actionEvent) {
outputTextArea.setText("");
logger.log(1, "STOP_PROXY_SERVER");
try {
proxyServer.stop();
logger.log(1, "STOP_PROXY_SERVER: OK");
} catch (Exception e) {
logger.log(1, "STOP_PROXY_SERVER: EXCEPTION", e);
logger.log(1, "STOP_PROXY_SERVER: NOT OK");
}
}
});
final Panel buttonPanel = new Panel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
buttonPanel.add(startButton);
buttonPanel.add(stopButton);
final ImageIcon imageIcon = new ImageIcon("APJP_LOCAL.png");
final JFrame frame = new JFrame();
frame.setIconImage(imageIcon.getImage());
frame.setSize(675, 375);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.add(buttonPanel, BorderLayout.NORTH);
frame.add(outputScrollPane, BorderLayout.CENTER);
if (SystemTray.isSupported()) {
final TrayIcon trayIcon = new TrayIcon(imageIcon.getImage());
trayIcon.setImageAutoSize(true);
trayIcon.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent actionEvent) {
frame.setVisible(!frame.isVisible());
}
});
SystemTray.getSystemTray().add(trayIcon);
}
frame.setVisible(true);
} catch (Exception e) {
logger.log(1, "EXCEPTION", e);
}
}
});
}
use of javax.swing.JTextArea in project jna by java-native-access.
the class ShapedWindowDemo method main.
public static void main(String[] args) {
try {
System.setProperty("sun.java2d.noddraw", "true");
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
}
final JFrame frame = new JFrame("Shaped Window Demo");
MouseInputAdapter handler = new MouseInputAdapter() {
private Point offset;
private void showPopup(MouseEvent e) {
final JPopupMenu m = new JPopupMenu();
m.add(new AbstractAction("Hide") {
public void actionPerformed(ActionEvent e) {
frame.setState(JFrame.ICONIFIED);
}
private static final long serialVersionUID = 1L;
});
m.add(new AbstractAction("Close") {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
private static final long serialVersionUID = 1L;
});
m.pack();
m.show(e.getComponent(), e.getX(), e.getY());
}
public void mousePressed(MouseEvent e) {
offset = e.getPoint();
if (e.isPopupTrigger()) {
showPopup(e);
}
}
public void mouseDragged(MouseEvent e) {
if (!SwingUtilities.isLeftMouseButton(e))
return;
Point where = e.getPoint();
where.translate(-offset.x, -offset.y);
Point loc = frame.getLocationOnScreen();
loc.translate(where.x, where.y);
frame.setLocation(loc.x, loc.y);
}
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
showPopup(e);
}
}
};
frame.addMouseListener(handler);
frame.addMouseMotionListener(handler);
ClockFace face = new ClockFace(new Dimension(150, 150));
frame.getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
frame.getContentPane().add(face);
frame.setUndecorated(true);
try {
Shape mask = new Area(new Ellipse2D.Float(0, 0, 150, 150));
WindowUtils.setWindowMask(frame, mask);
if (WindowUtils.isWindowAlphaSupported()) {
WindowUtils.setWindowAlpha(frame, .7f);
}
frame.setIconImage(face.getIconImage());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocation(100, 100);
frame.setVisible(true);
} catch (UnsatisfiedLinkError e) {
e.printStackTrace();
String msg = e.getMessage() + "\nError loading the JNA library";
JTextArea area = new JTextArea(msg);
area.setOpaque(false);
area.setFont(UIManager.getFont("Label.font"));
area.setEditable(false);
area.setColumns(80);
area.setRows(8);
area.setWrapStyleWord(true);
area.setLineWrap(true);
JOptionPane.showMessageDialog(frame, new JScrollPane(area), "Library Load Error: " + System.getProperty("os.name") + "/" + System.getProperty("os.arch"), JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
}
use of javax.swing.JTextArea in project jna by java-native-access.
the class BalloonManagerDemo method main.
public static void main(String[] args) {
try {
System.setProperty("sun.java2d.noddraw", "true");
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
}
JFrame f = new JFrame("Balloon Test");
final String BALLOON_TEXT = "<html><center>" + "This is some sample balloon text<br>" + "which has been formatted with html.<br>" + "Click to dismiss.</center></html>";
final JLabel content = new JLabel(BALLOON_TEXT);
content.setIconTextGap(10);
content.setBorder(new EmptyBorder(0, 8, 0, 8));
content.setSize(content.getPreferredSize());
content.setIcon(new InfoIcon());
JLabel label = new JLabel("Click anywhere for more information");
label.setHorizontalAlignment(SwingConstants.CENTER);
label.addMouseListener(new MouseAdapter() {
private MouseListener listener = new MouseAdapter() {
public void mousePressed(MouseEvent e) {
hidePopup(e);
}
};
private Popup popup;
private void hidePopup(MouseEvent e) {
e.getComponent().removeMouseListener(listener);
if (popup != null)
popup.hide();
}
public void mousePressed(MouseEvent e) {
hidePopup(e);
popup = BalloonManager.getBalloon(e.getComponent(), content, e.getX(), e.getY());
popup.show();
content.getParent().addMouseListener(listener);
}
});
f.getContentPane().add(label);
f.pack();
f.setSize(new Dimension(300, 300));
f.setLocation(100, 100);
try {
// Force a load of JNA
WindowUtils.setWindowMask(f, WindowUtils.MASK_NONE);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} catch (UnsatisfiedLinkError e) {
e.printStackTrace();
String msg = e.getMessage() + "\nError loading the JNA library";
JTextArea area = new JTextArea(msg);
area.setOpaque(false);
area.setFont(UIManager.getFont("Label.font"));
area.setEditable(false);
area.setColumns(80);
area.setRows(8);
area.setWrapStyleWord(true);
area.setLineWrap(true);
JOptionPane.showMessageDialog(null, new JScrollPane(area), "Library Load Error: " + System.getProperty("os.name") + "/" + System.getProperty("os.arch"), JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
}
Aggregations