java 消息通知
首先创建JFrame作为弹出窗口。 在其中添加一些JLabel以包含信息,并在适当的位置分配它们,使其看起来像一条通知消息。
下面给出了示例代码:
String message = 'You got a new notification message. Isn't it awesome to have such a notification message.';
String header = 'This is header of notification message';
JFrame frame = new JFrame();
frame.setSize(300,125);
frame.setLayout(new GridBagLayout());
GridBagConstraints constraints = new GridBagConstraints();
constraints.gridx = 0;
constraints.gridy = 0;
constraints.weightx = 1.0f;
constraints.weighty = 1.0f;
constraints.insets = new Insets(5, 5, 5, 5);
constraints.fill = GridBagConstraints.BOTH;
JLabel headingLabel = new JLabel(header);
headingLabel .setIcon(headingIcon); // --- use image icon you want to be as heading image.
headingLabel.setOpaque(false);
frame.add(headingLabel, constraints);
constraints.gridx++;