I have a JList
inside of a JScrollPane
and have set the font to Tahoma
, plain, 20 and for some reason its still displaying as very small text and I am not to sure why this is?
Just so that this isn't a massive piece of code I have slimmed it down as much as I can the frame that this is stored in uses a GridBagLayout
ArrayUtil.ArrayToListModel
converts any List<T>;
to ListMode<T>;
JFrame frame = new JFrame();
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
GridBagLayout gridBagLayout = new GridBagLayout();
gridBagLayout.columnWidths = new int[]{0};
gridBagLayout.rowHeights = new int[]{0};
gridBagLayout.columnWeights = new double[]{1.0};
gridBagLayout.rowWeights = new double[]{1.0};
frame.getContentPane().setLayout(gridBagLayout);
JScrollPane showlistScrollPane = new JScrollPane();
GridBagConstraints gbc_showlistScrollPane = new GridBagConstraints();
gbc_showlistScrollPane.insets = new Insets(0, 0, 0, 5);
gbc_showlistScrollPane.fill = GridBagConstraints.BOTH;
gbc_showlistScrollPane.gridx = 0;
gbc_showlistScrollPane.gridy = 0;
frame.getContentPane().add(showlistScrollPane, gbc_showlistScrollPane);
ArrayList<String> randomData = new ArrayList<String>();
randomData.add("Random drhgiudrhgiudhri");
randomData.add("Data dsirhgodhroih");
ListModel<String> pagesList = ArrayUtil.ArrayToListModel(randomData);
showlist = new JList<String>(pagesList);
showlist.setFont(new Font("Tahoma", Font.PLAIN, 20));
showlistScrollPane.setViewportView(showlist);
No matter how big or small I make the font for showlist
it never changes from its default.