diff --git a/src/jniplatform/cpp/JNIDecorations.cpp b/src/jniplatform/cpp/JNIDecorations.cpp index aaa4526e..659d6b85 100644 --- a/src/jniplatform/cpp/JNIDecorations.cpp +++ b/src/jniplatform/cpp/JNIDecorations.cpp @@ -120,7 +120,7 @@ LRESULT CALLBACK WindowWrapper::WindowProc(_In_ HWND hwnd, _In_ UINT uMsg, _In_ } JNIEXPORT void JNICALL -JJava_com_github_weisj_darklaf_platform_windows_JNIDecorations_setResizable(JNIEnv *env, jclass obj, jlong hwnd, jboolean res) +Java_com_github_weisj_darklaf_platform_windows_JNIDecorations_setResizable(JNIEnv *env, jclass obj, jlong hwnd, jboolean res) { HWND handle = reinterpret_cast(hwnd); auto wrap = wrapper_map[handle]; diff --git a/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java b/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java index 49f31287..1dd19ebd 100644 --- a/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java +++ b/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java @@ -23,6 +23,7 @@ */ package com.github.weisj.darklaf.ui.table; +import com.github.weisj.darklaf.components.OverlayScrollPane; import com.github.weisj.darklaf.util.DarkUIUtil; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; @@ -170,6 +171,7 @@ public class DarkTableUI extends DarkTableUIBridge { selectionBackground = UIManager.getColor("Table.selectionNoFocusBackground"); } + @Override protected void paintGrid(@NotNull final Graphics g, final int rMin, final int rMax, final int cMin, final int cMax) { @@ -240,11 +242,9 @@ public class DarkTableUI extends DarkTableUIBridge { } protected boolean scrollBarVisible() { - Container comp = SwingUtilities.getUnwrappedParent(table); - if (comp != null) { - comp = comp.getParent(); - } - return comp instanceof JScrollPane && ((JScrollPane) comp).getVerticalScrollBar().isVisible(); + JScrollPane comp = DarkUIUtil.getParentOfType(JScrollPane.class, table); + return comp != null && comp.getVerticalScrollBar().isVisible() + && DarkUIUtil.getParentOfType(OverlayScrollPane.class, table) == null; } protected boolean showVerticalLine(final boolean ltr, final boolean scrollVisible, @@ -336,16 +336,14 @@ public class DarkTableUI extends DarkTableUIBridge { } } } - if (table.isEditing() && table.getEditingRow() == row && - table.getEditingColumn() == column) { + if (table.isEditing() && table.getEditingRow() == row && table.getEditingColumn() == column) { Component component = table.getEditorComponent(); - component.setBounds(cellRect); + component.setBounds(r); component.validate(); } else { TableCellRenderer renderer = table.getCellRenderer(row, column); Component component = table.prepareRenderer(renderer, row, column); - rendererPane.paintComponent(g, component, table, cellRect.x, cellRect.y, - cellRect.width, cellRect.height, true); + rendererPane.paintComponent(g, component, table, r.x, r.y, r.width, r.height, true); } } @@ -370,31 +368,28 @@ public class DarkTableUI extends DarkTableUIBridge { parent = par.getParent(); } } + int tableHeight = getPreferredSize(table).height; g.setColor(parent.getBackground()); - g.fillRect(vacatedColumnRect.x, vacatedColumnRect.y, - vacatedColumnRect.width - 1, vacatedColumnRect.height); + g.fillRect(vacatedColumnRect.x, 0, vacatedColumnRect.width - 1, tableHeight); // Move to the where the cell has been dragged. vacatedColumnRect.x += dist; - boolean scrollVisible = scrollBarVisible(); - boolean drawBottomBorder = !table.getShowHorizontalLines() && !scrollVisible && table.getShowVerticalLines(); boolean ltr = table.getComponentOrientation().isLeftToRight(); // Fill the background. g.setColor(table.getBackground()); - g.fillRect(vacatedColumnRect.x, vacatedColumnRect.y, - vacatedColumnRect.width, vacatedColumnRect.height); + g.fillRect(vacatedColumnRect.x, 0, vacatedColumnRect.width, tableHeight); // Paint the vertical grid lines if necessary. if (table.getShowVerticalLines()) { g.setColor(table.getGridColor()); int x1 = vacatedColumnRect.x; - int y1 = vacatedColumnRect.y; + int y1 = 0; int x2 = x1 + vacatedColumnRect.width - 1; - int y2 = y1 + vacatedColumnRect.height - 1; + int y2 = y1 + tableHeight; boolean onLeftEdge = ltr ? draggedColumnIndex == cMin : draggedColumnIndex == cMax; boolean onRightEdge = ltr ? draggedColumnIndex == cMax : draggedColumnIndex == cMin; @@ -423,13 +418,13 @@ public class DarkTableUI extends DarkTableUIBridge { paintCell(g, r, row, draggedColumnIndex); // Paint the (lower) horizontal grid line if necessary. - if (table.getShowHorizontalLines() || (!scrollVisible && row == rMax)) { + if (table.getShowHorizontalLines()) { g.setColor(table.getGridColor()); Rectangle rcr = table.getCellRect(row, draggedColumnIndex, true); - rcr.x += dist; - int x1 = rcr.x - 1; + rcr.x += distance; + int x1 = rcr.x; int y1 = rcr.y; - int x2 = x1 + rcr.width + 1; + int x2 = x1 + rcr.width; int y2 = y1 + rcr.height - 1; g.fillRect(x1, y2, x2 - x1, 1); } @@ -482,6 +477,14 @@ public class DarkTableUI extends DarkTableUIBridge { } } + @Override + public void mousePressed(final MouseEvent e) { + super.mousePressed(e); + if (SwingUtilities.isLeftMouseButton(e)) { + table.repaint(); + } + } + protected JFileChooser getFileChooser() { var obj = table.getClientProperty("JTable.fileChooserParent"); if (obj instanceof Supplier) { diff --git a/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java b/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java index 1d423101..1a92d2d2 100644 --- a/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java +++ b/src/main/java/com/github/weisj/darklaf/ui/table/TableUIBridge.java @@ -1879,9 +1879,8 @@ public abstract class TableUIBridge extends TableUI { if (binding != null) { ActionMap am = component.getActionMap(); Action action = (am != null) ? am.get(binding) : null; - if (action != null && SwingUtilities. - notifyAction(action, keyStroke, e, component, - e.getModifiers())) { + if (action != null && SwingUtilities.notifyAction(action, keyStroke, e, component, + e.getModifiers())) { e.consume(); } } @@ -2057,11 +2056,8 @@ public abstract class TableUIBridge extends TableUI { Component editorComponent = table.getEditorComponent(); Point p = e.getPoint(); Point p2 = SwingUtilities.convertPoint(table, p, editorComponent); - dispatchComponent = - SwingUtilities.getDeepestComponentAt(editorComponent, - p2.x, p2.y); - SwingUtilities2.setSkipClickCount(dispatchComponent, - e.getClickCount() - 1); + dispatchComponent = SwingUtilities.getDeepestComponentAt(editorComponent, p2.x, p2.y); + SwingUtilities2.setSkipClickCount(dispatchComponent, e.getClickCount() - 1); } public void mouseEntered(final MouseEvent e) { @@ -2107,11 +2103,8 @@ public abstract class TableUIBridge extends TableUI { } else if (!e.isShiftDown() && table.isCellSelected(pressedRow, pressedCol)) { // clicking on something that's already selected // and need to make it the lead now - table.getSelectionModel().addSelectionInterval(pressedRow, - pressedRow); - table.getColumnModel().getSelectionModel(). - addSelectionInterval(pressedCol, pressedCol); - + table.getSelectionModel().addSelectionInterval(pressedRow, pressedRow); + table.getColumnModel().getSelectionModel().addSelectionInterval(pressedCol, pressedCol); return; } @@ -2145,7 +2138,6 @@ public abstract class TableUIBridge extends TableUI { if (editorComponent != null && !editorComponent.hasFocus()) { SwingUtilities2.compositeRequestFocus(editorComponent); } - return; } public void dragStarting(final MouseEvent me) { @@ -2166,9 +2158,7 @@ public abstract class TableUIBridge extends TableUI { return; } - if (table.getDragEnabled() && - (DragRecognitionSupport.mouseDragged(e, this) || dragStarted)) { - + if (table.getDragEnabled() && (DragRecognitionSupport.mouseDragged(e, this) || dragStarted)) { return; } @@ -2190,8 +2180,7 @@ public abstract class TableUIBridge extends TableUI { return; } - table.changeSelection(row, column, - DarkUIUtil.isMenuShortcutKeyDown(e), true); + table.changeSelection(row, column, DarkUIUtil.isMenuShortcutKeyDown(e), true); } public void mouseMoved(final MouseEvent e) { diff --git a/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java b/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java index 69d44a59..8077cbf0 100644 --- a/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java +++ b/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java @@ -132,7 +132,7 @@ public class DarkTooltipUI extends BasicToolTipUI implements PropertyChangeListe @Override protected void installDefaults(final JComponent c) { super.installDefaults(c); - LookAndFeel.installProperty(c, "opaque", false); + c.setOpaque(false); if (c.getBorder() instanceof DarkTooltipBorder) { Alignment align = (Alignment) c.getClientProperty("JToolTip.pointerLocation"); ((DarkTooltipBorder) c.getBorder()).setPointerLocation(align == null ? Alignment.CENTER : align); diff --git a/src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.dll b/src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.dll index 70622dc0..51d54653 100644 Binary files a/src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.dll and b/src/main/resources/com/github/weisj/darklaf/platform/windows/x64/jniplatform.dll differ diff --git a/src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.dll b/src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.dll index c9cd73b3..3ea40384 100644 Binary files a/src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.dll and b/src/main/resources/com/github/weisj/darklaf/platform/windows/x86/jniplatform.dll differ diff --git a/src/test/java/UIManagerDefaults.java b/src/test/java/UIManagerDefaults.java index 61430624..54bf95d1 100644 --- a/src/test/java/UIManagerDefaults.java +++ b/src/test/java/UIManagerDefaults.java @@ -5,6 +5,7 @@ import com.github.weisj.darklaf.DarkLafInfo; import com.github.weisj.darklaf.LafManager; +import com.github.weisj.darklaf.components.OverlayScrollPane; import com.github.weisj.darklaf.ui.cell.DarkCellRendererToggleButton; import com.github.weisj.darklaf.ui.table.DarkColorTableCellRendererEditor; import org.jdesktop.swingx.JXTaskPane; @@ -203,7 +204,7 @@ public class UIManagerDefaults implements ItemListener { final DefaultTableModel model = new DefaultTableModel(COLUMN_NAMES, 0); table = new JTable(model); table.setAutoCreateColumnsFromModel(false); - table.setShowHorizontalLines(false); +// table.setShowHorizontalLines(false); table.getColumnModel().getColumn(0).setPreferredWidth(250); table.getColumnModel().getColumn(1).setPreferredWidth(500); @@ -215,7 +216,7 @@ public class UIManagerDefaults implements ItemListener { d.height = 350; table.setPreferredScrollableViewportSize(d); - return new JScrollPane(table); + return new OverlayScrollPane(table); } /*