-
Bug
-
Resolution: Won't Fix
-
P4
-
5.0
-
generic
-
generic
Need spacing between the JComboBox's, JSpinner and JLabel after adding them to a toolbar, like there is between the JButton's and JTextField's. See picture attached.
Test code below:
--------------------------------------------------------------------------
import java.awt.*;
import java.util.*;
import java.util.List;
import javax.swing.*;
public class ToolBarTest extends JFrame {
public ToolBarTest() {
setLayout(new BorderLayout());
// Add buttons
JToolBar toolBar = new JToolBar("Test");
toolBar.add(new JButton("Green"));
toolBar.add(new JButton("Blue"));
// Add combobox's
String[] styles = {"Plain","Bold","Italic","Bold/Italic"};
toolBar.add(new JComboBox(styles));
toolBar.add(new JComboBox(styles));
// Add spinner
List values = new ArrayList();
for(int i=1; i<=9; i++) {
values.add("0" + i);
}
SpinnerListModel spinnerModel = new SpinnerListModel(values);
JSpinner sizeSpinner = new JSpinner(spinnerModel);
sizeSpinner.setValue("04");
toolBar.add(sizeSpinner);
// Add button
toolBar.add(new JButton("Black"));
// Add textfield
toolBar.add(new JTextField(8));
// Add button
toolBar.add(new JButton("Purple"));
// Add label
toolBar.add(new JLabel("Need Spacing"));
// Some buttons
toolBar.add(new JButton("Red"));
toolBar.add(new JButton("Orange"));
add(toolBar, BorderLayout.NORTH);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setVisible(true);
}
public static void main(String[] args) {
new ToolBarTest();
}
}
Test code below:
--------------------------------------------------------------------------
import java.awt.*;
import java.util.*;
import java.util.List;
import javax.swing.*;
public class ToolBarTest extends JFrame {
public ToolBarTest() {
setLayout(new BorderLayout());
// Add buttons
JToolBar toolBar = new JToolBar("Test");
toolBar.add(new JButton("Green"));
toolBar.add(new JButton("Blue"));
// Add combobox's
String[] styles = {"Plain","Bold","Italic","Bold/Italic"};
toolBar.add(new JComboBox(styles));
toolBar.add(new JComboBox(styles));
// Add spinner
List values = new ArrayList();
for(int i=1; i<=9; i++) {
values.add("0" + i);
}
SpinnerListModel spinnerModel = new SpinnerListModel(values);
JSpinner sizeSpinner = new JSpinner(spinnerModel);
sizeSpinner.setValue("04");
toolBar.add(sizeSpinner);
// Add button
toolBar.add(new JButton("Black"));
// Add textfield
toolBar.add(new JTextField(8));
// Add button
toolBar.add(new JButton("Purple"));
// Add label
toolBar.add(new JLabel("Need Spacing"));
// Some buttons
toolBar.add(new JButton("Red"));
toolBar.add(new JButton("Orange"));
add(toolBar, BorderLayout.NORTH);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setVisible(true);
}
public static void main(String[] args) {
new ToolBarTest();
}
}