as the title says what I want to achieve is to pop up an option message using JOptionPane such that the question and the buttons be placed on the same line. I'm reading the following tutorials but it seems to be quite difficult:
In a sense the idea is to have the following confirmation message layout:
The products are going to be removed from the database.
Are you sure you want to perform it? |YES| |NO|
where YES and NO should be buttons. (The text is not the real one, it's only to give the flavor of the message).
Any comments or hints will be welcomed.
Thanks a lot in advance.
Try this
JOptionPane.showConfirmDialog(null,
getCustomPanel(), // this will return a Panel design on your Own
"JOptionPane Example : ",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE);
//and your Custom Panel
private JPanel getCustomPanel() {
JPanel panel = new JPanel();
JLabel label = new JLabel("Text Message:");
panel.setLayout(null);
JButton okbtn=new JButton("ok");
label.setBounds(10,20,200,40); //x,y,width,height
okbtn.setBounds(220,20,80,40); //x,y,width,height
panel.add(label);
panel.add(okbtn);
return panel;
}