From da3fd66287d7d5350241d235bd65e6e894c5e6c2 Mon Sep 17 00:00:00 2001 From: Steffen Ritter Date: Mon, 18 Jun 2018 17:11:17 +0200 Subject: [client] Force user to scroll disclaimer down --- .../openslx/dozmod/gui/window/GenericNoticeWindow.java | 18 ++++++++++++++++++ .../gui/window/layout/GenericNoticeWindowLayout.java | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window') diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/GenericNoticeWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/GenericNoticeWindow.java index 4660c8b6..94492d7f 100755 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/GenericNoticeWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/GenericNoticeWindow.java @@ -3,10 +3,13 @@ package org.openslx.dozmod.gui.window; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JFrame; +import javax.swing.JScrollBar; import org.apache.log4j.Logger; import org.openslx.dozmod.gui.Gui; @@ -49,6 +52,21 @@ public abstract class GenericNoticeWindow extends GenericNoticeWindowLayout impl chkAgreeBox.setVisible(false); btnContinue.setText("Schließen"); btnContinue.setEnabled(true); + } else { + disclaimerPanel.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() { + @Override + public void adjustmentValueChanged(AdjustmentEvent e) { + JScrollBar scrollBar = (JScrollBar) e.getAdjustable(); + int extent = scrollBar.getModel().getExtent(); + + int value = e.getValue() + extent; + int max = e.getAdjustable().getMaximum(); + + if (value >= max) { + chkAgreeBox.setEnabled(true); + } + } + }); } } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/GenericNoticeWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/GenericNoticeWindowLayout.java index 5b036892..56713dd5 100755 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/GenericNoticeWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/GenericNoticeWindowLayout.java @@ -22,6 +22,7 @@ public abstract class GenericNoticeWindowLayout extends JDialog { protected String info = "Bitte lesen und bestätigen Sie folgende rechtliche Hinweise:"; protected JTextArea notice; + protected JScrollPane disclaimerPanel; protected String checkboxText = "Ja, ich akzeptiere die Vereinbarung. Benachrichtigung nicht mehr anzeigen."; @@ -53,13 +54,14 @@ public abstract class GenericNoticeWindowLayout extends JDialog { notice.setEditable(false); notice.setLineWrap(true); notice.setWrapStyleWord(true); - JScrollPane disclaimerPanel = new JScrollPane(notice, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + disclaimerPanel = new JScrollPane(notice, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); // checkbox for acknowledging the notice JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); chkAgreeBox = new JCheckBox(checkboxText); + chkAgreeBox.setEnabled(false); buttonPanel.add(chkAgreeBox); // spacer buttonPanel.add(Box.createHorizontalGlue()); -- cgit v1.2.3-55-g7522