На строчке message = textMessage.getText() выдает java.NullPointerException. В чем дело?
public class ParamFrame extends JDialog {
private final JPanel contentPanel = new JPanel();
private JTextField textAlarmHour;
private JTextField textAlarmMinute;
private JTextField textTimerHour;
private JTextField textTimerMinute;
private JTextPane textMessage;
private JRadioButton radioButtonAlarm;
private JRadioButton radioButtonTimer;
private int alarmHour;
private int alarmMinute;
private int timerHour;
private int timerMinute;
private String message;
private NotificationType notificationType;
public enum NotificationType {
NONE,
ALARM,
TIMER;
}
/**
* Launch the application.
*/
private int convertToInt (String value){
if(value.isEmpty()) return 0;
try {
return Integer.parseInt(value);
} catch (NumberFormatException e) {
return 0;
}
}
public ParamFrame (MainFrame owner){
super(owner, "Параметры", true);
setTitle("\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0430 \u043E\u043F\u043E\u0432\u0435\u0449\u0435\u043D\u0438\u044F");
setAlwaysOnTop(true);
setBounds(100, 100, 447, 377);
getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
{
JPanel panelNotificationType = new JPanel();
panelNotificationType.setAlignmentX(Component.LEFT_ALIGNMENT);
panelNotificationType.setBorder(new TitledBorder(null, "\u041E\u043F\u043E\u0432\u0435\u0449\u0435\u043D\u0438\u0435", TitledBorder.LEADING, TitledBorder.TOP, null, null));
contentPanel.add(panelNotificationType);
panelNotificationType.setLayout(new BoxLayout(panelNotificationType, BoxLayout.Y_AXIS));
{
JRadioButton RadioButtonNone = new JRadioButton("\u041E\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442");
panelNotificationType.add(RadioButtonNone);
}
{
Component horizontalGlue = Box.createHorizontalGlue();
panelNotificationType.add(horizontalGlue);
}
{
JRadioButton radioButtonAlarm = new JRadioButton("\u0411\u0443\u0434\u0438\u043B\u044C\u043D\u0438\u043A");
panelNotificationType.add(radioButtonAlarm);
}
{
JRadioButton radioButtonTimer = new JRadioButton("\u0422\u0430\u0439\u043C\u0435\u0440");
panelNotificationType.add(radioButtonTimer);
}
}
{
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
tabbedPane.setAlignmentX(Component.LEFT_ALIGNMENT);
contentPanel.add(tabbedPane);
{
JPanel panelAlarm = new JPanel();
tabbedPane.addTab("\u0411\u0443\u0434\u0438\u043B\u044C\u043D\u0438\u043A", null, panelAlarm, null);
panelAlarm.setLayout(null);
{
JLabel label = new JLabel("\u0412\u0440\u0435\u043C\u044F \u0441\u0438\u0433\u043D\u0430\u043B\u0430 (\u0447:\u043C):");
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setBounds(142, 11, 104, 14);
panelAlarm.add(label);
}
textAlarmHour = new JTextField();
textAlarmHour.setBounds(62, 36, 86, 20);
panelAlarm.add(textAlarmHour);
textAlarmHour.setColumns(10);
textAlarmMinute = new JTextField();
textAlarmMinute.setBounds(169, 36, 86, 20);
panelAlarm.add(textAlarmMinute);
textAlarmMinute.setColumns(10);
}
{
JPanel panelTimer = new JPanel();
tabbedPane.addTab("\u0422\u0430\u0439\u043C\u0435\u0440", null, panelTimer, null);
panelTimer.setLayout(null);
{
JLabel label = new JLabel("\u0418\u043D\u0442\u0435\u0440\u0432\u0430\u043B \u0441\u0440\u0430\u0431\u0430\u0442\u044B\u0432\u0430\u043D\u0438\u044F \u0442\u0430\u0439\u043C\u0435\u0440\u0430 (\u0447:\u043C):");
label.setBounds(63, 8, 201, 14);
panelTimer.add(label);
}
textTimerHour = new JTextField();
textTimerHour.setBounds(63, 33, 86, 20);
panelTimer.add(textTimerHour);
textTimerHour.setColumns(10);
textTimerMinute = new JTextField();
textTimerMinute.setBounds(178, 33, 86, 20);
panelTimer.add(textTimerMinute);
textTimerMinute.setColumns(10);
}
}
{
JScrollPane scrollPane = new JScrollPane();
scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT);
contentPanel.add(scrollPane);
{
JTextPane textMessage = new JTextPane();
scrollPane.setViewportView(textMessage);
}
{
JLabel labelNotification = new JLabel("\u0421\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435");
scrollPane.setColumnHeaderView(labelNotification);
}
}
{
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
getContentPane().add(buttonPane, BorderLayout.SOUTH);
{
JButton okButton = new JButton("OK");
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
notificationType = NotificationType.NONE;
message = textMessage.getText();
if(radioButtonAlarm.isSelected()) {
notificationType = NotificationType.ALARM;
alarmHour = convertToInt(textAlarmHour.getText());
alarmMinute = convertToInt(textAlarmMinute.getText());
}
if(radioButtonTimer.isSelected()) {
notificationType = NotificationType.TIMER;
timerHour = convertToInt(textTimerHour.getText());
timerMinute = convertToInt(textTimerMinute.getText());
}
setVisible(false);
dispose();
}
});
okButton.setActionCommand("OK");
buttonPane.add(okButton);
getRootPane().setDefaultButton(okButton);
}
{
JButton cancelButton = new JButton("\u041E\u0442\u043C\u0435\u043D\u0430");
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
dispose();
}
});
cancelButton.setActionCommand("Cancel");
buttonPane.add(cancelButton);
}
}
}
public int getAlarmHour() {
return alarmHour;
}
public int getAlarmMinute() {
return alarmMinute;
}
public int getTimerHour() {
return timerHour;
}
public int getTimerMinute() {
return timerMinute;
}
public String getMessage() {
return message;
}
public NotificationType getNotificationType() {
return notificationType;
}
}
Айфон мало держит заряд, разбираемся с проблемой вместе с AppLab
Перевод документов на английский язык: Важность и ключевые аспекты
Есть ли в природе готовый плагин jquery для перетаскивания ячеек html ? чтоб в дальнейшем их можно было сохранить в базу новые значения позиций
Захотелось быстро поработать с Oracle без кучи фреймворковских библиотекСоздаем любой статический класс и добавляем метод: