Professional Documents
Culture Documents
Package Import Import Import Import Import Import Import Import Import Import Import Import Public Class Private Private Private Private
Package Import Import Import Import Import Import Import Import Import Import Import Import Public Class Private Private Private Private
java
package swing_1;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public JAVASwingFormPrimer() {
initialize();
}
/** * Initialize the contents of the frame. */
private void initialize() {
frmJavaSwingForm = new JFrame();
frmJavaSwingForm.setTitle("JAVA Swing Form Primer");
frmJavaSwingForm.setBounds(100, 100, 450, 463);
frmJavaSwingForm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmJavaSwingForm.getContentPane().setLayout(null);
JLabel lblNewLabel = new JLabel("Ime:");
lblNewLabel.setBounds(24, 27, 46, 14);
frmJavaSwingForm.getContentPane().add(lblNewLabel);
}
});
btnSubmit.setBounds(26, 371, 89, 23);
frmJavaSwingForm.getContentPane().add(btnSubmit);
}
});
btnClear.setBounds(193, 371, 89, 23);
frmJavaSwingForm.getContentPane().add(btnClear);
}
}
IZVORNI
JAVASwingFormPrimer.java
package swing_1;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JButton;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.JRadioButton;
import javax.swing.JToggleButton;
import javax.swing.JScrollBar;
import javax.swing.JComboBox;
import javax.swing.JCheckBox;
import java.awt.Font;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
JAVASwingFormPrimer window = new JAVASwingFormPrimer();
window.frmJavaSwingForma.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public JAVASwingFormPrimer() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frmJavaSwingForma = new JFrame();
frmJavaSwingForma.setTitle("Java swing forma - primer");
frmJavaSwingForma.setBounds(100, 100, 484, 486);
frmJavaSwingForma.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmJavaSwingForma.getContentPane().setLayout(null);
btnSubmit.setBackground(Color.WHITE);
btnSubmit.setForeground(Color.BLACK);
btnSubmit.setBounds(65, 387, 89, 23);
frmJavaSwingForma.getContentPane().add(btnSubmit);
btnSubmit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if(textField.getText().isEmpty()||
(textField_1.getText().isEmpty())||(textField_2.getText().isEmpty())||
(textArea_1.getText().isEmpty())||
((radioButton_1.isSelected())&&(radioButton.isSelected()))||
(comboBox.getSelectedItem().equals("Select")))
JOptionPane.showMessageDialog(null, "GREŠKA - Morate
popuniti sve podatke");
else
JOptionPane.showMessageDialog(null, "Podaci su u redu i biće
prosleđeni!");
}
});
btnClear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
textField_1.setText(null);
textField_2.setText(null);
textField.setText(null);
textArea_1.setText(null);
radioButton.setSelected(false);
radioButton_1.setSelected(false);
comboBox.setSelectedItem("Select");
}
});
}
}