I am trying to create a JPanel
with varying font sizes, without using JLabels
.
Below is a representation of what the code looks like.
public class MyPanel extends JPanel{
public MyPanel(string title){
JFrame frame = new JFrame(title);
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
public void paintComponent(Graphics graphics){
graphics.drawString("Some Text",100,100);
// Should decrease font size
graphics.drawString("Some Smaller Text",200,200);
// Should increase font size
graphics.drawString("Some Bigger Text",300,300);
}
}