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);
}
}
use of javax.swing.JTextArea in project neo4j by neo4j.
the class ScrollableOptionPane method createWrappingScrollPane.
private static JScrollPane createWrappingScrollPane(String message) {
JTextArea view = new JTextArea(message, 10, 80);
view.setLineWrap(true);
view.setEditable(false);
view.setWrapStyleWord(true);
return new JScrollPane(view);
}
use of javax.swing.JTextArea in project pcgen by PCGen.
the class RunConvertPanel method getMessageArea.
/**
* This method initializes messageArea
*
* @return javax.swing.JTextArea
*/
private JTextArea getMessageArea() {
if (messageArea == null) {
messageArea = new JTextArea();
messageArea.setName("errorMessageBox");
messageArea.setEditable(false);
messageArea.setTabSize(8);
}
return messageArea;
}
use of javax.swing.JTextArea in project pcgen by PCGen.
the class SummaryPanel method setupDisplay.
/**
* @see pcgen.gui2.converter.panel.ConvertSubPanel#setupDisplay(javax.swing.JPanel, pcgen.cdom.base.CDOMObject)
*/
@Override
public void setupDisplay(JPanel panel, CDOMObject pc) {
panel.setLayout(new GridBagLayout());
JLabel introLabel = new JLabel("Ready to convert.");
GridBagConstraints gbc = new GridBagConstraints();
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
gbc.insets = new Insets(50, 25, 10, 25);
panel.add(introLabel, gbc);
JLabel instructLabel = new JLabel("Press Next to begin converting using the following settings:");
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
gbc.insets = new Insets(10, 25, 20, 25);
panel.add(instructLabel, gbc);
JLabel[] labels = new JLabel[4];
JComponent[] values = new JComponent[4];
labels[0] = new JLabel("Source Folder:");
labels[1] = new JLabel("Destination Folder:");
labels[2] = new JLabel("Game mode:");
labels[3] = new JLabel("Sources:");
values[0] = new JLabel(pc.get(ObjectKey.DIRECTORY).getAbsolutePath());
values[1] = new JLabel(pc.get(ObjectKey.WRITE_DIRECTORY).getAbsolutePath());
values[2] = new JLabel(pc.get(ObjectKey.GAME_MODE).getDisplayName());
List<Campaign> campaigns = pc.getSafeListFor(ListKey.CAMPAIGN);
StringBuilder campDisplay = new StringBuilder();
for (int i = 0; i < campaigns.size(); i++) {
campDisplay.append(campaigns.get(i).getDisplayName());
campDisplay.append("\n");
}
JTextArea campText = new JTextArea(campDisplay.toString());
campText.setEditable(false);
JScrollPane scrollPane = new JScrollPane(campText);
values[3] = scrollPane;
// Place the labels on the page and lay them out
Font plainFont = FontManipulation.plain(panel.getFont());
for (int i = 0; i < labels.length; i++) {
Utility.buildRelativeConstraints(gbc, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
gbc.insets = new Insets(10, 25, 10, 10);
panel.add(labels[i], gbc);
if (i < labels.length - 1) {
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 1.0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
} else {
Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
}
gbc.insets = new Insets(10, 10, 10, 25);
panel.add(values[i], gbc);
values[i].setFont(plainFont);
}
}
Aggregations