Here i mad panel and i put two Boxes in it , then i tried to make a background color for box by useing (background(color.blue) method) but it never has the color .
Then i try to resize its height by useing Box.createRigidArea(new Dimension(10, 50)) but the titleBoard take all the fram
why this?
my code
---------------
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.border.TitledBorder;
public class MainStegoFrame extends JFrame {
private JMenuBar bar;
private JMenu fileMenu, editMenu, toolMenu, helpMenu;
private JPanel mainPanel;
private Box displayBox, ButtonsBoxs;
private JButton loadImageButton, loadVedioButton, loadAudioButton;
public MainStegoFrame() {
intializeingMenus();
intializeingPanels();
intializeingButtons();
getContentPane().add(mainPanel, BorderLayout.CENTER);
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
}
MainStegoFrame mainStegoFrame = new MainStegoFrame();
mainStegoFrame.setDefaultCloseOperation(MainStegoFrame.EXIT_ON_CLOSE);
mainStegoFrame.setSize(new Dimension(600, 300));
mainStegoFrame.setLocationRelativeTo(null);
mainStegoFrame.setVisible(true);
// mainStegoFrame.setExtendedState(MAXIMIZED_BOTH);
}
private void intializeingMenus() {
bar = new JMenuBar();
fileMenu = new JMenu("File");
bar.add(fileMenu);
editMenu = new JMenu("Edit");
bar.add(editMenu);
toolMenu = new JMenu("Tool");
bar.add(toolMenu);
helpMenu = new JMenu("Help");
bar.add(helpMenu);
setJMenuBar(bar);
}
private void intializeingPanels() {
mainPanel = new JPanel(new BorderLayout());
displayBox = Box.createHorizontalBox();
displayBox.setBackground(Color.BLUE);
TitledBorder titledBorderDispaly = new TitledBorder("Cover");
displayBox.setBorder(titledBorderDispaly);
mainPanel.add(displayBox, BorderLayout.CENTER);
ButtonsBoxs = Box.createVerticalBox();
ButtonsBoxs.add(Box.createVerticalStrut(30));
ButtonsBoxs.add(Box.createRigidArea(new Dimension(10, 50)));
ButtonsBoxs.setBackground(Color.BLUE);
TitledBorder titledBorderCover = new TitledBorder("Cover");
ButtonsBoxs.setBorder(titledBorderCover);
mainPanel.add(ButtonsBoxs, BorderLayout.EAST);
}
private void intializeingButtons() {
loadImageButton = new JButton("Load Image");
ButtonsBoxs.add(loadImageButton);
loadAudioButton = new JButton("Load Audio");
ButtonsBoxs.add(loadAudioButton);
loadVedioButton = new JButton("Load vedio");
ButtonsBoxs.add(loadVedioButton);
}
}
thanks in advance