Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

memati bas

Ranch Hand
+ Follow
since Jan 29, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by memati bas

I think that this code snippet helps you.
14 years ago
Make your panel, which is added into your ScrollPane, have bigger size than ScrollPane's size, so that you scrollBars can appear.
14 years ago
I think it does not matter whether you draw your picture on Frame or Panel but you should be careful that while drawing on Frame use paint(Graphics g) method and while drawing on Panel use paintComponent(Graphics g)method.
14 years ago
Sorry, I mean that the only familiar one is JPanel

The others;

AbstractButton, BasicInternalFrameTitlePane, Box, Box.Filler, JColorChooser, JComboBox, JFileChooser, JInternalFrame, JInternalFrame.JDesktopIcon, JLabel, JLayeredPane, JList, JMenuBar, JOptionPane, JPanel, JPopupMenu, JProgressBar, JRootPane, JScrollBar, JScrollPane, JSeparator, JSlider, JSpinner, JSplitPane, JTabbedPane, JTable, JTableHeader, JTextComponent, JToolBar, JToolTip, JTree, JViewport
14 years ago
Sorry I said that JDialog has paintComponent(Graphics g) method but it does not have.
Only, JPanel has paintComponent(Graphics g) method
14 years ago

Originally posted by Ernest Friedman-Hill:


Close, although really not the best solution. You shouldn't override paint(), but rather paintComponent(); and when you do, you should call super.paintComponent() first. Overriding paint() in a Swing component just makes a mess of things.



I think he is correct by suggesting paint method for drawing.
Because, I know that paintComponent(Graphics g) should be used for Java Swing components, not containers. If you draw something on JPanel or JDialog, use paintComponent(Graphics g), otherwise use paint(Graphics g).
14 years ago
Oh, sorry for forgetting the tell the class that the above method belongs to.
It is kept in Graphics class.
14 years ago
Try to use the following method to cear all the Frame screen:
clearRect(int x, int y, int width, int height)
14 years ago
Write setVisible(true) after adding all the components(or containers) into your Top Level Container(JFrame).

Regards
14 years ago
If your file is directory, so can you guess what happened ??
14 years ago
Oh, thanks very much for this extremely explanatory reply.
Now, I think that I kept the idea.

Again thanks very much for this.

Regards
14 years ago
Yes, it increases the efficiency by having readLine method...
14 years ago
Sorry but it is a little bit messy for me.
Would you mind being more clear ?
14 years ago