473,386 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

SplitPanel and ImageIcon problem

Hello,
I'm starting with java and i'm having problems to display an image in a
splitpanel with a scrollbar.
I have different files but those required are described below. I think the
problem is coming from the file RightPanel.java here below does do not
display the image.
There is no problem of compilation , it works fine. Just that the image and
scrollbar are not displayed.
If anybody could help it would really be great.
thanks,.
david

FILE RightPanel

import javax.swing.*;

import java.awt.*;

public class RightPanel extends JPanel {

private JLabel picture;
RightPanel() {
ImageIcon pathImage = new ImageIcon("images/image.gif");

picture = new JLabel(pathImage);

JScrollPane imageDisplayPane = new JScrollPane(picture);
this.add(imageDisplayPane);

this.setSize(300,250);

this.setBackground(Color.white);

this.setVisible(true);

}

FILE SplitPanel.java :

import javax.swing.*;

import java.awt.*;

public class SplitPanel extends JPanel {

public SplitPanel() {

super();

final JList list;
LeftPanel leftp = new LeftPanel();

RightPanel rightp = new RightPanel();

JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);

pane.setLeftComponent(leftp);

pane.setRightComponent(rightp);

pane.setDividerLocation(200);

pane.setDividerSize(10);
sion(400, 200));

setLayout(new GridLayout(1,1));

add(pane, new Dimension(1,1));
}

}

}

FILE: MainFrame.java

import javax.swing.*;

import java.awt.*;

public class MainFrame extends JFrame{
MainFrame() {
//Set properties

setTitle("viewer v1.0");

setSize(600,400);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Define container

Container pane = getContentPane();
//Set BorderLayout

BorderLayout border = new BorderLayout();

pane.setLayout(border);
pane.add(new SplitPanel());
setVisible(true);

}

}

FILE: Main.java

import javax.swing.*;

public class Main {

public static void main(String[] args) {

JFrame.setDefaultLookAndFeelDecorated(true);
MainFrame joe = new MainFrame();
}

}

Jul 17 '05 #1
1 2967
David wrote:
Hello,
I'm starting with java and i'm having problems to display an image in a
splitpanel with a scrollbar.
I have different files but those required are described below. I think the
problem is coming from the file RightPanel.java here below does do not
display the image.
There is no problem of compilation , it works fine. Just that the image and
scrollbar are not displayed.
If anybody could help it would really be great.
thanks,.
david

FILE RightPanel

import javax.swing.*;

import java.awt.*;

public class RightPanel extends JPanel {

private JLabel picture;
RightPanel() {
ImageIcon pathImage = new ImageIcon("images/image.gif");

picture = new JLabel(pathImage);

JScrollPane imageDisplayPane = new JScrollPane(picture);
this.add(imageDisplayPane);

this.setSize(300,250);

this.setBackground(Color.white);

this.setVisible(true);

}

It looks like you forgot to add the picture to the JScrollPane.

Ray

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: AIK | last post by:
Can someone show me or point me to a nice tutorial on showing imageicon images in a jframe? Thanks.
0
by: Mik | last post by:
I have a problem with drawing ImageIcon objects on a JPanel in a JApplet Everything is ok when I run applet locally, but when it's run from a server the images are not showing ImageIcon objects...
11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
117
by: Peter Olcott | last post by:
www.halting-problem.com
0
by: gilbert | last post by:
Hello. I am using .Net 2.0, C#. and am trying to put a MdiClient control into a SplitPanel of a SplitContainer. First, I put a SplitContainer called splitContainer1 into the form. In the...
1
by: mario99 | last post by:
I have an application that contains buttons which contain icons and images. When I run the app in Eclipse, they show fine. However, when I create the JAR file and run it, no icon shows, and I don't...
1
crystal2005
by: crystal2005 | last post by:
Hi all, Can anyone tell me why my image doesn't appear in my frame's container? When I change imageIcon to just normal Label, it does go work. In another condition, if i don't use method...
1
by: Stefan Hoffmann | last post by:
hi @all, I have a simple draw control which uses the OnPaint event: protected override void OnPaint(PaintEventArgs pe) { base.OnPaint(pe); CalculatePaint(); DrawCanvas(pe.Graphics); if...
2
by: Coreyja | last post by:
Im trying to display a png image by setting it as a ImageIcon and then putting that in a JLabel. I cant get it to display the image. I am using a null layout as it is the simplest way for me to get...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.