Java Code Examples for javax.swing.JComboBox#setBounds()

The following examples show how to use javax.swing.JComboBox#setBounds() . 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: InputDialog.java    From dkpro-jwpl with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the input type chooser.
 */
private void createTypeChooser()
{

	typeLabel = new JLabel("Input type: ");
	typeLabel.setBounds(10, 80, 130, 25);
	this.add(typeLabel);

	typeChooser = new JComboBox();
	typeChooser.setBounds(150, 80, 110, 25);

	typeChooser.addItem(InputType.XML);

	if (this.controller.is7ZipEnabled()) {
		typeChooser.addItem(InputType.SEVENZIP);
	}

	typeChooser.addItem(InputType.BZIP2);

	this.add(typeChooser);
}
 
Example 2
Source File: ControlsDialog.java    From WorldGrower with GNU General Public License v3.0 6 votes vote down vote up
private void addPerformancePanel(KeyBindings keyBindings) {
	JPanel performancePanel = JPanelFactory.createJPanel("Performance");
	performancePanel.setOpaque(false);
	performancePanel.setBounds(15, 310, 368, 100);
	performancePanel.setLayout(null);
	
	JLabel lblAnimationSpeed = JLabelFactory.createJLabel("Animation Speed:");
	lblAnimationSpeed.setToolTipText(ANIMATION_SPEED_TOOL_TIP);
	lblAnimationSpeed.setOpaque(false);
	lblAnimationSpeed.setBounds(12, 25, 137, 25);
	performancePanel.add(lblAnimationSpeed);

	JComboBox<AnimationSpeed> cmbAnimationSpeed = JComboBoxFactory.createJComboBox(AnimationSpeed.values(), imageInfoReader);
	cmbAnimationSpeed.setForeground(Color.BLACK);
	cmbAnimationSpeed.setToolTipText(ANIMATION_SPEED_TOOL_TIP);
	cmbAnimationSpeed.setSelectedItem(keyBindings.getAnimationSpeed());
	cmbAnimationSpeed.setOpaque(false);
	cmbAnimationSpeed.setBounds(228, 25, 127, 25);
	performancePanel.add(cmbAnimationSpeed);
	
	cmbAnimationSpeed.addActionListener(e -> keyBindings.setAnimationSpeed((AnimationSpeed)cmbAnimationSpeed.getSelectedItem()));
	
	addComponent(performancePanel);
}
 
Example 3
Source File: SwitchController.java    From Ardulink-2 with Apache License 2.0 5 votes vote down vote up
/**
 * Create the panel.
 */
public SwitchController() {
	setPreferredSize(new Dimension(125, 75));
	setLayout(null);
	pinComboBoxModel = new IntMinMaxModel(0, 40).withSelectedItem(3);
	JComboBox pinComboBox = new JComboBox(pinComboBoxModel);
	pinComboBox.setBounds(66, 11, 47, 22);
	add(pinComboBox);
	
	JLabel label = new JLabel("Power Pin:");
	label.setFont(new Font("SansSerif", Font.PLAIN, 11));
	label.setBounds(10, 15, 59, 14);
	add(label);
	
	switchToggleButton = new JToggleButton("Off");
	switchToggleButton.addItemListener(new ItemListener() {
		@Override
		public void itemStateChanged(ItemEvent e) {
			int pin = pinComboBoxModel.getSelectedItem().intValue();
			if(e.getStateChange() == ItemEvent.SELECTED) {
				switchToggleButton.setText("On");
				link.sendPowerPinSwitch(pin, true);
			} else if(e.getStateChange() == ItemEvent.DESELECTED) {
				switchToggleButton.setText("Off");
				link.sendPowerPinSwitch(pin, false);
			}
		}
	});
	switchToggleButton.setBounds(10, 38, 103, 23);
	add(switchToggleButton);
}
 
Example 4
Source File: SwitchController.java    From Ardulink-1 with Apache License 2.0 5 votes vote down vote up
/**
 * Create the panel.
 */
public SwitchController() {
	setPreferredSize(new Dimension(125, 75));
	setLayout(null);
	pinComboBoxModel = new IntMinMaxModel(0, 40).withSelectedItem(3);
	JComboBox pinComboBox = new JComboBox(pinComboBoxModel);
	pinComboBox.setBounds(66, 11, 47, 22);
	add(pinComboBox);
	
	JLabel label = new JLabel("Power Pin:");
	label.setFont(new Font("SansSerif", Font.PLAIN, 11));
	label.setBounds(10, 15, 59, 14);
	add(label);
	
	switchToggleButton = new JToggleButton("Off");
	switchToggleButton.addItemListener(new ItemListener() {
		public void itemStateChanged(ItemEvent e) {
			int pin = pinComboBoxModel.getSelectedItem().intValue();
			if(e.getStateChange() == ItemEvent.SELECTED) {
				switchToggleButton.setText("On");
				link.sendPowerPinSwitch(pin, IProtocol.POWER_HIGH);
			} else if(e.getStateChange() == ItemEvent.DESELECTED) {
				switchToggleButton.setText("Off");
				link.sendPowerPinSwitch(pin, IProtocol.POWER_LOW);
			}
		}
	});
	switchToggleButton.setBounds(10, 38, 103, 23);
	add(switchToggleButton);
}
 
Example 5
Source File: BluetoothConnectionPanel.java    From Ardulink-1 with Apache License 2.0 5 votes vote down vote up
/**
 * Create the panel.
 */
public BluetoothConnectionPanel() {

	Dimension dimension = new Dimension(275, 55);
	setPreferredSize(dimension);
	setMinimumSize(dimension);
	setLayout(null);

	JLabel devicesLabel = new JLabel("Devices:");
	devicesLabel.setHorizontalAlignment(SwingConstants.LEFT);
	devicesLabel.setBounds(6, 17, 65, 16);
	add(devicesLabel);

	deviceComboBox = new JComboBox();
	deviceComboBox.setBounds(67, 12, 165, 26);
	add(deviceComboBox);

	discoverButton = new JButton("");
	discoverButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			deviceComboBox.removeAllItems();
			PortListCallbackDialog dialog = new PortListCallbackDialog();
			UtilityGeometry.setAlignmentCentered(dialog,
					SwingUtilities.getRoot((Component) e.getSource()));
			getAsynchPortList(dialog, deviceComboBox);
			dialog.setVisible(true);
		}
	});
	discoverButton.setIcon(new ImageIcon(BluetoothConnectionPanel.class
			.getResource("icons/search_icon.png")));
	discoverButton.setToolTipText("Discover");
	discoverButton.setBounds(237, 9, 32, 32);
	add(discoverButton);

}
 
Example 6
Source File: TesteComponentes.java    From dctb-utfpr-2018-1 with Apache License 2.0 4 votes vote down vote up
public void TesteComponente(){
    janela.setVisible(true);
    janela.setSize(DIMENSOES);
    janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
    JScrollPane teste1 = new JScrollPane(painel);
    teste1.setBounds(1, 2, 150, 200);
    
    JButton teste2 = new JButton("Aperte");
    teste2.setBounds(210, 2, 100, 100);
    
    JToggleButton teste3 = new JToggleButton("Toggle");
    teste3.setBounds(320, 2, 100, 100);
    
    JCheckBox teste4 = new JCheckBox("Teste");
    teste4.setBounds(430, 2, 100, 100);
    
    JRadioButton teste5 = new JRadioButton("Teste2");
    teste5.setBounds(540, 2, 100, 100);
    
    JTextField teste6 = new JTextField();
    teste6.setToolTipText("Seu Nome");
    teste6.setBounds(1, 205, 200, 50);
    
    String[] numeros = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
    JList teste7 = new JList(numeros);
    JScrollPane teste7_2 = new JScrollPane(teste7);
    teste7_2.setBounds(210, 205, 100, 100);
    
    String[] numeros2 = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
    JComboBox teste8 = new JComboBox(numeros2);
    teste8.setBounds(320, 205, 50, 50);
    
    JLabel teste9 = new JLabel();
    teste9.setText("Biografia: ");
    teste9.setBounds(1, 290, 200, 100);
    
    JTextArea teste10 = new JTextArea();
    teste10.setToolTipText("Biografia");
    teste10.setBounds(1, 350, 100, 100);
    
    teste2.addActionListener(this);
    teste3.addActionListener(this);
    teste4.addActionListener(this);
    teste5.addActionListener(this);
    
    janela.add(teste1);
    janela.add(teste2);
    janela.add(teste3);
    janela.add(teste4);
    janela.add(teste5);
    janela.add(teste6);
    janela.add(teste7);
    janela.add(teste8);
    janela.add(teste9);
    janela.add(teste10);
}
 
Example 7
Source File: LoginFrame.java    From myqq with MIT License 4 votes vote down vote up
/**
 * Create the frame.
 */
public LoginFrame()
{
	setTitle("QQ2013");
	setIconImage(Toolkit.getDefaultToolkit().getImage(LoginFrame.class.getResource("/client/img/QQ_64.png")));
	setUndecorated(true);//设置窗体没有边框
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(100, 100, 354, 272);
	
	contentPane = new MyPanel("../img/QQ2011_Login.png");
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	
	pwd密码 = new JPasswordField();
	pwd密码.setText("123");
	pwd密码.setEchoChar('●');
	pwd密码.setBounds(104, 163, 154, 26);
	contentPane.add(pwd密码);
	
	lblQQ2013 = new JLabel("QQ2013");
	lblQQ2013.setForeground(new Color(0, 0, 51));
	lblQQ2013.setFont(new Font("宋体", Font.BOLD, 16));
	lblQQ2013.setBounds(14, 6, 55, 18);
	contentPane.add(lblQQ2013);
	
	lbl头像 = new JLabel("");
	lbl头像.setIcon(new ImageIcon(LoginFrame.class.getResource("/client/img/headImage/head_boy_01_64.jpg")));
	lbl头像.setBounds(18, 127, 64, 64);
	contentPane.add(lbl头像);
	
	checkBox记住密码 = new JCheckBox("\u8BB0\u4F4F\u5BC6\u7801");
	checkBox记住密码.setBounds(156, 198, 76, 18);
	contentPane.add(checkBox记住密码);
	
	checkBox自动登录 = new JCheckBox("\u81EA\u52A8\u767B\u5F55");
	checkBox自动登录.setBounds(237, 198, 76, 18);
	contentPane.add(checkBox自动登录);
	
	lbl登录 = new JLabel("");
	lbl登录.setIcon(new ImageIcon(LoginFrame.class.getResource("/client/img/button/button_login_1.png")));
	lbl登录.setBounds(262, 237, 69, 22);
	contentPane.add(lbl登录);
	
	textField用户名 = new JTextField();
	textField用户名.setText("\u9A6C\u5316\u817E");
	textField用户名.setBounds(104, 128, 154, 26);
	contentPane.add(textField用户名);
	textField用户名.setColumns(10);
	
	lbl注册账号 = new JLabel("\u6CE8\u518C\u8D26\u53F7");
	lbl注册账号.setFont(new Font("SansSerif", Font.PLAIN, 13));
	lbl注册账号.setForeground(new Color(0, 51, 255));
	lbl注册账号.setBounds(288, 132, 55, 18);
	contentPane.add(lbl注册账号);
	
	lbl忘记密码 = new JLabel("\u5FD8\u8BB0\u5BC6\u7801");
	lbl忘记密码.setFont(new Font("SansSerif", Font.PLAIN, 13));
	lbl忘记密码.setForeground(new Color(0, 51, 255));
	lbl忘记密码.setBounds(288, 167, 55, 18);
	contentPane.add(lbl忘记密码);
	
	lbl最小化 = new JLabel("");
	lbl最小化.setIcon(new ImageIcon(LoginFrame.class.getResource("/client/img/button/login_minsize_1.png")));
	lbl最小化.setBounds(284, 0, 29, 19);
	contentPane.add(lbl最小化);
	
	lbl退出 = new JLabel("");
	lbl退出.setIcon(new ImageIcon(LoginFrame.class.getResource("/client/img/button/login_exit_1.png")));
	lbl退出.setBounds(312, -1, 37, 20);
	contentPane.add(lbl退出);
	
	lbl多账号 = new JLabel("");
	lbl多账号.setIcon(new ImageIcon(LoginFrame.class.getResource("/client/img/button/login_duozhanghao_1.png")));
	lbl多账号.setBounds(14, 237, 69, 21);
	contentPane.add(lbl多账号);
	
	lbl设置 = new JLabel("");
	lbl设置.setIcon(new ImageIcon(LoginFrame.class.getResource("/client/img/button/login_setting_1.png")));
	lbl设置.setBounds(93, 237, 69, 21);
	contentPane.add(lbl设置);
	
	comboBox状态 = new JComboBox();
	comboBox状态.setBounds(104, 195, 40, 24);
	contentPane.add(comboBox状态);
}
 
Example 8
Source File: BroadcastFrame.java    From JRakNet with MIT License 4 votes vote down vote up
/**
 * Creates a broadcast test frame.
 */
protected BroadcastFrame() {
	// Frame and content settings
	this.setResizable(false);
	this.setSize(FRAME_WIDTH, FRAME_HEIGHT);
	this.setTitle("JRakNet Broadcast Test");
	this.getContentPane().setLayout(null);

	// Discovered MCPE Servers
	JTextPane txtpnDiscoveredMcpeServers = new JTextPane();
	txtpnDiscoveredMcpeServers.setEditable(false);
	txtpnDiscoveredMcpeServers.setBackground(UIManager.getColor("Button.background"));
	txtpnDiscoveredMcpeServers.setText("Discovered servers");
	txtpnDiscoveredMcpeServers.setBounds(10, 10, 350, 20);
	this.getContentPane().add(txtpnDiscoveredMcpeServers);

	// How the client will discover servers on the local network
	JComboBox<String> comboBoxDiscoveryType = new JComboBox<String>();
	comboBoxDiscoveryType.setToolTipText(
			"Changing this will update how the client will discover servers, by default it will look for any possible connection on the network");
	comboBoxDiscoveryType.setModel(new DefaultComboBoxModel<String>(DISCOVERY_MODE_OPTIONS));
	comboBoxDiscoveryType.setBounds(370, 10, 115, 20);
	comboBoxDiscoveryType.addActionListener(new RakNetBroadcastDiscoveryTypeListener());
	this.getContentPane().add(comboBoxDiscoveryType);

	// Used to update the discovery port
	JTextField textFieldDiscoveryPort = new JTextField();
	textFieldDiscoveryPort.setBounds(370, 45, 115, 20);
	textFieldDiscoveryPort.setText(Integer.toString(Discovery.getPorts()[0]));
	this.getContentPane().add(textFieldDiscoveryPort);
	textFieldDiscoveryPort.setColumns(10);
	JButton btnUpdatePort = new JButton("Update Port");
	btnUpdatePort.setBounds(370, 76, 114, 23);
	btnUpdatePort.addActionListener(new RakNetBroadcastUpdatePortListener(textFieldDiscoveryPort));
	this.getContentPane().add(btnUpdatePort);

	// The text containing the discovered MCPE servers
	txtPnDiscoveredMcpeServerList = new JTextPane();
	txtPnDiscoveredMcpeServerList.setToolTipText("This is the list of the discovered servers on the local network");
	txtPnDiscoveredMcpeServerList.setEditable(false);
	txtPnDiscoveredMcpeServerList.setBackground(UIManager.getColor("Button.background"));
	txtPnDiscoveredMcpeServerList.setBounds(10, 30, 350, 165);
	this.getContentPane().add(txtPnDiscoveredMcpeServerList);
}
 
Example 9
Source File: FontEditor.java    From lsdpatch with MIT License 4 votes vote down vote up
public FontEditor() {
      setTitle("Font Editor");
      setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
      setBounds(100, 100, 415, 324);
      setResizable(false);

      JMenuBar menuBar = new JMenuBar();
      setJMenuBar(menuBar);

      JMenu mnFile = new JMenu("File");
mnFile.setMnemonic(KeyEvent.VK_F);
      menuBar.add(mnFile);

      JMenuItem mntmOpen = new JMenuItem("Open...");
mntmOpen.setMnemonic(KeyEvent.VK_O);
      mntmOpen.addActionListener(this);
      mnFile.add(mntmOpen);

      JMenuItem mntmSave = new JMenuItem("Save...");
mntmSave.setMnemonic(KeyEvent.VK_S);
      mntmSave.addActionListener(this);
      mnFile.add(mntmSave);

      JMenu mnEdit = new JMenu("Edit");
mnEdit.setMnemonic(KeyEvent.VK_E);
      menuBar.add(mnEdit);

      JMenuItem mntmCopy = new JMenuItem("Copy Tile");
      mntmCopy.addActionListener(this);
      mntmCopy.setMnemonic(KeyEvent.VK_C);
      mnEdit.add(mntmCopy);

      JMenuItem mntmPaste = new JMenuItem("Paste Tile");
      mntmPaste.setMnemonic(KeyEvent.VK_P);
      mntmPaste.addActionListener(this);
      mnEdit.add(mntmPaste);

      contentPane = new JPanel();
      contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
      setContentPane(contentPane);
      contentPane.setLayout(null);

      fontMap = new FontMap();
      fontMap.setBounds(10, 42, 128, 146);
      fontMap.setTileSelectListener(this);
      contentPane.add(fontMap);

      tileEditor = new TileEditor();
      tileEditor.setBounds(148, 11, 240, 240);
      tileEditor.setTileChangedListener(this);
      contentPane.add(tileEditor);

      fontSelector = new JComboBox();
      fontSelector.setBounds(10, 11, 128, 20);
      fontSelector.setEditable(true);
      fontSelector.addItemListener(this);
      fontSelector.addActionListener(this);
      contentPane.add(fontSelector);

      color1 = new JRadioButton("1");
      color1.setBounds(10, 220, 37, 23);
      color1.addItemListener(this);
      color1.setMnemonic(KeyEvent.VK_1);
      contentPane.add(color1);

      color2 = new JRadioButton("2");
      color2.setBounds(49, 220, 37, 23);
      color2.addItemListener(this);
      color2.setMnemonic(KeyEvent.VK_2);
      contentPane.add(color2);

      color3 = new JRadioButton("3");
      color3.setBounds(88, 220, 37, 23);
      color3.addItemListener(this);
      color3.setSelected(true);
      color3.setMnemonic(KeyEvent.VK_3);
      contentPane.add(color3);

      colorGroup = new javax.swing.ButtonGroup();
      colorGroup.add(color1);
      colorGroup.add(color2);
      colorGroup.add(color3);

      JLabel lblColor = new JLabel("Color:");
      lblColor.setBounds(10, 199, 46, 14);
      contentPane.add(lblColor);
  }
 
Example 10
Source File: SerialConnectionPanel.java    From Ardulink-1 with Apache License 2.0 4 votes vote down vote up
/**
	 * Create the panel.
	 */
	public SerialConnectionPanel() {

		// decomment this to use simple byte protocol
//		link = Link.getInstance("serialConnection");
//		if(link == null) {
//			Set<String> protocolNames = ProtocolHandler.getInstalledProtocolImplementationNames();
//			if(!protocolNames.contains(SimpleBinaryProtocol.NAME)) {
//				ProtocolHandler.installProtocolImplementation(new SimpleBinaryProtocol());
//			}
//			link = Link.createInstance("serialConnection", SimpleBinaryProtocol.NAME);
//		}
		
		Dimension dimension = new Dimension(275, 80);
		setPreferredSize(dimension);
		setMinimumSize(dimension);
		setLayout(null);
		
		JLabel connectionPortLabel = new JLabel("Connection Port:");
		connectionPortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
		connectionPortLabel.setBounds(6, 16, 91, 16);
		add(connectionPortLabel);
		
		connectionPortComboBox = new JComboBox();
		connectionPortComboBox.setBounds(108, 10, 122, 28);
		add(connectionPortComboBox);
		
		lblBaudRate = new JLabel("Baud Rate:");
		lblBaudRate.setHorizontalAlignment(SwingConstants.RIGHT);
		lblBaudRate.setBounds(6, 44, 91, 16);
		add(lblBaudRate);
		
		baudRateTextField = new JTextField();
		baudRateTextField.setText(String.valueOf(Link.DEFAULT_BAUDRATE));
		baudRateTextField.setColumns(10);
		baudRateTextField.setBounds(108, 38, 122, 28);
		add(baudRateTextField);
		
		discoverButton = new JButton("");
		discoverButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				List<String> portList = link.getPortList();
//				portList = new ArrayList<String>(); // Mock code...
//				portList.add("COM19");
//				portList.add("COM20");
				if(portList != null && !portList.isEmpty()) {
					connectionPortComboBox
							.setModel(new DefaultComboBoxModel(portList
									.toArray(new String[portList.size()])));
				} else {
					connectionPortComboBox.removeAllItems();
				}
			}
		});
		discoverButton.setIcon(new ImageIcon(SerialConnectionPanel.class.getResource("icons/search_icon.png")));
		discoverButton.setToolTipText("Discover");
		discoverButton.setBounds(235, 8, 32, 32);
		add(discoverButton);
		

	}