Problem in scrolling a JTextArea
hi,
I am using a JTextArea to display files. I could scroll smoothly without interruptions when I tested with a 1 kb file. But when I loaded a 300 kb file, the scrolling beacame halted and slow. It was not continuous. Can this be fixed?
Also I am thinking of displaying files of larger sizes( 1Mb- 5 Mb). In such cases, I thought it would be better to display only parts of the document as i scroll. Could someone please help me with this?
Thanks,
ramya
Hello,
I hope you would be able to recall my problem - smooth scrolling of loads of text.(Please see my problem -right at the top, as the first post)
I worked out a way to display only the required text as i scroll. I could not go in for a scrollpane because I would need to deal with MBs of textual data. :(
Now, I am trying to perform a word search on the text displayed. I do not know how to do this.
Please help with your suggestions and pointers.
I have posted the code below.
import javax.swing.*;
import java.awt.*;
import javax.swing.text.*;
import java.awt.event.*;
import javax.swing.border.*;
import javax.swing.text.*;
public class paint_frame extends JFrame implements AdjustmentListener
JTextArea text; PlainDocument doc = new PlainDocument();Font f;FontMetrics fm; int ivisible,ivalue;JScrollBar hscroll;
JViewport view; int width; columnpanel cp; JScrollBar vscroll;
paintpanel pp; int ivisible_v; int ivalue_v; VPanel vp; JPanel mp;
JPanel mmp=new JPanel(new BorderLayout());
public static void main(String[] args)
paint_frame pf = new paint_frame();
pf.setSize(new Dimension(900,900));
pf.pack();
pf.setVisible(true);
pf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
public paint_frame()
try
doc.insertString(doc.getLength(),"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"67890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"89012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"02345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"67890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"89012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789*",null);
doc.insertString(doc.getLength(),"\n",null);
doc.insertString(doc.getLength(),"00345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789*",null);
}catch(Exception e){}
hscroll = new JScrollBar(JScrollBar.HORIZONTAL,0,0,0,0); // set the max value to be the length of the longest seq. in the alignment.
vscroll = new JScrollBar(JScrollBar.VERTICAL,0,0,0,0);
pp = new paintpanel();
view = new JViewport();
view.setPreferredSize(new Dimension(600,600));
view.setMaximumSize(new Dimension(600,600));
vp = new VPanel();
text = new JTextArea(); view.setView(text);
f = new Font("Monospaced",Font.PLAIN,20);
text.setFont(f);fm = text.getFontMetrics(f); //text.setEditable(false);
mp = new JPanel(new BorderLayout());
cp = new columnpanel();
hscroll.addAdjustmentListener(this);
vscroll.addAdjustmentListener(this);
pp.add(view,BorderLayout.CENTER);
pp.add(hscroll,BorderLayout.SOUTH);
pp.add(cp, BorderLayout.NORTH);
view.setView(text);
JMenuBar bar = new JMenuBar();
JMenu format = new JMenu("format");
JMenuItem font = new JMenuItem("font");
JMenu search = new JMenu("search");
JMenuItem find = new JMenuItem("find");
font.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
f = new Font("Monospaced",Font.PLAIN,18);
text.setFont(f);
fm=text.getFontMetrics(f);
//paintframe3.this.revalidate();
paint_frame.this.repaint(); // causes the panel to be repainted
format.add(font);
bar.add(format);
mp.add(pp,BorderLayout.CENTER);
mp.add(vp,BorderLayout.EAST);
mmp.add(mp,BorderLayout.CENTER);
//mmp.add(headerview,BorderLayout.WEST);
getContentPane().add(mmp,BorderLayout.CENTER);
setJMenuBar(bar);
System.out.println("\n jpanel added");
public void adjustmentValueChanged(AdjustmentEvent ae)
try
paint_frame.this.repaint();
}catch(Exception e){}
class columnpanel extends JPanel
int alignment_width;
int window_width;
int hvalue;int j;String s=""; int v1,v;
columnpanel()
setOpaque(true);
setPreferredSize(new Dimension(view.getSize().width,50));
public void doLayout()
public void paintComponent(Graphics g)
window_width = width;
g.setColor(Color.white);
System.out.println(" COLUMN PANEL COLUMN PANEL/*//*" + getSize());System.out.println(" preferred column panel" + getPreferredSize());
g.fillRect(0,0,getSize().width,getSize().height);
g.setColor(Color.black);
g.setFont(f);
j = fm.charWidth('M');
v = hscroll.getValue()/fm.charWidth('M');
for(int i=1;i<=15;i=i+1)
if(v==0)
s=new Integer((i)*10).toString();
//g.drawString("|", i*j*10-(j+j*v),0+10);
g.drawString(s, i*j*10-(j+j*v),40);
else
if(v!=0)
s=new Integer((i)*10).toString();
//g.drawString("|", i*j*10-(j+j*v)+view.getSize().width%j,0+10);
g.drawString(s, i*j*10-(j+j*v)+view.getSize().width%j,40);
}// end of column panel class
class paintpanel extends JPanel
paintpanel()
setSize(new Dimension(800,800));
setLayout(new BorderLayout());
public void paintComponent(Graphics g)
try
int testwidth = view.getSize().width/fm.charWidth('M');
int testheight = view.getSize().height/fm.getHeight();
hscroll.setMaximum(150*fm.charWidth('M'));
vscroll.setMaximum(30*fm.getHeight());
hscroll.setVisibleAmount(testwidth*fm.charWidth('M'));
vscroll.setVisibleAmount(testheight*fm.getHeight());
hscroll.setUnitIncrement(fm.charWidth('M'));
vscroll.setUnitIncrement(fm.getHeight());
hscroll.setBlockIncrement(testwidth*fm.charWidth('M'));
//hvisibleamount = hscroll.getVisibleAmount();
text.setText("");
text.setText(doc.getText(0,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText((151),testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(302,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(453,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(604,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(755,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(906,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(1057,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(1208,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(1359,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(1510,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(1661,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(1812,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(1963,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(2114,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(2265,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(2416,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(2567,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(2718,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
text.append("\n");
text.append(doc.getText(2869,testwidth+(hscroll.getValue()/fm.charWidth('M'))));
/*text.append("\n");
text.append(doc.getText(3020,ivalue+ivisible+hscroll.getValue()));
text.append("\n");
text.append(doc.getText(3171,ivalue+ivisible+hscroll.getValue()));
text.append("\n");
text.append(doc.getText(3322,ivalue+ivisible+hscroll.getValue()));
text.append("\n");
text.append(doc.getText(3473,ivalue+ivisible+hscroll.getValue()));
text.append("\n");
text.append(doc.getText(3624,ivalue+ivisible+hscroll.getValue()));
text.append("\n");
text.append(doc.getText(3775,ivalue+ivisible+hscroll.getValue()));
text.append("\n");
text.append(doc.getText(3926,ivalue+ivisible+hscroll.getValue()));
text.append("\n");
text.append(doc.getText(4077,ivalue+ivisible+hscroll.getValue()));
text.append("\n");
text.append(doc.getText(4228,ivalue+ivisible+hscroll.getValue()));
text.append("\n");
text.append(doc.getText(1379,ivalue+ivisible+hscroll.getValue()));*/
}catch(Exception e){}
}// end of paint panel class
class VPanel extends JPanel
VPanel()
//setLayout(null);
setSize(new Dimension(17,pp.getSize().height));
setBackground(Color.white);
add(vscroll);
public void doLayout()
vscroll.setBounds(0,view.getBounds().y,getSize().width,view.getSize().height);
//vscroll.setPreferredSize(new Dimension(getSize().width,view.getSize().height));
public void paintComponent(Graphics g)
super.paintComponent(g);
System.out.println("\n vertical panel size" + getSize());
} // end of VPanel class
}// end of piant_frame classThank you very much for the time,
ramya
Similar Messages
-
Scrolling in JtextArea ????
Can anybody tell me how to introduce scrolling in JtextArea ???
Following is the skeleton of my code ...
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class Interface extends Frame
String path;
JTextField text = new JTextField();
JButton button = new JButton("Browse");
JButton executeButton = new JButton("Execute");
JTextArea area = new JTextArea();
JPanel P1 = new JPanel();
public Component createComponents()
text.setBounds(30,30,300,20);
button.setBounds(30,70,80,20);
executeButton.setBounds(130,70,80,20);
area.setBounds(30,110,540,430);
P1.setBackground(Color.red);
P1.setLayout(null);
P1.add(button);
P1.add(executeButton);
P1.add(text);
P1.add(area);
return P1;
public static void main(String[] args)
JFrame frame = new JFrame("Pseudocode Interpreter");
Interface app = new Interface();
Component contents = app.createComponents();
frame.getContentPane().add(contents);
frame.setSize(600,600);
frame.setVisible(true);
frame.setLocation(50,50);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}Thanks !!!!I am happy to help use but addind scroll pane is a simple one.
y not u post it in swing ya?.
you can add scrollpane by
JScrollPane jsp=new JScrollPane(new JTextArea(20,20));
yourpanel.add(jsp);
if u still have problem post. u r welcome.
i did not run the below changed code u may try it.it is so simple.....
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class Interface extends Frame
String path;
JTextField text = new JTextField();
JButton button = new JButton("Browse");
JButton executeButton = new JButton("Execute");
JTextArea area = new JTextArea();
JScrollPane jsp=new JScrollPane(area);
JPanel P1 = new JPanel();
public Component createComponents()
text.setBounds(30,30,300,20);
button.setBounds(30,70,80,20);
executeButton.setBounds(130,70,80,20);
jsp.setBounds(30,110,540,430);
P1.setBackground(Color.red);
P1.setLayout(null);
P1.add(button);
P1.add(executeButton);
P1.add(text);
P1.add(jsp);
return P1;
public static void main(String[] args)
JFrame frame = new JFrame("Pseudocode Interpreter");
Interface app = new Interface();
Component contents = app.createComponents();
frame.getContentPane().add(contents);
frame.setSize(600,600);
frame.setVisible(true);
frame.setLocation(50,50);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} -
Problems with scrolling and Mission Control
I have this problem:
When scrolling down any page, the letters will blur at the top of the screen and not the bottom.
When swiping acrross pages in the launchpad, it occasionaly freezes half way between the two.
When I swipe up with four fingers to access mission control, the screen becomes very sluggish. Swiping back down (or clicking a tab) is even worse, causing slow "laggy" animations.
And this the report from EtreCheck:
Hardware Information:
MacBook Pro (13-inch, Mid 2012)
MacBook Pro - model: MacBookPro9,2
1 2.5 GHz Intel Core i5 CPU: 2 cores
4 GB RAM
Video Information:
Intel HD Graphics 4000 - VRAM: 1024 MB
System Software:
OS X 10.9.2 (13C1021) - Uptime: 0 days 0:3:16
Disk Information:
APPLE HDD HTS545050A7E362 disk0 : (500.11 GB)
EFI (disk0s1) <not mounted>: 209.7 MB
Macintosh HD (disk0s2) / [Startup]: 499.25 GB (309.44 GB free)
HL-DT-ST DVDRW GS41N
USB Information:
Apple Inc. Apple Internal Keyboard / Trackpad
Apple Computer, Inc. IR Receiver
Apple Inc. BRCM20702 Hub
Apple Inc. Bluetooth USB Host Controller
Apple Inc. FaceTime HD Camera (Built-in)
FireWire Information:
Thunderbolt Information:
Apple Inc. thunderbolt_bus
Configuration files:
/etc/hosts - Count: 1
Launch Daemons:
[loaded] com.adobe.fpsaud.plist Support
[loaded] com.microsoft.office.licensing.helper.plist Support
Launch Agents:
[not loaded] com.bose.soundtouch.plist Support
User Launch Agents:
[loaded] com.adobe.ARM.[...].plist Support
[loaded] com.google.keystone.agent.plist Support
[running] com.spotify.webhelper.plist Support
User Login Items:
iTunesHelper
Spotify
BitTorrent
Autodesk 360
Internet Plug-ins:
SharePointBrowserPlugin: Version: 14.0.0 Support
FlashPlayer-10.6: Version: 13.0.0.201 - SDK 10.6 Support
AdobePDFViewer: Version: 10.0.0 Support
Flash Player: Version: 13.0.0.201 - SDK 10.6 Support
QuickTime Plugin: Version: 7.7.3
Default Browser: Version: 537 - SDK 10.9
Audio Plug-ins:
BluetoothAudioPlugIn: Version: 1.0 - SDK 10.9
AirPlay: Version: 2.0 - SDK 10.9
AppleAVBAudio: Version: 203.2 - SDK 10.9
iSightAudio: Version: 7.7.3 - SDK 10.9
iTunes Plug-ins:
Quartz Composer Visualizer: Version: 1.4 - SDK 10.9
3rd Party Preference Panes:
Flash Player Support
Time Machine:
Time Machine not configured!
Top Processes by CPU:
2% WindowServer
2% SoundTouch music server
0% fontd
0% BitTorrent
0% mds
Top Processes by Memory:
90 MB mds_stores
86 MB Safari
78 MB Spotify
57 MB Spotify Helper
49 MB ocspd
Virtual Memory Information:
1.83 GB Free RAM
1.44 GB Active RAM
190 MB Inactive RAM
558 MB Wired RAM
303 MB Page-ins
0 B Page-outsI have this problem:
When scrolling down any page, the letters will blur at the top of the screen and not the bottom.
When swiping acrross pages in the launchpad, it occasionaly freezes half way between the two.
When I swipe up with four fingers to access mission control, the screen becomes very sluggish. Swiping back down (or clicking a tab) is even worse, causing slow "laggy" animations.
And this the report from EtreCheck:
Hardware Information:
MacBook Pro (13-inch, Mid 2012)
MacBook Pro - model: MacBookPro9,2
1 2.5 GHz Intel Core i5 CPU: 2 cores
4 GB RAM
Video Information:
Intel HD Graphics 4000 - VRAM: 1024 MB
System Software:
OS X 10.9.2 (13C1021) - Uptime: 0 days 0:3:16
Disk Information:
APPLE HDD HTS545050A7E362 disk0 : (500.11 GB)
EFI (disk0s1) <not mounted>: 209.7 MB
Macintosh HD (disk0s2) / [Startup]: 499.25 GB (309.44 GB free)
HL-DT-ST DVDRW GS41N
USB Information:
Apple Inc. Apple Internal Keyboard / Trackpad
Apple Computer, Inc. IR Receiver
Apple Inc. BRCM20702 Hub
Apple Inc. Bluetooth USB Host Controller
Apple Inc. FaceTime HD Camera (Built-in)
FireWire Information:
Thunderbolt Information:
Apple Inc. thunderbolt_bus
Configuration files:
/etc/hosts - Count: 1
Launch Daemons:
[loaded] com.adobe.fpsaud.plist Support
[loaded] com.microsoft.office.licensing.helper.plist Support
Launch Agents:
[not loaded] com.bose.soundtouch.plist Support
User Launch Agents:
[loaded] com.adobe.ARM.[...].plist Support
[loaded] com.google.keystone.agent.plist Support
[running] com.spotify.webhelper.plist Support
User Login Items:
iTunesHelper
Spotify
BitTorrent
Autodesk 360
Internet Plug-ins:
SharePointBrowserPlugin: Version: 14.0.0 Support
FlashPlayer-10.6: Version: 13.0.0.201 - SDK 10.6 Support
AdobePDFViewer: Version: 10.0.0 Support
Flash Player: Version: 13.0.0.201 - SDK 10.6 Support
QuickTime Plugin: Version: 7.7.3
Default Browser: Version: 537 - SDK 10.9
Audio Plug-ins:
BluetoothAudioPlugIn: Version: 1.0 - SDK 10.9
AirPlay: Version: 2.0 - SDK 10.9
AppleAVBAudio: Version: 203.2 - SDK 10.9
iSightAudio: Version: 7.7.3 - SDK 10.9
iTunes Plug-ins:
Quartz Composer Visualizer: Version: 1.4 - SDK 10.9
3rd Party Preference Panes:
Flash Player Support
Time Machine:
Time Machine not configured!
Top Processes by CPU:
2% WindowServer
2% SoundTouch music server
0% fontd
0% BitTorrent
0% mds
Top Processes by Memory:
90 MB mds_stores
86 MB Safari
78 MB Spotify
57 MB Spotify Helper
49 MB ocspd
Virtual Memory Information:
1.83 GB Free RAM
1.44 GB Active RAM
190 MB Inactive RAM
558 MB Wired RAM
303 MB Page-ins
0 B Page-outs -
In the last few days, I've encountered a problem with scrolling with my up & down keys. The up & down keys seem to, now function as Home & End keys. MyPage Up & Page Down keys seem to do nothing. What is wrong?
Hit the '''F7''' key, you probably have Caret browsing turned on.
http://kb.mozillazine.org/Accessibility.browsewithcaret -
Basically whenever i place an html item in my Muse site or an object I encounter a problem when scrolling down past that object in the preview. I have a horizontal menu bar that sits on the top of my site and whenever I scroll down the html items and objects
cut through my menu. Is there any way to rectify this? - i've tried pinning objects but can't figure it out. Any help would be greatly appreciated.
Thanks,So you have a pinned Menu in the Master page but is being overlayed by the objects in page when you scroll down? If that is the case, select the Menu in the Master, right click on it and Move To Master Foreground.
Thanks,
Vinayak -
Parallax Scrolling: Problems with scroll wheel
Hi,I'm syue
I learn parallax effect from this video.
It helps me a lot ,but I have a problem with scroll wheel
Everything looks nice on my computer.
But when I make a test on different computers.It will show something like this...
https://docs.google.com/file/d/0B-eo1Bu6k3N-cEw2c3dyWEpfNDA/preview
I don't know how to explain the situation so I make this video.
I also chick my code and it shows me everything is fine.
I don't know how to solve this problem
Can you give me some advice?
Best regards. :-DI know many people who have 30 gig and no wheel problem. I have an 80 gig and no problem. Finding your warranty (or buying the extended warranty) would be useful.
Good luck.
Kid -
Problem with scroll tab layout in JtabbedPane
Pls. if anyone know this, help me
I have a problem, my scroll tab layout policy does not working when I set it to UI.
import javax.swing.*;
import javax.swing.plaf.basic.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
public class Components_Area extends JFrame{
JTabbedPane tab = new JTabbedPane(JTabbedPane.TOP,JTabbedPane.SCROLL_TAB_LAYOUT);
JLabel l[] = new JLabel[5];
public Components_Area() {
tab.setUI(new TestPlaf());
tab.addTab("Untitled",l[0]);
tab.addTab("Untitled",l[1]);
tab.addTab("Untitled",l[2]);
tab.addTab("Untitled",l[3]);
tab.addTab("Untitled",l[4]);
getContentPane().add(tab);
public static void main(String args []) {
Components_Area frame = new Components_Area();
frame.setSize(200,200);
frame.show();
static class TestPlaf extends BasicTabbedPaneUI {
protected LayoutManager createLayoutManager() {
return new TestPlafLayout();
protected Insets getTabInsets(int tabPlacement,int tabIndex) {
Insets defaultInsets = (Insets)super.getTabInsets(tabPlacement,tabIndex).clone();
defaultInsets.right += 50;
defaultInsets.top += 2;
return defaultInsets;
class TestPlafLayout extends TabbedPaneLayout {
//a list of our close buttons
java.util.ArrayList closeButtons = new java.util.ArrayList();
public void layoutContainer(Container parent) {
super.layoutContainer(parent);
//ensure that there are at least as many close buttons as tabs
while(tabPane.getTabCount() > closeButtons.size()) {
closeButtons.add(new CloseButton(closeButtons.size()));
tabPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
Rectangle rect = new Rectangle();
int i;
for(i = 0; i < tabPane.getTabCount();i++) {
rect = getTabBounds(i,rect);
JButton closeButton = (JButton)closeButtons.get(i);
//shift the close button 3 down from the top of the pane and 20 to the left
closeButton.setLocation(rect.x+rect.width-20,rect.y+4);
closeButton.setSize(15,15);
tabPane.add(closeButton);
for(;i < closeButtons.size();i++) {
//remove any extra close buttons
tabPane.remove((JButton)closeButtons.get(i));
// implement UIResource so that when we add this button to the
// tabbedpane, it doesn't try to make a tab for it!
class CloseButton extends JButton implements javax.swing.plaf.UIResource {
public CloseButton(int index) {
super(new CloseButtonAction(index));
setBorder( BorderFactory.createEmptyBorder() );
setToolTipText("Close this tab");
//remove the typical padding for the button
setMargin(new Insets(0,0,0,0));
addMouseListener(new MouseAdapter() {
public void mouseEntered(MouseEvent e) {
setBorder( BorderFactory.createLineBorder(Color.black, 1 ));
public void mouseExited(MouseEvent e) {
setBorder( BorderFactory.createEmptyBorder() );
class CloseButtonAction extends AbstractAction {
int index;
public CloseButtonAction(int index) {
super("x");
this.index = index;
public void actionPerformed(ActionEvent e) {
tabPane.remove(index);
} Message was edited by:
henyoIf someone knows this, help me!
-
Problem with scrolling a panel containing an image
I am having a problem adding scrolling capabilities to a tabbed panel containing pages containing an image. In my program, I have a class called ImagePanel that extends JPanel and contains an image read from a file. In another class, I create a tabbed panel and add to it ImagePanels.
The problem I'm facing is that the pages added to my tabbed panel contain scroll bars, but these scroll bars are not scrollable (i.e. I cannot use the bars the scroll and see the missing parts of the image).
Any help on this manner is highly appreciated.
The code is shown below:
JTabbedPane m_pathwayTabbedPane = new JTabbedPane();
ImageIcon overviewImageIcon = IconLoader.readImageIcon(pathway.gif);
ImagePanel overviewPanel = new ImagePanel(overviewImageIcon.getImage());
JScrollPane graphcrollPane = new JScrollPane(overviewPanel,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
m_pathwayTabbedPane.addTab(StringManager.OVERVIEW, graphcrollPane);import java.awt.*;
import java.io.*;
import java.net.*;
import javax.imageio.ImageIO;
import javax.swing.*;
public class ScrollingImages
public static void main(String[] args)
String[] fileNames = {
"images/bclynx.jpg", "images/mtngoat.jpg", "images/redfox.jpg"
JPanel panel = new JPanel(new GridBagLayout());
panel.setBackground(Color.black);
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(5,5,5,5);
gbc.gridwidth = gbc.REMAINDER;
for(int j = 0; j < fileNames.length; j++)
panel.add(new ImageComponent(fileNames[j]), gbc);
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new JScrollPane(panel));
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
class ImageComponent extends JPanel
Image image;
public ImageComponent(String fileName)
loadImage(fileName);
setBackground(Color.black);
protected void paintComponent(Graphics g)
super.paintComponent(g);
int w = getWidth();
int h = getHeight();
int imageWidth = image.getWidth(this);
int imageHeight = image.getHeight(this);
int x = (w - imageWidth)/2;
int y = (h - imageHeight)/2;
g.drawImage(image, x, y, this);
* For the JScrollPane which will inquire about our size
* which it needs to properly set its scrollbars.
public Dimension getPreferredSize()
return new Dimension(image.getWidth(this), image.getHeight(this));
private void loadImage(String fileName)
try
URL url = getClass().getResource(fileName);
image = ImageIO.read(url);
catch(MalformedURLException mue)
System.out.println(mue.getMessage());
catch(IOException ioe)
System.out.println(ioe.getMessage());
} -
Having a problem when scrolling through one clip: a different clip scrolls through point and time simultaneously. Can you please assist us?
First question: this is a Captivate forum, are you sure that you have a Captivate problem (with cpvc or an imported video)?
-
Good afternoon, I am facing a problem when scrolling a page when in the continuous view, sometimes the page jumps to the previous lines... How can I fix this?
I've only got one paint method and that is the main one in the base class. I've actually always disliked it. It basically contains all the location setting of all the components on the applet. I always thought these should be put in init, but whenever I do that, it fails to set their location.
Still, this is what my paint method looks like (well, a bit of it, its long)
public void paint(Graphics g)
//Empire Choice
empire.setLocation(215,21);
//End Empire Choice
//Implants Choice
implants.setLocation(10,layoutArray1[29]);
//End Implants Choice
//Mode Choice
mode.setLocation(177,51);
//End Mode Choice
//Templates Choice
templates.setLocation(235, 81);
//End Templates Choice
//Implants Chosen List
implantsChosen.setLocation(10,layoutArray1[32]);
implantsChosen.setSize(110,60);
//End Implants Chosen List
//Implants Description Label
implantsDesc.setLocation(10,layoutArray1[30]);
implantsDesc.setSize(275,15);
//End Implants Description Label
etc
etc
etcI really think its wrong, but i've not been able to work out how to make it 'propper' (I mean, it works and everything, but it seems wrong to me). Like I said, we haven't been taught much on applets at all, so i've had to teach myself all of this :-/
Thanks. -
Problems with scroll bars in list view
Hello,
I am using Xcelsius 2008 (Build Number 12,2,166). I am still having trouble with scroll bars on my list view control. Other list views in my dashboard seem to be ok. It seems that this list view is not ignoring the blank cells in my excel file. I have gone through many things to correct this problem. I have added a new list view, I have copied other list views that work correctly but still no success. It seems that the "Ignore Blank Cells" property is not working correctly. Does anyone have a solution for this?
Much Thx!Hi Yusufel,
Please check the data whether the cells are really blank or having any space which could not be seen, etc.
With best wishes
BaaRaa. -
Problem in SCROLLING of TABLE CONTROL which is designed using WIZARD
Hello Friends ,
I have designed a entry screen by using table control with wizard. My table control layout has 11 rows. I have used all 3 facilities i.e. SCROLLING , INSERT/DELETE & SELECT/DESELECT by cheking ( ticking ) check boxes while designing table control with wizard.
Now i have 3 problems.
1> In my entry screen , if 11 entries are entered , they are displayed in entry screen and are saved correctly in DB.
But when i copy a file of suppose 15 entries into entry screen then it displays only 11 entries in entry screen and after that if i click/move VERTICAL SCROLL BAR to see remaining/next 4 entries then it does not display 12th 13th 14th &15th entry in entry screen. So the problem is i am unable to display remaining/next 4 entries in entry screen & also to save them DB.
2> At the same time when i click/move VERTICAL SCROLL BAR to see remaining/next 4 entries then earlier 11 entries are disappeared/ get cleared from entry screen.
3> The FIRST PAGE, PREVIOUS PAGE , NEXT PAGE , LAST PAGE and INSERT , DELETE push buttons are dispalyed in my entry screen . But they are not working or doing their opertions on table control though there is system generated code for them written in module pool program and PBO & PAI OF SCREEN 100 on which table control is present.
So eagerly waiting for POSITIVE replies & Correct solutions from all ABAP techies.
THANKS & REGARDS,
Ashish.Hi friend,
I have visited the link u have given . But it is a report program .it is available in ABAPDOCU tcode.
ABAPDOCU----
>ABAP User Dialogs -
>Screens -
>Complex Screen Elements -
>Table Control with Scrolling .
It is a REPORT program. and not a module pool program. plz check this in ur link also.
REPORT demo_dynpro_tabcont_loop. &
*SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.* -
> this statement is used only in report program and system does not allow us to use in module pool program.
Second thing here data is retrived from spfli table where as my data will be whatever enduser enters it may be 15 lines , may be 50 lines or may be 200 lines and it shold be displayed on entry screen before clicking SAVE or any other user action.
My main problem is that I am unable to enter more than 11 entries in my entry screen. I want dynaamic table. Mean whichever enteries are entered they should be displayed on entry screen as well as can be scrolled up & down before saving and get saved after clicking SAVE button. here table control design is not imp because entry data depends on table control layout rows & which has limit. It can not be extended beyond certain level. i think max will be 20 Or 25 rows in layout. How to make it dynamic so that we can get any no. of entries in entry screen hiich canbe scrolled up & down.
Anyways thanks for ur reply And send some other soln.
Thanks & regards,
Ashish -
Problems with scrolling after mountain lion download.
I just downloaded mountain lion today and ever since the download I am having issues with the scrolling for my magic mouse and trackpad. My problem is when I scroll down on my mouse or trackpad it actually goes up on the page and vice versa. I have seen others have had some scrolling issues but not exactly the same as mine. Just wondering if there is any known fix for this problem? I did the PRAM reset and also the SMC reset and that didn't fix the problem unfortunately.
Look in System Preferences > Trackpad (or mouse) > Scroll & Zoom tab > uncheck Scroll direction: Natural.
The scrolling direction has been changed to a technique where your push the screen up or pull it down, takes a few days to get used to. The swipe directions will also be affected by this change. -
Problems with scrolling through premiere timeline using arrow keys and shift arrow
This is a really weird problem in cs6.
When I load a clip into the source monitor i can scroll throughit fine using the arrow keys, and shift arrows and my shuttle pro controller.
When I place the same clip on to the timeline it really struggles to scroll using the arrows or the shuttle pro, its really kerky and sdlwo to scroll the timeline, which is really frstrating, becuase it can play the footage fine in the source monitor.
The clips will playback fine, but scrolling through them just doesn't work as it should any ideas?
Cheers
MikeI changed my shuttle settings to make the shuttling more responsive:
1 - 5 times second
2 - 10
3 - 15
4 - 30
5 - 45
6 - 60
7 - fast as possible
At least I changed this a long time ago - don't know if these are the defaults or not.
It'll only shuttle as fast as your system is responsive of course - so if you get instantaneous scrubbing by dragging the CTI in the timeline with the mouse, you should be able to get good performance with the shuttle. Of course that performance depends on the type of footage and how demanding it is on CPU to decode and whether youi have effects applied etc etc etc.
I edit pretty much exclusively with Sony XDCAM EX 1080P 25 footage we've shot on EX3 and PMW-350 etc and I get very very fast performance on the timeline - no issues at all i7 6 core 4GHz with 24Gb ram and fairly fast RAID array for footage. -
Flash button problem when scrolling
Hello.
I posted this in Dreamweaver forum as well....just in case.
I am using flash buttons for email links in my web site
rather than html email links to help with spamming.
They work great except for one thing. In my site I have a
fixed Div on the left of my pages. The content scrolls sideways
underneath the fixed div. However....the flash buttons scroll over
the TOP of the fixed div while the rest of the content goes under
as it is supposed to. I have the fixed div set at z-index of 2.
This isn't an issue in Firefox, only IE7, so far.
Any one know of an easy fix for this rather than creating a
new div for each of the buttons?
Here is the link to the problem page - its the email link in
red towards the end of the page. Watch the link go OVER the drums
as you scroll. (it should go under)
http://dev.informarch.com/wm/article3/flashBtnScrollexample.html
Thanks in advance for any help.
KenHello,
Try this and see if it works
In your HTML go to where the <object> tag is that loads
your flash button.
Add this parameter within it.
<param name="wmode" value="transparent">
Then add the following inside the <embed> tag
wmode="transparent"
This is taken from an article from this site
http://www.bigismore.com/flash-related/flash-zorder-always-on-top/
Maybe you are looking for
-
Hard Drive still full after emptying trash
Hi! I own a Macbook running 10.4.8., 80 GB hard drive. I also just purchased and hooked up a LaCie external hard drive, FA Porsche, USB 2.0, 250 GB. I am working on making some home movies into DVDs, which is why I purchased the hard drive, so I coul
-
Can I put javascipt in a Java program?
Can I?
-
Does In-Browser Editing now allow adding/changing links to images and text?
There are images that link up to pages within the site and to external sites. When a client wants to change the image it needs to link to a new page. Is there a way they can now do that with in-browser editing?
-
Oracle AS adapter 10g R3 installation on clusters Application server
Hi, I want documentations or steps for installing oracle AS adpater 10R3 on oc4j application server(clustered). Existing components: Oracle AS server in clustered mode Oracle SOA Suite 10.1.3.5 Over this I want to install oracle AS adapter.I have few
-
'Show Movies in Cloud' setting not saving
Hi, As above, frequently when I log into iTunes, or even when I've been continuously logged in, the box which designates in-the-cloud purchases to be shown is un-ticked. It's not a major problem, but I still don't know why it's happening an