Используйте Series.between
:
print (df)
Open High Low Close Volume
0 133.795 137.61 132.905 137.275 165822.375
1 133.795 137.61 132.905 133.994 165822.375
2 133.795 137.61 132.905 133.596 165822.375
m = df['Close'].between(df['Open'] - .2, df['Open'] + .2)
print (m)
0 False
1 True
2 True
dtype: bool
Или:
a = df['Open'] - .2
b = df['Open'] + .2
m = (df['Close'] >= a ) & (df['Close'] <= b)
Можно сделать это использование JLabel
, но альтернатива должна была бы разработать JButton
. Тем путем Вы не должны волновать приблизительно доступность и можете просто запустить события с помощью ActionListener
.
public static void main(String[] args) throws URISyntaxException {
final URI uri = new URI("http://java.sun.com");
class OpenUrlAction implements ActionListener {
@Override public void actionPerformed(ActionEvent e) {
open(uri);
}
}
JFrame frame = new JFrame("Links");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(100, 400);
Container container = frame.getContentPane();
container.setLayout(new GridBagLayout());
JButton button = new JButton();
button.setText("<HTML>Click the <FONT color=\"#000099\"><U>link</U></FONT>"
+ " to go to the Java website.</HTML>");
button.setHorizontalAlignment(SwingConstants.LEFT);
button.setBorderPainted(false);
button.setOpaque(false);
button.setBackground(Color.WHITE);
button.setToolTipText(uri.toString());
button.addActionListener(new OpenUrlAction());
container.add(button);
frame.setVisible(true);
}
private static void open(URI uri) {
if (Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().browse(uri);
} catch (IOException e) { /* TODO: error handling */ }
} else { /* TODO: error handling */ }
}
Возможно, используйте JXHyperlink
от SwingX вместо этого. Это расширяется JButton
. Некоторые полезные ссылки:
Если < href = "связывает" > не работает, затем:
Взглянули на java.awt. Рабочий стол API для открытия ссылки с помощью браузера по умолчанию (этот API доступен только от Java6).