I am making a simple GUI with the logo being on the first line, then the rest of the stuff on the next line. Problem is the logo is to small therefore the JComboBox and JTextArea is also on that line, how could I prevent this and ONLY make the logo on the first line? Thank you!
public class TimerMenu {
private JFrame frame;
private JLabel background, logo;
private JTextArea timeText;
private JButton startTimerButton;
private JComboBox timeUnitChoice;
public TimerMenu(){
frame = new JFrame("Timer");
startTimerButton = new JButton("Start Timer");
startTimerButton.setPreferredSize(new Dimension(135, 30));
startTimerButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO: CHANGE TO SOMETHING NICER
JOptionPane.showMessageDialog(null, "This feature hasn't been implemented yet.", "We're sorry!",
JOptionPane.ERROR_MESSAGE);
}
});
// Creating drop down menu.
String[] timeChoices = { "Nanoseconds", "Microseconds", "Milliseconds", "Seconds", "Minutes", "Hours", "Days"};
// Giving the choices from the array of 'timeChoices'
timeUnitChoice = new JComboBox(timeChoices);
// Setting the default option to 'Minutes' (4th choice, starting at 0 as its an array!)
timeUnitChoice.setSelectedIndex(4);
try {
background = new JLabel(new ImageIcon(ImageIO.read(getClass()
.getResourceAsStream("/me/devy/alarm/clock/resources/background.jpg"))));
logo = new JLabel(new ImageIcon(ImageIO.read(getClass()
.getResourceAsStream("/me/devy/alarm/clock/resources/timer.png"))));
} catch (IOException e) {
e.printStackTrace();
}
// Creating simple text
background.setLayout(new FlowLayout());
frame.setContentPane(background);
frame.add(logo);
frame.add(timeUnitChoice);
// Creating a text field
timeText = new JTextArea("Length:");
timeText.setEditable(false);
frame.add(timeText);
frame.add(startTimerButton);
frame.setVisible(true);
frame.setSize(550, 250);
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}