Hi, Im creating a GUI however i'm experiencing some difficulties. I want to have a text field and a button both placed inside a radiobutton. I've tried inputting ONLY the button, but the button is not displayed when i run the codes. Would be good if light could be shed, thanks.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Layout {
public static void main(String[] args) {
//for query
JRadioButton query1, query2, query3;
query1 = new JRadioButton("for uploading of file");
//query1.setActionCommand("bach1");
query2 = new JRadioButton("dropdownlist for database");
//query2.setActionCommand("bach2");
query3 = new JRadioButton("entering of sequence");
//query3.setActionCommand("Shostakovich");
JButton UploadQuery = new JButton("Upload");
JPanel buttonPanel = new JPanel();
buttonPanel.add(UploadQuery);
//a group
final ButtonGroup group1 = new ButtonGroup();
group1.add(query1);
group1.add(query2);
group1.add(query3);
//for target
JRadioButton target1, target2, target3;
target1 = new JRadioButton("for uploading of file");
//choice1.setActionCommand("bach1");
target2 = new JRadioButton("dropdownlist for database");
//choice2.setActionCommand("bach2");
target3 = new JRadioButton("entering of sequence");
//choice3.setActionCommand("Shostakovich");
//a group that ensures we vote for only one
final ButtonGroup group2 = new ButtonGroup();
group2.add(target1);
group2.add(target2);
group2.add(target3);
//throw everything together
JFrame frame = new JFrame("Biomolecular Structure Comparison");
frame.setPreferredSize(new Dimension(500, 500));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container QUERY = frame.getContentPane();
QUERY.setLayout(new GridLayout(10,20) );
QUERY.add(new JLabel("Query Structure:"));
QUERY.add(query1,buttonPanel);
QUERY.add(query2);
QUERY.add(query3);
Container TARGET = frame.getContentPane();
TARGET.setLayout(new GridLayout(10,50) );
TARGET.add(new JLabel("Target Structure:"));
TARGET.add(target1);
TARGET.add(target2);
TARGET.add(target3);
frame.pack();
frame.setVisible(true);
}//end of main
}//end of class