[英]how can i get a jPanel that is inside a JtabbedPane
I'm developing a Image Editor in java, i inserted a JPanel inside a JTabbedPane, to create a JTabbedPane with tabs that rapresent the Image Filter i want to apply to the image, i don't know how to obtain a The inner JPanel of a TabbedPane to decide witch filter is selected, because when i do " jTabbedPane1.getSelectedComponent(); " i can obtain only a component not a JComponent.. 我正在用Java开发图像编辑器,我在JTabbedPane中插入了一个JPanel,以创建一个JTabbedPane,它的选项卡呈现了我想应用到图像的图像滤镜,我不知道如何获取内部的JPanel选择TabbedPane来决定筛选器,因为当我执行“ jTabbedPane1.getSelectedComponent();”时,我只能获得一个组件,而不是JComponent。
anyone knows something, sorry for my english thank's a lot.. 任何人都知道,对不起我的英语,谢谢。
This is a part of my code: 这是我的代码的一部分:
package javaapplication22;
import javax.swing.JPanel;
/**
*
* @author iDoc
*/
public abstract class FilterTab extends JPanel {
public FilterTab() {
}
protected void ApplyFilter() {
}
protected void ResetFilter() {
}
}
public class InvertFilterTab extends FilterTab {
private InvertFilter filter;
public InvertFilterTab ()
{
filter = new InvertFilter();
}
/**
*
* @param originalImage
* @param modifiedImage
*/
public void ApplyFilter(BufferedImage originalImage, BufferedImage modifiedImage) {
modifiedImage = filter.filter(originalImage, modifiedImage);
}
@Override
public void ResetFilter() {
}
}
private void button1ActionPerformed(java.awt.event.ActionEvent evt) {
BufferedImage originalImage = jOriginalPanel.getImage();
// BufferedImage modifiedImage = new BufferedImage(
// originalImage.getWidth(), originalImage.getHeight(),
// BufferedImage.TYPE_INT_ARGB);
//modifiedImage =
FilterTab ft = jTabbedPane1.getSelectedComponent(); <--- the problem is here
filter.filter(originalImage, modifiedImage);
jModifiedPanel.changeImage(modifiedImage);
jModifiedPanel.repaint();
Simply cast the result ... 简单地转换结果...
FilterTab tab = (FilterTab)jTabbedPane1.getSelectedComponent();
Remember, JPanel
extends from JComponent
, which extends from Container
, which extends from Component
记住,
JPanel
从JComponent
扩展而来, JComponent
从Container
扩展而来, Container
从Component
扩展而来
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.