8
I have a Toolbar, and I want to make a settings bar on it. However, in order not to take up space, I would like it to be possible to hide/minimize it, something similar to teamviewer’s chat.
My Toolbar (this inside a main screen)
Container contentPane = this.getContentPane();
contentPane.add(toolBar, BorderLayout.SOUTH);
toolBar.setFloatable(false);// não deixa ToolBar mudar de lugar.
JLabel label = new JLabel(" Configurações ");
toolBar.add(label);
toolBar.add(botaoConfig);
botaoConfig.addActionListener(this);
botaoConfig.setPreferredSize(new Dimension(30, 30));
I’ll put an illustration to help with the enthusement:
Well summarised example:
package testes;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import static java.awt.Frame.MAXIMIZED_BOTH;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import static javax.swing.JFrame.EXIT_ON_CLOSE;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JToolBar;
public class TelaSistema extends JFrame implements ActionListener {
public JDesktopPane jdp = new JDesktopPane();
public JMenuBar jmb = new JMenuBar();
public JMenu jmCadastros = new JMenu("Cadastros");
public JMenuItem jmiEstado = new JMenuItem("Estado");
JToolBar toolBar = new JToolBar();
JButton botaoConfig = new JButton("Config");
public TelaSistema() {
Container contentPane = this.getContentPane();
contentPane.add(toolBar, BorderLayout.EAST);
toolBar.setFloatable(false);// não deixa ToolBar mudar de lugar.
JLabel label = new JLabel(" Configurações ");
toolBar.add(label);
toolBar.add(botaoConfig);
botaoConfig.addActionListener(this);
botaoConfig.setPreferredSize(new Dimension(30, 30));
toolBar.setBackground(new Color(230, 230, 230));
// setSize(800, 600);
setExtendedState(MAXIMIZED_BOTH);
setTitle("Sistema");
getContentPane().add(jdp);
setJMenuBar(jmb);
jmb.add(jmCadastros);
adicionaJMenuItem(jmCadastros, jmiEstado);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
private void adicionaJMenuItem(JMenu menu, JMenuItem item) {
menu.add(item);
item.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent ae)
{
}
public static void main(String[] args)
{
TelaSistema tela = new TelaSistema();
}
}
You can add a [mcve] of your screen with the bar?
– user28595
Hello I believe your question is the same as that: http://stackoverflow.com/questions/31601900/javafx-how-to-create-slide-in-animation-effect-for-a-pane-inside-transparent
– Phrxn
@Phrxn this question is about javafx, the solution there will hardly fit for this,
– user28595