Questions tagged [jviewport]

JViewport known as viewport is an java swing component that draw the visible region of a scrollable area. When the user scroll, what move is the viewport.

JViewport known as viewport is an java swing component that draw the visible region of a scrollable area. When the user scroll, what move is the viewport.

46 questions
15
votes
1 answer

Passing current Date

Seems like as not possible to fix Graphics2D lack in code, there I must to set fix size for animations, otherwise some Start outside Rectangle 490 x 490 freeze or shaking on the screen my SSCCE import java.awt.*; import…
mKorbel
  • 108,320
  • 17
  • 126
  • 296
14
votes
2 answers

JTable in JScrollPane, how to set background?

I am using a JScrollPane to wrap a JTable. Depending on the configuration, there is some space that is not occupied by the table. It is drawn gray (it looks like it is transparent and you can just see the component in the back). How can I set this…
brimborium
  • 8,880
  • 9
  • 46
  • 73
14
votes
1 answer

Enabling auto resize of JTable only if it fit viewport

I need to create a JTable inside JScrollPane with resizeable columns (when user increase column width - horizontal scrollbar appears). For this I have use table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);. Also, when viewport is wide enough to…
user2137020
  • 556
  • 7
  • 20
8
votes
2 answers

JTable how to change BackGround Color

I inspired by MeBigFatGuy interesting question, in this conection I have very specific question about Graphisc2D, how to change BackGround Color by depends if is JTables Row visible in the JViewPort, 1) if 1st. & last JTables Row will be visible in…
mKorbel
  • 108,320
  • 17
  • 126
  • 296
6
votes
3 answers

How to pan an image using your mouse in Java Swing

I am creating a Java app that will allow users to view images and to pan the image using their mouse. To implement the panning of the image I use a combination of mouseClicked and mouseDragged events using JViewports. The bulk of the code is in the…
Codey McCodeface
  • 2,788
  • 5
  • 26
  • 52
5
votes
1 answer

When is getPreferredScrollableViewportSize() called when laying out JScrollPane?

Implementing the Scrollable interface requires implementing the getPreferredScrollableViewportSize() method. This is typically done by just forwarding the call to getPreferredSize() - except when other parameters of the Scrollable may affect the…
ags
  • 693
  • 5
  • 22
4
votes
5 answers

I want a picture to stay in top left corner of a jscrollpane while scrolling

I have a JPanel in a JScrollpane. I draw on a BufferedImage, which I display on the JPanel. In the top left corner of the JScrollpane, I want a picture, that always stays in that corner when I scroll down to see the rest of my JPanel. Here the…
3
votes
1 answer

Get JPanel in a JScrollPane

I have a JScrollPane and I put a JPanel in the JScrollPane. The JPanel holds a variable amount of JLabels. Here is how I "new" it: JPanel dataPanel = new JPanel(); //then do a for loop to put a few JLabels in dataPanel JScrollPane scrollPane = new…
user1888955
  • 524
  • 1
  • 6
  • 20
3
votes
2 answers

Scrolling limitation with JScrollPane and JViewport maximum sizes smaller than contents

I have a JFrame containing a JScrollPane containing a JPanel. The JPanel contains a bunch of JTextAreas. I'm loading a lot of text into them (about 8k-10k characters). The layout works fine, though the scrolling is a bit laggy. The real issue is…
nwod
  • 309
  • 2
  • 12
3
votes
1 answer

JScrollPane automatically sets ViewPort position to (0,0)

I have a JScrollPane whose viewport is a subclass of JPanel. This panel is laid out with a BoxLayout and upon user interaction the horizontal width of the components can change. When there are sufficient components such that the scroll bars are…
user450775
  • 437
  • 1
  • 5
  • 13
3
votes
1 answer

JScrollPane Zoom view with components inside

Are there any methods which i want to zoom the view of the viewport but the location of the components inside does not change. The setting is that i have a big jpanel inside a jscrollpane in which i only want to only change the view into zoomed…
3
votes
3 answers

How to put a component on top of others?

I have a JScrollPanel that includes a big panel which it's self includes 3 inner panels. i want to put a panel (for example) in a special place so that always could be seen, I mean the user can scroll to anywhere wants but that panel always is in…
Soheil
  • 1,610
  • 6
  • 31
  • 63
2
votes
2 answers

Temporarily disable or prevent repainting JViewPort on scrolling with a mouseDrag

I have written a MouseListener as defined below so that I can move a JButton around to reorder the components that are within the JPanel. The JPanel is within a JScrollPane so that when multiple components are added they can be scrolled. The problem…
Java Devil
  • 9,835
  • 7
  • 30
  • 44
2
votes
1 answer

Moving a view port over a larger image; JLablel+JScrollPane

I have a JScrollPane m_jScrollPane with a JLabel m_jlImage being displayed inside of it. The m_jlImage is a screen capture with a red dot drawn where the user last clicked on the screen. I wish to move (read scroll) the viewing area of the…
user1311286
2
votes
3 answers

Can't change background color of java application

I'm trying my hand at making a picture viewer in Java and for the life of me, I can't get the background color of the viewer to change to black. Here's my latest code: public class PictureViewer extends JFrame { static class PauseAction extends…
Michael Robinson
  • 1,080
  • 3
  • 13
  • 36
1
2 3 4