Author: tilman
Date: Tue Aug 25 13:25:11 2026
New Revision: 1937433

Log:
PDFBOX-6240: add a title bar to the popup; swing changes by copilot

Modified:
   
pdfbox/branches/3.0/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java

Modified: 
pdfbox/branches/3.0/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java
==============================================================================
--- 
pdfbox/branches/3.0/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java
        Tue Aug 25 12:59:57 2026        (r1937432)
+++ 
pdfbox/branches/3.0/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java
        Tue Aug 25 13:25:11 2026        (r1937433)
@@ -84,6 +84,7 @@ import org.apache.pdfbox.pdmodel.interac
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationFreeText;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLink;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget;
 import 
org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination.PDDestination;
 import 
org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination.PDNamedDestination;
@@ -118,6 +119,7 @@ public class PagePane implements ActionL
     private final AffineTransform defaultTransform = 
GraphicsEnvironment.getLocalGraphicsEnvironment().
                         
getDefaultScreenDevice().getDefaultConfiguration().getDefaultTransform();
     private JWindow hoverWindow;
+    private JLabel hoverTitleLabel;
     private JTextArea hoverTextArea;
 
     // more ideas:
@@ -160,6 +162,11 @@ public class PagePane implements ActionL
         hoverWindow = new JWindow();
         hoverWindow.setAlwaysOnTop(true);
 
+        hoverTitleLabel = new JLabel("Annotation");
+        hoverTitleLabel.setOpaque(true);
+        hoverTitleLabel.setBackground(new Color(230, 230, 230));
+        hoverTitleLabel.setBorder(BorderFactory.createEmptyBorder(4, 8, 4, 8));
+
         hoverTextArea = new JTextArea(4, 24);
         hoverTextArea.setEditable(false);
         hoverTextArea.setOpaque(true);
@@ -168,7 +175,8 @@ public class PagePane implements ActionL
         hoverTextArea.setBorder(BorderFactory.createEmptyBorder(6, 8, 6, 8));
 
         JPanel content = new JPanel(new BorderLayout());
-        content.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); // 
thin border
+        content.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
+        content.add(hoverTitleLabel, BorderLayout.NORTH);
         content.add(hoverTextArea, BorderLayout.CENTER);
 
         hoverWindow.setContentPane(content);
@@ -493,6 +501,7 @@ public class PagePane implements ActionL
         int y1;
         PDRectangle hitRect = null;
         String hitText = null;
+        String hitTitle = null;
 
         switch ((RotationMenu.getRotationDegrees() + page.getRotation()) % 360)
         {
@@ -536,6 +545,10 @@ public class PagePane implements ActionL
                 {
                     hitRect = rectangle;
                     hitText = contents;
+                    if (annotation instanceof PDAnnotationMarkup)
+                    {
+                        hitTitle = ((PDAnnotationMarkup) 
annotation).getTitlePopup();
+                    }
                 }
                 text += ", " + s;
                 break;
@@ -547,7 +560,7 @@ public class PagePane implements ActionL
 
         if (hitRect != null)
         {
-            showHoverPopup(e, hitText);
+            showHoverPopup(e, hitText, hitTitle);
         }
         else
         {
@@ -555,10 +568,19 @@ public class PagePane implements ActionL
         }
     }
 
-    private void showHoverPopup(MouseEvent e, String text)
+    private void showHoverPopup(MouseEvent e, String text, String title)
     {
         hoverTextArea.setText(text);
         hoverTextArea.setCaretPosition(0);
+        if (title != null && !title.isEmpty())
+        {
+            hoverTitleLabel.setVisible(true);
+            hoverTitleLabel.setText(title);
+        }
+        else
+        {
+            hoverTitleLabel.setVisible(false);
+        }
         hoverWindow.pack();
 
         Point screen = e.getLocationOnScreen();

Reply via email to