Skip to content

Commit

Permalink
Better Scrolling behaviour for Peer panels
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Aug 21, 2023
1 parent db8e3f3 commit 5262d30
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package convex.gui.components;

import java.awt.Rectangle;

import javax.swing.text.DefaultCaret;

@SuppressWarnings("serial")
public class NonUpdatingCaret extends DefaultCaret {
@Override
protected void adjustVisibility(Rectangle nloc) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.Timer;

import convex.api.Convex;
import convex.core.util.Text;
import convex.gui.components.ActionPanel;
import convex.gui.components.NonUpdatingCaret;
import convex.gui.utils.Toolkit;
import convex.peer.AThreadedComponent;
import convex.peer.Server;
Expand All @@ -32,15 +34,18 @@ public PeerInfoPanel(Convex p) {
JButton refreshButton = new JButton("Refresh");
panel.add(refreshButton);

JPanel panel_1 = new JPanel();
add(panel_1, BorderLayout.CENTER);
panel_1.setLayout(new BorderLayout(0, 0));

textArea = new JTextArea();
textArea.setEditable(false);
textArea.setBackground(null);
textArea.setCaret(new NonUpdatingCaret());
textArea.setColumns(100);
textArea.setFont(Toolkit.SMALL_MONO_FONT);

JPanel panel1=new JPanel();
panel1.add(textArea);
JScrollPane jsp1=new JScrollPane(panel1);
add(jsp1, BorderLayout.CENTER);

// Set up periodic refresh
int INTERVAL = 500;
Timer timer = new Timer(INTERVAL,new ActionListener() {
Expand All @@ -60,7 +65,6 @@ public void componentShown(ComponentEvent ce) {
}
});

panel_1.add(textArea);
refreshButton.addActionListener(e -> {
updateState(p);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.awt.BorderLayout;

import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;

import org.slf4j.Logger;
Expand Down Expand Up @@ -37,16 +39,18 @@ public PeerWindow(PeerGUI manager, Convex peer) {
Convex convex = Convex.connect(server.getHostAddress(), server.getPeerController(),server.getKeyPair());
tabbedPane.addTab("REPL", null, new REPLPanel(convex), null);
} catch (Throwable t) {
log.warn("Unable to create Peer Controller Window");
String msg=("Failed to connect to Peer: "+t);
log.warn(msg);
tabbedPane.addTab("REPL Error", null, new JLabel(msg), null);
return;
}
tabbedPane.addTab("Observation", null, new ObserverPanel(server), null);
tabbedPane.addTab("Observation", null, new JScrollPane(new ObserverPanel(server)), null);
}
tabbedPane.addTab("Stress", null, new StressPanel(peer), null);
tabbedPane.addTab("Info", null, new PeerInfoPanel(peer), null);

PeerComponent pcom = new PeerComponent(manager, peer);
add(pcom, BorderLayout.NORTH);

}

@Override
Expand Down

0 comments on commit 5262d30

Please sign in to comment.