Java Code Examples for java.awt.GridLayout#setHgap()

The following examples show how to use java.awt.GridLayout#setHgap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StatusPanel.java    From ramus with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method initializes this
 *
 * @return void
 */
private void initialize() {
    double[][] size = {{5, TableLayout.FILL, 5},
            {5, TableLayout.FILL, 5}};
    this.setLayout(new TableLayout(size));
    final GridLayout gridLayout3 = new GridLayout();
    JPanel child = new JPanel(gridLayout3);
    this.setSize(351, 105);
    gridLayout3.setRows(3);
    gridLayout3.setColumns(2);
    gridLayout3.setHgap(5);
    gridLayout3.setVgap(5);
    child.add(getJRadioButton(), null);
    child.add(getJRadioButton1(), null);
    child.add(getJRadioButton2(), null);
    child.add(getJRadioButton3(), null);
    child.add(getJRadioButton4(), null);
    child.add(getJTextField(), null);
    this.add(child, "1,1");
}
 
Example 2
Source File: OperatorInfoScreen.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
public static JPanel createCapabilitiesPanel(Operator operator) {
	CapabilityProvider capabilityProvider = (CapabilityProvider) operator;
	int length = OperatorCapability.values().length;
	GridLayout layout = new GridLayout(length / 2, 2);
	layout.setHgap(GAP);
	layout.setVgap(GAP);
	JPanel capabilitiesPanel = new JPanel(layout);
	for (OperatorCapability capability : OperatorCapability.values()) {
		JLabel capabilityLabel = new JLabel(capability.getDescription());
		try {
			if (capabilityProvider.supportsCapability(capability)) {
				capabilityLabel.setIcon(SwingTools.createIcon("16/ok.png"));
			} else {
				capabilityLabel.setIcon(SwingTools.createIcon("16/error.png"));
			}
		} catch (Exception e) {
			break;
		}
		capabilitiesPanel.add(capabilityLabel);
	}
	return capabilitiesPanel;
}
 
Example 3
Source File: PopupPane.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public PopupPane() {
    listComponents = new HashSet<ListComponent>();
    view = new JPanel();
    GridLayout grid = new GridLayout(0, 1);
    grid.setHgap(0);
    grid.setVgap(0);
    view.setLayout(grid);
    view.setBorder(BorderFactory.createEmptyBorder());
    setName("progresspopup"); //NOI18N
    setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    setViewportView(view);
    setFocusable(true);
    setRequestFocusEnabled(true);

    Action down = new MoveDownAction();
    getActionMap().put("Move-Down", down);
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "Move-Down");
    getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "Move-Down");
    
    Action up = new MoveUpAction();
    getActionMap().put("Move-Up", up);
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "Move-Up");
    getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "Move-Up");
    Action cancel = new CancelAction();
    getActionMap().put("Cancel-Task", cancel);
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "Cancel-Task");
    getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "Cancel-Task");
    
    Action select = new SelectAction();
    getActionMap().put("select-task", select);
    getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "select-task");
    getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "select-task");
    
    
    setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
}
 
Example 4
Source File: NationTypeDetailPanel.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Builds the details panel for the given nation type.
 *
 * @param nationType - the IndianNationType
 * @param panel the panel to use
 */
private void buildIndianNationTypeDetail(IndianNationType nationType,
                                         JPanel panel) {
    List<RandomChoice<UnitType>> skills = nationType.getSkills();

    panel.setLayout(new MigLayout("wrap 2, gapx 20", "", ""));

    JLabel name = Utility.localizedHeaderLabel(nationType, FontLibrary.FontSize.SMALL);
    panel.add(name, "span, align center, wrap 40");

    panel.add(Utility.localizedLabel("colopedia.nationType.aggression"));
    panel.add(Utility.localizedLabel("colopedia.nationType."
            + nationType.getAggression().getKey()));

    panel.add(Utility.localizedLabel("colopedia.nationType.settlementNumber"));
    panel.add(Utility.localizedLabel("colopedia.nationType."
            + nationType.getNumberOfSettlements().getKey()));

    panel.add(Utility.localizedLabel("colopedia.nationType.typeOfSettlements"));
    panel.add(new JLabel(Messages.getName(nationType.getCapitalType()),
        new ImageIcon(getImageLibrary()
            .getScaledSettlementTypeImage(nationType.getCapitalType())),
        SwingConstants.CENTER));

    List<String> regionNames = toList(map(nationType.getRegions(),
                                      n -> Messages.getName(n)));
    panel.add(Utility.localizedLabel("colopedia.nationType.regions"));
    panel.add(new JLabel(join(", ", regionNames)));

    panel.add(Utility.localizedLabel("colopedia.nationType.skills"), "top, newline 20");
    GridLayout gridLayout = new GridLayout(0, 2);
    gridLayout.setHgap(10);
    JPanel unitPanel = new JPanel(gridLayout);
    unitPanel.setOpaque(false);
    for (RandomChoice<UnitType> choice : skills) {
        unitPanel.add(getUnitButton(choice.getObject()));
    }
    panel.add(unitPanel);
}
 
Example 5
Source File: PreferencesDialog.java    From petscii-bbs with Mozilla Public License 2.0 4 votes vote down vote up
public PreferencesDialog(JFrame parent, Preferences preferences,
                         DisplaySettings settings) {
  
  super(parent, "Preferences...", true);
  this.preferences = preferences;
  this.settings = settings;
  
  // Control panel
  GridLayout grid = new GridLayout(5, 2);
  grid.setVgap(3);
  grid.setHgap(3);
  
  JPanel mainpanel = new JPanel(grid);
  
  JLabel stdfontLabel = new JLabel("Size of standard font: ");
  mainpanel.add(stdfontLabel);
  stdfontSpinner = new JSpinner();
  stdfontSpinner.setValue(settings.getStdFontSize());
  mainpanel.add(stdfontSpinner);

  JLabel fixedfontLabel = new JLabel("Size of fixed font: ");
  mainpanel.add(fixedfontLabel);    
  fixedfontSpinner = new JSpinner();
  fixedfontSpinner.setValue(settings.getFixedFontSize());
  mainpanel.add(fixedfontSpinner);
  
  JLabel backgroundLabel = new JLabel("Default background: ");
  mainpanel.add(backgroundLabel);
  backgroundCB = new JComboBox(colors);
  mainpanel.add(backgroundCB);
  preselect(backgroundCB, settings.getDefaultBackground());
  
  JLabel foregroundLabel = new JLabel("Default foreground: ");
  mainpanel.add(foregroundLabel);
  foregroundCB = new JComboBox(colors);
  mainpanel.add(foregroundCB);
  preselect(foregroundCB, settings.getDefaultForeground());

  JLabel antialiasLabel = new JLabel("Antialiased text: ");
  mainpanel.add(antialiasLabel);
  antialiasCB = new JCheckBox();
  antialiasCB.setSelected(settings.getAntialias());
  mainpanel.add(antialiasCB);
  
  // Button panel
  Box lowpanel = new Box(BoxLayout.Y_AXIS);
  lowpanel.add(new JSeparator());
  JPanel buttonpanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
  lowpanel.add(buttonpanel);
  
  JButton okbutton = new JButton("Ok");
  JButton cancelbutton = new JButton("Cancel");
  getRootPane().setDefaultButton(okbutton);
  buttonpanel.add(okbutton);
  buttonpanel.add(cancelbutton);
  okbutton.addActionListener(this);
  cancelbutton.addActionListener(this);
  
  getContentPane().add(mainpanel, BorderLayout.NORTH);
  getContentPane().add(
      new JLabel("<html><body><i>(Note: Changes only take effect after a " +
                 "restart)</i></body></html>"),
                 BorderLayout.CENTER);
  getContentPane().add(lowpanel, BorderLayout.SOUTH);
  
  Border border = BorderFactory.createEmptyBorder(5, 5, 5, 3);
  ((JPanel) getContentPane()).setBorder(border);
  ((BorderLayout) getContentPane().getLayout()).setVgap(5);

  pack();
  
}
 
Example 6
Source File: ReaderAddIFrame.java    From LibraryManagementSystem with MIT License 4 votes vote down vote up
public ReaderAddIFrame() {
	super();
	setIconifiable(true);							// ���ô������С������������
	setClosable(true);								// ���ô���ɹرգ���������
	setTitle("������Ϣ���");						// ���ô�����⣭��������
	setBounds(100, 30, 500, 250);

	//������ͷͼƬ
	final JLabel logoLabel = new JLabel();
	ImageIcon readerAddIcon=CreateIcon.add("tback.jpg");
	logoLabel.setIcon(readerAddIcon);
	logoLabel.setOpaque(true);
	logoLabel.setBackground(Color.white);
	logoLabel.setPreferredSize(new Dimension(400, 60));
	getContentPane().add(logoLabel, BorderLayout.NORTH);

	//����һ�������������
	final JPanel panel = new JPanel();
	panel.setLayout(new FlowLayout());
	getContentPane().add(panel);

	//�������������Ƕ�����1,���ڷ��÷ǰ�ť���
	final JPanel panel_1 = new JPanel();
	final GridLayout gridLayout = new GridLayout(0, 4);
	gridLayout.setVgap(15);
	gridLayout.setHgap(10);
	panel_1.setLayout(gridLayout);
	panel_1.setPreferredSize(new Dimension(450, 100));
	panel.add(panel_1);

	final JLabel label_2 = new JLabel();
	label_2.setText("��ַ��");
	panel_1.add(label_2);
	address = new JTextField();
	address.setDocument(new MyDocument(256));
	panel_1.add(address);
	
	final JLabel label_3 = new JLabel();
	label_3.setText("��     �ţ�");
	panel_1.add(label_3);
	id = new JTextField();
	id.setDocument(new MyDocument(256));
	panel_1.add(id);
	
	final JLabel label_4 = new JLabel();
	label_4.setText("���� ��");
	panel_1.add(label_4);
	name = new JTextField();
	name.setDocument(new MyDocument(256));
	panel_1.add(name);
	
	final JLabel label_5 = new JLabel();
	label_5.setText("Ƿ�");
	panel_1.add(label_5);
	own = new JTextField();
	own.setDocument(new MyDocument(256));
	panel_1.add(own);
	
	final JLabel label_6 = new JLabel();
	label_6.setText("�绰��");
	panel_1.add(label_6);
	phone = new JTextField();
	phone.setDocument(new MyDocument(256));
	panel_1.add(phone);
	
	final JLabel label_7 = new JLabel();
	label_7.setText("�Ա�");
	panel_1.add(label_7);
	sex = new JTextField();
	sex.setDocument(new MyDocument(256));
	panel_1.add(sex);

	//����������Ƕ��һ�����ڷ��Ű�ť�����
	final JPanel panel_2 = new JPanel();
	panel_2.setPreferredSize(new Dimension(450, 100));
	panel.add(panel_2);
	
	final JRadioButton radioButton1 = new JRadioButton();

	//�����������
	final JButton submit = new JButton();
	panel_2.add(submit);
	submit.setText("�ύ");
	submit.addActionListener((ActionListener) new ButtonAddListener(radioButton1));
	
	//�����������
	final JButton back = new JButton();
	panel_2.add(back);
	back.setText("����");
	back.addActionListener(new CloseActionListener());

	setVisible(true);
}
 
Example 7
Source File: BorrowIFrame.java    From LibraryManagementSystem with MIT License 4 votes vote down vote up
public BorrowIFrame() {
	super();
	setIconifiable(true);							// ���ô������С������������
	setClosable(true);								// ���ô���ɹرգ���������
	setTitle("������Ϣ���");						// ���ô�����⣭��������
	setBounds(100, 30, 500, 250);

	//������ͷͼƬ
	final JLabel logoLabel = new JLabel();
	ImageIcon readerAddIcon=CreateIcon.add("tback.jpg");
	logoLabel.setIcon(readerAddIcon);
	logoLabel.setOpaque(true);
	logoLabel.setBackground(Color.white);
	logoLabel.setPreferredSize(new Dimension(400, 60));
	getContentPane().add(logoLabel, BorderLayout.NORTH);

	//����һ�������������
	final JPanel panel = new JPanel();
	panel.setLayout(new FlowLayout());
	getContentPane().add(panel);

	//�������������Ƕ�����1,���ڷ��÷ǰ�ť���
	final JPanel panel_1 = new JPanel();
	final GridLayout gridLayout = new GridLayout(0, 4);
	gridLayout.setVgap(15);
	gridLayout.setHgap(10);
	panel_1.setLayout(gridLayout);
	panel_1.setPreferredSize(new Dimension(450, 100));
	panel.add(panel_1);

	final JLabel label_2 = new JLabel();
	label_2.setText("�������ڣ�");
	panel_1.add(label_2);
	borrowDate = new JFormattedTextField();
	borrowDate.setValue("XXXX-XX-XX");
	borrowDate.addKeyListener(new DateListener());
	panel_1.add(borrowDate);
	
	final JLabel label_3 = new JLabel();
	label_3.setText("��     �ţ�");
	panel_1.add(label_3);
	id = new JTextField();
	id.setDocument(new MyDocument(256));
	panel_1.add(id);
	
	final JLabel label_4 = new JLabel();
	label_4.setText("�鱾��� ��");
	panel_1.add(label_4);
	bid = new JTextField();
	bid.setDocument(new MyDocument(256));
	panel_1.add(bid);
	
	final JLabel label_5 = new JLabel();
	label_5.setText("���߱�ţ�");
	panel_1.add(label_5);
	rid = new JTextField();
	rid.setDocument(new MyDocument(256));
	panel_1.add(rid);
	
	final JLabel label_6 = new JLabel();
	label_6.setText("����Ա���֣�");
	panel_1.add(label_6);
	name = new JTextField();
	name.setDocument(new MyDocument(256));
	panel_1.add(name);

	//����������Ƕ��һ�����ڷ��Ű�ť�����
	final JPanel panel_2 = new JPanel();
	panel_2.setPreferredSize(new Dimension(450, 100));
	panel.add(panel_2);
	
	final JRadioButton radioButton1 = new JRadioButton();

	//�����������
	final JButton submit = new JButton();
	panel_2.add(submit);
	submit.setText("�ύ");
	submit.addActionListener((ActionListener) new ButtonAddListener(radioButton1));
	
	//�����������
	final JButton back = new JButton();
	panel_2.add(back);
	back.setText("����");
	back.addActionListener(new CloseActionListener());

	setVisible(true);
}