Reputation: 11
I want to create desktop application, a banner / tool bar, in java (I'm using swing in netbeans) and I want it to act same as windows Task bar, means desktop icons will rearrange according to banner position.
How to do so?
Thanks for any responses.
Upvotes: 1
Views: 1378
Reputation: 11
Shahar asked this question on my behalf. I thought that it could be done using pure Java, but sadly as far as I know, in this case, Java is a dead end.
You need to use windows API and for that you will need to use Java Native Interface (JNI).
Best way is to create a DLL using C or C++ (use the header windows) and import it into the Java code.
Upvotes: 1
Reputation: 109823
one of way is use JWindow
or Modal and un_decorated JDialog
, for example
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() {
}
}
Upvotes: 1