Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion Ports/JavaSE/src/com/codename1/impl/javase/NetworkMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.codename1.io.ConnectionRequest;
import com.codename1.io.IOAccessor;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.net.URLConnection;
Expand All @@ -40,7 +42,7 @@
*
* @author Shai Almog
*/
public class NetworkMonitor extends javax.swing.JPanel {
public class NetworkMonitor extends javax.swing.JPanel implements Scrollable {

private Map<URLConnection, NetworkRequestObject> requests = new HashMap<URLConnection, NetworkRequestObject>();
private Map<ConnectionRequest, NetworkRequestObject> queuedRequests = new HashMap<ConnectionRequest, NetworkRequestObject>();
Expand Down Expand Up @@ -89,13 +91,52 @@ public void windowClosing(WindowEvent e) {
});

frame.pack();
Dimension packed = frame.getSize();
Rectangle screen = frame.getGraphicsConfiguration().getBounds();
int defaultW = Math.min(Math.max(packed.width, 1100), screen.width - 80);
int defaultH = Math.min(Math.max(packed.height, 700), screen.height - 80);
frame.setSize(defaultW, defaultH);
if (jSplitPane1 != null) {
jSplitPane1.setResizeWeight(0.25);
jSplitPane1.setDividerLocation(Math.max(220, defaultW / 4));
}
frame.setLocationByPlatform(true);
frame.setVisible(true);

}
return frame;
}

/// Scrollable implementation: when wrapped in a JScrollPane (single-window
/// mode via AppPanel.setScrollable), the monitor stretches to fill the
/// viewport width so the request list and detail tabs claim the full
/// available width as the simulator window resizes.

@Override
public Dimension getPreferredScrollableViewportSize() {
return getPreferredSize();
}

@Override
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
return 16;
}

@Override
public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
return orientation == SwingConstants.VERTICAL ? visibleRect.height : visibleRect.width;
}

@Override
public boolean getScrollableTracksViewportWidth() {
return true;
}

@Override
public boolean getScrollableTracksViewportHeight() {
return false;
}

public void dispose() {
if (frame != null) {
frame.dispose();
Expand Down
Loading