当前位置: 首页>>代码示例>>Java>>正文


Java JButton.setBounds方法代码示例

本文整理汇总了Java中javax.swing.JButton.setBounds方法的典型用法代码示例。如果您正苦于以下问题:Java JButton.setBounds方法的具体用法?Java JButton.setBounds怎么用?Java JButton.setBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JButton的用法示例。


在下文中一共展示了JButton.setBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: WindowGame

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Create the frame.
 */
public WindowGame() {
	setIconImage(Toolkit.getDefaultToolkit().getImage(WindowGame.class.getResource("/resource/chip.png")));
	setTitle("\u6A4B\u724C123");
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(100, 100, 980, 500);
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	
	textField = new JTextField();
	textField.setBounds(650, 422, 239, 29);
	contentPane.add(textField);
	textField.setColumns(10);
	
	JButton btnNewButton = new JButton("\u50B3\u9001");
	btnNewButton.setBounds(886, 422, 68, 29);
	contentPane.add(btnNewButton);
	
	JTextArea textArea = new JTextArea();
	textArea.setBounds(650, 0, 304, 423);
	contentPane.add(textArea);
}
 
开发者ID:aben20807,项目名称:bridgechat,代码行数:27,代码来源:WindowGame.java

示例2: test_skip

import javax.swing.JButton; //导入方法依赖的package包/类
private void test_skip() {
		JButton button1 = new JButton("��ʾ-menu");
//		game.add(button1);
		button1.setBounds(600, 200, 100, 40);
		button1.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				cardLayout.show(panelFirst, "id_menu");
			}
		});
		game.setLayout(null);
		JButton button2 = new JButton("��ʾ-game");
//		menu.add(button2);

		button2.addActionListener(event -> {
			cardLayout.show(panelFirst, "id_game");
		});
	}
 
开发者ID:BH2017,项目名称:snake_classic,代码行数:21,代码来源:UserInterface0.java

示例3: add

import javax.swing.JButton; //导入方法依赖的package包/类
public void add(TrnControllerGUI g) {
	guiList.add(g);
	
	JLabel L = new JLabel(g.getId());
	stylizeInfoLabel_Bold(L);
	idList.add(L);
	L.setBounds(30, yCount + 8, 100, 24);
	contentPane.add(L);
	
	JButton B = new JButton("VIEW");
	stylizeButton(B);
	buttonList.add(B);
	B.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent e) {	//finds the index of the button and sets the same index controller gui to visible
			int i = buttonList.indexOf(B);
			TrnControllerGUI I = guiList.get(i);
			I.setVisible(true);
		}
	});
	B.setBounds(150, yCount, 70, 37);
	B.setVisible(true);
	B.setEnabled(true);
	contentPane.add(B);
	
	yCount = yCount + 50;
	if (yCount >= (height - 50)) {	//increases size of frame if the buttons need more space
		height = height + 50;
		logoHeight = logoHeight + 50;
		frame.setBounds(100, 500, 450, height);
		icon_logo.setBounds(330, logoHeight, 100, 100);
	}
	frame.repaint();
}
 
开发者ID:kevingilboy,项目名称:COE1186,代码行数:35,代码来源:TrainControllerGUI.java

示例4: AddBreakPoint

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Create the frame.
 */
public AddBreakPoint(DefaultListModel<BreakPoint> breakpoint) {
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(100, 100, 450, 300);
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	
	JComboBox<Object> comboBox = new JComboBox<Object>();
	comboBox.setModel(new DefaultComboBoxModel<Object>(Variable.values()));
	comboBox.setBounds(10, 115, 141, 20);
	contentPane.add(comboBox);
	
	textField = new JTextField();
	textField.setBounds(226, 115, 141, 20);
	contentPane.add(textField);
	textField.setColumns(10);
	
	JButton btnAddBreakpoint = new JButton("Add BreakPoint");
	btnAddBreakpoint.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent arg0) {
			Object val = null;
			String text = textField.getText().toLowerCase();
			if(text.equals("true"))
				val = true;
			else if(text.equals("false"))
				val = false;
			else{
				val = Integer.parseInt(text, 16);
			}
			breakpoint.addElement(new BreakPoint((Variable) comboBox.getSelectedItem(),val));
			setVisible(false);
			dispose();
		}
	});
	btnAddBreakpoint.setBounds(138, 191, 141, 23);
	contentPane.add(btnAddBreakpoint);
}
 
开发者ID:QuantumSoundings,项目名称:BassNES,代码行数:42,代码来源:AddBreakPoint.java

示例5: GUI_BASIC2

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Create the frame.
 */
public GUI_BASIC2(String name, DATA_SETTINGS data_SETTINGS, SETUP setup) {
	setTitle(name);
	this.settings = data_SETTINGS;
	this.setup = setup;
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(100, 100, 297, 287);
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	autoButton = new JButton("Start Autopilot");
	autoButton.setToolTipText("Starts the autopilot");
	autoButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
		}
	});
	autoButton.setBounds(46, 82, 186, 45);
	contentPane.add(autoButton);
	textLabel = new JLabel("Connected to " + settings.getHostname());
	textLabel.setBounds(28, 31, 221, 20);
	contentPane.add(textLabel);
	//textLabel.setColumns(10);
	button = new JButton("Execute Node");
	button.setToolTipText("Executes the next node for the current vessel");
	button.setBounds(46, 148, 186, 45);
	contentPane.add(button);
	consolebutton = new JButton("console");
	consolebutton.setBounds(98, 214, 89, 23);
	consolebutton.setToolTipText("Opens/Closes the console");
	contentPane.add(consolebutton);
	console = new GUI_CONSOLE("Missionlog");
	console.setLocationRelativeTo(this);
	console.setLocation(console.getLocation().x + 400, console.getLocation().y - 20);
	setup();

}
 
开发者ID:Nik4053,项目名称:KSP-AGuS-Automatic-Guidance-System,代码行数:40,代码来源:GUI_BASIC2.java

示例6: Channel

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Create the frame to choose the channel
 */
public Channel() {
	this.setTitle("Chat IRC");
	this.setResizable(false);
	this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	this.setBounds(100, 100, 460, 261);
	this.setLocationRelativeTo(null);
	setIconImage(Toolkit.getDefaultToolkit().getImage(Channel.class.getResource("/image/swag.png")));
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	
	JButton btnOk = new JButton("OK");
	Icon imgOk = new ImageIcon(Toolkit.getDefaultToolkit().getImage(Channel.class.getResource("/image/ok.png")));
	btnOk.setIcon(imgOk);
	btnOk.setFont(new Font("Tahoma", Font.BOLD, 14));
	btnOk.addActionListener(new ChannelListener());
	btnOk.setBounds(164, 152, 104, 30);
	contentPane.add(btnOk);
	
	JLabel lblChannel = new JLabel("Channel");
	lblChannel.setHorizontalAlignment(SwingConstants.LEFT);
	lblChannel.setFont(new Font("Tahoma", Font.BOLD, 14));
	lblChannel.setBounds(187, 30, 72, 30);
	contentPane.add(lblChannel);
	
	textFieldChannel = new JTextField();
	textFieldChannel.setFont(new Font("Tahoma", Font.PLAIN, 14));
	textFieldChannel.setBounds(115, 85, 203, 30);
	contentPane.add(textFieldChannel);
	textFieldChannel.setColumns(10);
	
	this.addWindowListener( new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
			closeFrame();
		}
	});
}
 
开发者ID:LittleSnake42,项目名称:java-irc,代码行数:42,代码来源:Channel.java

示例7: JWindow

import javax.swing.JButton; //导入方法依赖的package包/类
public JWindow(String name)
{
	super(name);
	 
	panel = new MyPanel(this);
	this.setContentPane(panel);
	
	setPreferredSize(log_box);
	
	setAlwaysOnTop(true);
       setVisible(true);
       setResizable(false);
       setDefaultCloseOperation(EXIT_ON_CLOSE);
	
       paintText = new ArrayList<String>();
       
	setLayout(null);
	
	button_launch = new JButton("LAUNCH");
	button_launch.addActionListener(this);
	add(button_launch);
	
	button_abort = new JButton("ABORT");
	button_abort.addActionListener(this);
	button_abort.setBounds(300, 0, 100, 220);
	
	Dimension size = new Dimension();
	size.width = 200;
	size.height = 86;
	Dimension pos = new Dimension(190, 100);
	button_launch.setBounds(pos.width-Math.round(size.width/2f), pos.height-Math.round(size.height/2f), size.width, size.height);
	
	text_ap = new JTextArea("75000");
	text_ap.setBounds(105, 170, 170, 15);
	
	add(text_ap);
	
	pack();
}
 
开发者ID:janw23,项目名称:New-Kepard,代码行数:40,代码来源:JWindow.java

示例8: TextNotification

import javax.swing.JButton; //导入方法依赖的package包/类
public TextNotification() {
	m_fromLabel = new JLabel();
	m_titleLabel = new JLabel();
	m_titleLabel.addMouseListener(new NotificationMouseAdapter(m_titleLabel));
	
	m_subtitleArea = new JTextArea();
	m_subtitleArea.addMouseListener(new NotificationMouseAdapter(m_titleLabel));
	
	JPanel panelHeader = new JPanel();
	panelHeader.setLayout(new BoxLayout(panelHeader, BoxLayout.PAGE_AXIS));
	JButton dimissButton = new JButton();
	dimissButton.setText("X");
	final TextNotification me = this;
	dimissButton.addActionListener(new ActionListener() {

		@Override
		public void actionPerformed(ActionEvent arg0) {
			// TODO Auto-generated method stub
			me.removeFromManager();
		}
		
	});
	dimissButton.setOpaque(false);
	dimissButton.setContentAreaFilled(false);
	dimissButton.setBorderPainted(false);
	dimissButton.setBounds((int) (this.getWidth() - dimissButton.getPreferredSize().getWidth()), 0, (int) dimissButton.getPreferredSize().getWidth(), (int) dimissButton.getPreferredSize().getHeight());
	m_panel.add(dimissButton);
	
	
	panelHeader.add(m_fromLabel);
	panelHeader.add(m_titleLabel);
	this.addComponent(panelHeader, BorderLayout.NORTH);
	this.addComponent(m_subtitleArea, BorderLayout.CENTER);
}
 
开发者ID:OwaNotifier,项目名称:owa-notifier,代码行数:35,代码来源:TextNotification.java

示例9: Components

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Initializing the components.
 */
private void Components() {
	
	letsPlay = new JLabel("Let's Play");
	letsPlay.setHorizontalAlignment(SwingConstants.CENTER);
	letsPlay.setBounds(6, 6, 644, 16);
	contentPane.add(letsPlay);
	
	vLabel = new JLabel("Vehicle:");
	vLabel.setBounds(6, 47, 61, 16);
	contentPane.add(vLabel);
	
	vehicle = new JComboBox<>();
	vehicle.setBounds(79, 43, 83, 27);
	contentPane.add(vehicle);
	
	rLabel = new JLabel("Row:");
	rLabel.setBounds(174, 47, 44, 16);
	contentPane.add(rLabel);
	
	row = new JComboBox<>();
	row.setBounds(230, 43, 83, 27);
	contentPane.add(row);
	
	colsLabel = new JLabel("Column:");
	colsLabel.setBounds(335, 47, 61, 16);
	contentPane.add(colsLabel);
	
	column = new JComboBox<>();
	column.setBounds(408, 43, 83, 27);
	contentPane.add(column);
	
	execute = new JButton("Execute");
	execute.setForeground(Color.BLACK);
	execute.setBackground(Color.WHITE);
	execute.setBounds(503, 42, 117, 29);
	contentPane.add(execute);
	
	lblThisRowAnd = new JLabel("This row and column represents the head of vehicle");
	lblThisRowAnd.setFont(new Font("Lucida Grande", Font.PLAIN, 9));
	lblThisRowAnd.setBounds(200, 26, 252, 16);
	contentPane.add(lblThisRowAnd);
	
	int x = 174, y = 97;
	for(int i = 0; i < cells.length; i++){
	
		for(int j = 0; j < cells[i].length; j++){
			
			cells[i][j] = new JLabel("");
			cells[i][j].setOpaque(true);
			cells[i][j].setForeground(Color.white);
			cells[i][j].setHorizontalAlignment(SwingConstants.CENTER);
			cells[i][j].setBackground(new Color(204, 204, 204));
			cells[i][j].setBounds(x+(j*50), y, 50, 50);
			x += 1;
			contentPane.add(cells[i][j]);
		}
		x = 174;
		y += 51;
	}
	
	cells[2][5].setText("Exit");
	cells[2][5].setBackground(Color.red);
	
	for(int i = 1; i <= 6; i++){
		vehicle.addItem(String.valueOf(i));
		row.addItem(String.valueOf(i));
		column.addItem(String.valueOf(i));
	}
	
}
 
开发者ID:rehanjavedofficial,项目名称:Rush-Hour,代码行数:74,代码来源:MainFrame.java

示例10: PackOpeningPanel

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Create the panel.
 */
public PackOpeningPanel() {
	setLayout(null);
	
	btnNewButton = new JButton("Buy a Pack");
	btnNewButton.setBounds(26, 102, 117, 29);
	add(btnNewButton);
	
	btnBack = new JButton("Back");
	btnBack.setBounds(26, 174, 117, 29);
	add(btnBack);
	
	btnOpenAPack = new JButton("Open a Pack");
	btnOpenAPack.setBounds(26, 139, 117, 29);
	add(btnOpenAPack);
	
	JButton btnNewButton_1 = new JButton("");
	btnNewButton_1.setEnabled(false);
	btnNewButton_1.setBounds(350, 20, 125, 68);
	add(btnNewButton_1);
	card_places.add(btnNewButton_1);
	
	JButton button = new JButton("");
	button.setEnabled(false);
	button.setBounds(217, 102, 125, 68);
	add(button);
	card_places.add(button);

	
	JButton button_1 = new JButton("");
	button_1.setEnabled(false);
	button_1.setBounds(486, 102, 125, 68);
	add(button_1);
	card_places.add(button_1);
	
	JButton button_2 = new JButton("");
	button_2.setEnabled(false);
	button_2.setBounds(281, 182, 125, 68);
	add(button_2);
	card_places.add(button_2);
	
	JButton button_3 = new JButton("");
	button_3.setEnabled(false);
	button_3.setBounds(418, 182, 125, 68);
	add(button_3);
	card_places.add(button_3);
	
	lblPacks = new JLabel("Packs: ");
	lblPacks.setBounds(36, 215, 125, 16);
	add(lblPacks);
	
	lblGold = new JLabel("Gold: ");
	lblGold.setBounds(35, 234, 125, 16);
	add(lblGold);

}
 
开发者ID:ikhaliq15,项目名称:JHearthstone,代码行数:59,代码来源:PackOpeningPanel.java

示例11: Instructions

import javax.swing.JButton; //导入方法依赖的package包/类
public Instructions(JFrame f, int frameBoundX, int frameBoundY) {
	
	// Font
	InputStream is = Menu.class.getResourceAsStream("Cheap Potatoes.ttf");
	try {
		font = Font.createFont(Font.TRUETYPE_FONT, is);
	} catch (FontFormatException | IOException e1) {
		// TODO Auto-generated catch
		// block
		e1.printStackTrace();
	}
	
	//Main Panel of Instructions Section created here
	JPanel instrPanel = new JPanel();
	instrPanel.setLayout(null);
	setBounds(0,0,frameBoundX, frameBoundY);
	
	//Logo
	JLabel logoLabel = new JLabel("GEOTRIX", SwingConstants.CENTER);
	sizedFont = font.deriveFont(68f);
	logoLabel.setFont(sizedFont);
	logoLabel.setBounds(frameBoundX / 2 - 200, (frameBoundY-520)/ 2, 400, 190);
	
	JButton backButton = new JButton("Back");
	backButton.setBorderPainted(false);
	backButton.setFocusPainted(false);
	backButton.setContentAreaFilled(false);
	sizedFont = font.deriveFont(Font.BOLD, 30f);
	backButton.setFont(sizedFont);
	backButton.setForeground(Color.RED);
	backButton.setBounds(10, 10, 200, 100);
	// when backButton clicked
	backButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			//remove panel
			instrPanel.setVisible(false);
			f.remove(instrPanel);
			new MainMenu(f, frameBoundX, frameBoundY);
		}
	});
	
	//Logo
	JLabel instructionLabel = new JLabel("Arrow keys + Space button", SwingConstants.CENTER);
	sizedFont = font.deriveFont(40f);
	instructionLabel.setFont(sizedFont);
	instructionLabel.setBounds(25, frameBoundY/2 - 100, frameBoundX - 50, 200);
	instrPanel.add(instructionLabel);

	//Background Icon
	String img = "background_revision.jpg";
	ImageIcon imgIc = new ImageIcon(this.getClass().getResource(img));
	
	//Backgroud Label
	JLabel bgLabel = new JLabel(imgIc);
	bgLabel.setBounds(0, 0, frameBoundX, frameBoundY);

	instrPanel.add(backButton);
	instrPanel.add(logoLabel);
	instrPanel.add(bgLabel);
	
	f.add(instrPanel);
	f.revalidate();
	f.setVisible(true);
	
	
}
 
开发者ID:berkunal,项目名称:SWEngProject,代码行数:67,代码来源:Instructions.java

示例12: DialogFrame

import javax.swing.JButton; //导入方法依赖的package包/类
public DialogFrame() {
	
	setType(Type.POPUP);
	setResizable(false);
	
	setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
	this.setTitle("Approving question");
	this.setPreferredSize(new Dimension(400, 190));
	this.setAlwaysOnTop(isAlwaysOnTopSupported());
	this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	getContentPane().setLayout(new BorderLayout());
	
	final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	
	this.setLocation(screenSize.width / 2 - 150, screenSize.height / 2 - 75);
	
	this.setIconImage(Toolkit.getDefaultToolkit().
			getImage(getClass().getResource(LOGOPATH)));
	
	final JPanel panel = new JPanel();
	panel.setAutoscrolls(true);
	getContentPane().add(panel, BorderLayout.CENTER);
	panel.setLayout(null);
	
	btnYes = new JButton("YES");
	btnYes.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
	btnYes.setBounds(291, 129, 91, 29);
	panel.add(btnYes);
	
	btnNo = new JButton("NO");
	btnNo.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
	btnNo.setBounds(199, 129, 91, 29);
	panel.add(btnNo);
	
	lblIcon = new JLabel("");
	lblIcon.setIcon(new ImageIcon(DialogFrame.class.getResource("/com/coder/hms/icons/dialogPane_question.png")));
	lblIcon.setBounds(14, 40, 69, 70);
	panel.add(lblIcon);
	
	
	textArea = new JTextArea();
	textArea.setDisabledTextColor(new Color(153, 204, 255));
	textArea.setBounds(95, 32, 287, 85);
	textArea.setBackground(UIManager.getColor("ComboBox.background"));
	textArea.setBorder(null);
	textArea.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
	textArea.setEditable(false);
	textArea.setFont(new Font("Monospaced", Font.PLAIN, 14));
	textArea.setLineWrap(true);
	panel.add(textArea);
	
	this.pack();
}
 
开发者ID:Coder-ACJHP,项目名称:Hotel-Properties-Management-System,代码行数:54,代码来源:DialogFrame.java

示例13: Gestiones

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Create the frame.
 **/
public Gestiones() {
	setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	setBounds(100, 100, 403, 359);
	setLocationRelativeTo(null);
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	
	btnPrimero = new JButton("<<");
	btnPrimero.setBounds(14, 215, 54, 23);
	contentPane.add(btnPrimero);
	btnPrimero.addActionListener(this);
	
	btnAnterior = new JButton("<");
	btnAnterior.setBounds(82, 215, 54, 23);
	contentPane.add(btnAnterior);
	btnAnterior.addActionListener(this);
	
	btnSiguiente = new JButton(">");
	btnSiguiente.setBounds(250, 215, 54, 23);
	contentPane.add(btnSiguiente);
	btnSiguiente.addActionListener(this);
	
	btnUltimo = new JButton(">>");
	btnUltimo.setBounds(318, 215, 54, 23);
	contentPane.add(btnUltimo);
	btnUltimo.addActionListener(this);
	
	txtEstado = new JTextField();
	txtEstado.setHorizontalAlignment(SwingConstants.CENTER);
	txtEstado.setEditable(false);
	txtEstado.setBounds(150, 216, 86, 20);
	contentPane.add(txtEstado);
	txtEstado.setColumns(10);
	
	btnModificar = new JButton("Modificar");
	btnModificar.setBounds(30, 273, 89, 23);
	contentPane.add(btnModificar);
	btnModificar.addActionListener(this);
	
	btnNuevo = new JButton("Nuevo");
	btnNuevo.setBounds(149, 273, 89, 23);
	contentPane.add(btnNuevo);
	btnNuevo.addActionListener(this);
	
	btnEliminar = new JButton("Eliminar");
	btnEliminar.setBounds(268, 273, 89, 23);
	contentPane.add(btnEliminar);
	btnEliminar.addActionListener(this);
	
	setVisible(true);
	addWindowListener(this);
}
 
开发者ID:JuandeLS3,项目名称:Library-app,代码行数:58,代码来源:Gestiones.java

示例14: initialize

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
	frame = new JFrame();
	frame.setTitle("MD5");
	frame.setResizable(false);
	frame.setBounds(100, 100, 450, 580);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().setLayout(null);

	JLabel label = new JLabel("Please select your files:");
	label.setBounds(105, 32, 227, 16);
	frame.getContentPane().add(label);

	final JLabel error = new JLabel("");
	error.setForeground(new Color(255,0,0));
	error.setBounds(120, 52, 250, 16);
	frame.getContentPane().add(error);

	final JFileChooser filesChooser = new JFileChooser();
	filesChooser.setControlButtonsAreShown(false);
	filesChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
	filesChooser.setMultiSelectionEnabled(true);
	filesChooser.setBounds(41, 62, 362, 400);
	frame.getContentPane().add(filesChooser);

	JButton btnStartMD5 = new JButton("Start MD5");
	btnStartMD5.setBounds(132, 490, 177, 29);
	frame.getContentPane().add(btnStartMD5);

	//listener to run the application launch when the button is pressed
	btnStartMD5.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e)  {
			// It recovers the files selected
			File[] files;
			try{
				files = filesChooser.getSelectedFiles();
			}catch(NullPointerException exc){
				error.setText("No selected file");
				throw new Md5Exception("No selected file : " + exc.getMessage());
			}
			for(int i = 0; i < files.length; i++){
				String fileName = files[i].getAbsolutePath()  ;
				//Creation du md5 en java
				String output;
				try{
					output = CreateMD5.getMD5(fileName);
				}catch(Md5Exception e1){
					error.setText("Error creating the MD5");
					throw new Md5Exception("Error creating the MD5 : " + e1.getMessage());
				}
				/*Writing the md5 file
				  remove the extension of the original file if there is*/
				String path;
				if(files[i].getAbsolutePath().lastIndexOf(".") == -1){
					path = files[i].getAbsolutePath() + ".md5";
				}else {
					String nomFichierSansExt = files[i].getAbsolutePath().substring(0, files[i].getAbsolutePath().lastIndexOf(".")) ;
					path = nomFichierSansExt + ".md5";
				}	
				File file = new File(path); 
				try {
					if (!file.exists()){
						// File Creation
						file.createNewFile();
					}
					FileWriter writer = new FileWriter(file, true);
					writer.write(output);
					writer.close();
				} catch (Exception ex) {
					error.setText("Impossible to create MD5");
					throw new Md5Exception("Impossible to create MD5 : " + ex.getMessage());
				}
			} 
		}
	});
}
 
开发者ID:matleses,项目名称:MD5,代码行数:79,代码来源:MD5.java

示例15: NuevoPrestamo

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * @wbp.parser.constructor
 */
public NuevoPrestamo(Connection conn,JFrameJTable principal,String nombreuser,int codusuario,int codigoproducto,char tipochooser,String fecha) {
	setIconImage(Toolkit.getDefaultToolkit().getImage(NuevoPrestamo.class.getResource("/biblioteca/images/book.png")));
	setTitle("Modificar pr�stamo");
	this.principal=principal;
	this.conn=conn;
	initComponents();
	
	btnBuscarUsuario.setEnabled(false);
	btnBuscarCodigo.setEnabled(false);
	txtUsuario.setText(nombreuser);
	txtCodigo.setText(""+codigoproducto);
	PKuser=""+codusuario;
	PKproducto=""+codigoproducto;

	switch (tipochooser) {
	case 'L':
		tipo.select("Libro");
		break;
	case 'R':
		tipo.select("Revista");
		break;
	case 'C':
		tipo.select("CDROM");
		break;
	case 'A':
		tipo.select("Articulo");
		break;
	default:
		break;
	}


	fecha_devol = new JDateChooser();
	fecha_devol.setEnabled(false);
	fecha_devol.setBounds(265, 208, 126, 23);
	contentPane.add(fecha_devol);
	fecha_devol.setEnabled(true);
	
	JLabel lblfecha_prestDevol = new JLabel("Fecha de devoluci\u00F3n");
	lblfecha_prestDevol.setBounds(265, 193, 148, 14);
	contentPane.add(lblfecha_prestDevol);
	
	txtFecha_prest = new JTextField();
	txtFecha_prest.setEditable(false);
	txtFecha_prest.setBounds(16, 208, 126, 23);
	contentPane.add(txtFecha_prest);
	txtFecha_prest.setColumns(10);
	txtFecha_prest.setText(fecha);
	
	btnActualizar = new JButton("Actualizar");
	btnActualizar.setBounds(157, 264, 98, 23);
	contentPane.add(btnActualizar);
	btnActualizar.addActionListener(this);
	
	
	setVisible(true);
}
 
开发者ID:JuandeLS3,项目名称:Library-app,代码行数:61,代码来源:NuevoPrestamo.java


注:本文中的javax.swing.JButton.setBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。