我想创建桌面应用程序的Java旗帜/工具栏,横幅/工具栏,在Java(我使用的摆动在NetBeans),我希望它起到相同Windows任务栏上,意味着桌面图标将根据横幅位置重新排列。创建像个Windows任务栏
如何做?
感谢您的回复。
我想创建桌面应用程序的Java旗帜/工具栏,横幅/工具栏,在Java(我使用的摆动在NetBeans),我希望它起到相同Windows任务栏上,意味着桌面图标将根据横幅位置重新排列。创建像个Windows任务栏
如何做?
感谢您的回复。
的方法之一是使用JWindow
或模态和un_decorated JDialog
,例如
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JWindow;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
public class SlideText_1 {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
createAndShowGUI();
}
});
}
private static void createAndShowGUI() {
final JWindow window = new JWindow();
final JPanel windowContents = new JPanel();
JLabel label = new JLabel("A window that is pushed into view..........");
windowContents.add(label);
window.add(windowContents);
window.pack();
window.setLocationRelativeTo(null);
final int desiredWidth = window.getWidth();
window.getContentPane().setLayout(null);
window.setSize(0, window.getHeight());
window.setVisible(true);
Timer timer = new Timer(15, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int newWidth = Math.min(window.getWidth() + 1, desiredWidth);
window.setSize(newWidth, window.getHeight());
windowContents.setLocation(newWidth - desiredWidth, 0);
if (newWidth >= desiredWidth) {
((Timer) e.getSource()).stop();
window.getContentPane().setLayout(new BorderLayout()); //restore original layout
window.validate();
window.setVisible(false);
}
}
});
timer.start();
}
private SlideText_1() {
}
}
沙哈尔问这个问题,我的名义。我认为可以用纯Java来完成,但据我所知,在这种情况下,Java是一个死胡同。
您需要使用Windows API,并为您将需要使用Java本地接口(JNI)。
最好的方法是使用C或C++(使用头窗口)创建一个DLL并将其导入到Java代码中。
事情是,它只是悬停在桌面项目上方,我希望桌面项目(图标等)对横幅作出反应并且不会与其发生冲突。 – 2012-03-14 12:03:53