Skip to content

Commit

Permalink
Improved border design
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenni0451 committed Mar 28, 2024
1 parent 758ac59 commit 75559bc
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,33 @@
package net.raphimc.noteblocktool.elements;

import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;

public class FastScrollPane extends JScrollPane {

private final Border defaultBorder = this.getBorder();

public FastScrollPane() {
}

public FastScrollPane(final Component view) {
super(view);
}

{
this.setBorder(BorderFactory.createEmptyBorder());
}

public FastScrollPane setDefaultBorder() {
this.setBorder(this.defaultBorder);
return this;
}

public Border getDefaultBorder() {
return this.defaultBorder;
}

@Override
public JScrollBar createVerticalScrollBar() {
JScrollBar scrollBar = super.createVerticalScrollBar();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.raphimc.noteblocklib.format.nbs.model.NbsHeader;
import net.raphimc.noteblocklib.model.Song;
import net.raphimc.noteblocklib.model.SongView;
import net.raphimc.noteblocktool.elements.FastScrollPane;
import net.raphimc.noteblocktool.elements.NoteBlockFileFilter;
import net.raphimc.noteblocktool.elements.TextOverlayPanel;
import net.raphimc.noteblocktool.elements.drag.DragTable;
Expand Down Expand Up @@ -77,7 +78,7 @@ private void initComponents() {
root.setLayout(new BorderLayout());
this.setContentPane(root);

root.add(new JScrollPane(this.table), BorderLayout.CENTER);
root.add(new FastScrollPane(this.table), BorderLayout.CENTER);
this.dropTarget = new DropTarget(this, new DragTableDropTargetListener(this, this::load));
this.table.getSelectionModel().addListSelectionListener(e -> this.refreshButtons());
this.table.addKeyListener(new KeyAdapter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.raphimc.noteblocklib.model.SongView;
import net.raphimc.noteblocklib.util.Instrument;
import net.raphimc.noteblocklib.util.SongUtil;
import net.raphimc.noteblocktool.elements.FastScrollPane;
import net.raphimc.noteblocktool.elements.instruments.InstrumentsTable;
import net.raphimc.noteblocktool.frames.ListFrame;

Expand All @@ -43,7 +44,7 @@ protected void initComponents(JPanel center) {
this.removeAll();

this.table = new InstrumentsTable(true);
this.add(new JScrollPane(this.table));
this.add(new FastScrollPane(this.table));
this.usedInstruments = SongUtil.getUsedCustomInstruments(this.songs.get(0).getSong().getView());
NbsData data = (NbsData) this.songs.get(0).getSong().getData();
for (Integer instrument : this.usedInstruments) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public EditTab(final String title, final List<ListFrame.LoadedSong> songs) {
this.songs = songs;

this.setLayout(new BorderLayout());
JScrollPane scrollPane = new FastScrollPane();
JScrollPane scrollPane = new FastScrollPane().setDefaultBorder();
this.center = new ScrollPaneSizedPanel(scrollPane);
this.center.setLayout(new VerticalLayout(5, 5));
scrollPane.setViewportView(this.center);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.raphimc.noteblocklib.model.SongView;
import net.raphimc.noteblocklib.util.Instrument;
import net.raphimc.noteblocklib.util.SongUtil;
import net.raphimc.noteblocktool.elements.FastScrollPane;
import net.raphimc.noteblocktool.elements.instruments.InstrumentsTable;
import net.raphimc.noteblocktool.frames.ListFrame;

Expand All @@ -41,7 +42,7 @@ protected void initComponents(JPanel center) {
this.removeAll();

this.table = new InstrumentsTable(false);
this.add(new JScrollPane(this.table));
this.add(new FastScrollPane(this.table));
this.usedInstruments = this.songs.stream()
.map(song -> SongUtil.getUsedVanillaInstruments(song.getSong().getView()))
.reduce(EnumSet.noneOf(Instrument.class), (a, b) -> {
Expand Down

0 comments on commit 75559bc

Please sign in to comment.