在这篇文章中,我们将为您详细介绍JScrollPane中的JScrollPane的内容,并且讨论关于jscrollpane用法的相关问题。此外,我们还会涉及一些关于(二)美化滚动条-JScrollPa
在这篇文章中,我们将为您详细介绍JScrollPane中的JScrollPane的内容,并且讨论关于jscrollpane用法的相关问题。此外,我们还会涉及一些关于(二) 美化滚动条 - JScrollPane.js、com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.ScrollPaneStyle的实例源码、e822. 监听 JScrollPane 的滚动、Java JTextPane JScrollPane显示问题的知识,以帮助您更全面地了解这个主题。
本文目录一览:- JScrollPane中的JScrollPane(jscrollpane用法)
- (二) 美化滚动条 - JScrollPane.js
- com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.ScrollPaneStyle的实例源码
- e822. 监听 JScrollPane 的滚动
- Java JTextPane JScrollPane显示问题
JScrollPane中的JScrollPane(jscrollpane用法)
我有一个JScrollPane
,JPanel
其内容窗格为。为此,JPanel
我添加了较小JPanel
的,并且如预期的那样,如果添加太多JPanel
,则会出现一个垂直滚动条。
问题是,我的小JPanel
s包含一个JScrollPane
过了JEditorPane
。我想使用鼠标滚轮 仅
用于滚动面板外,而不是较小的滚动窗格。我已经设定wheelScrollingEnabled()
到false
为小滚动面板,但如果我朝任意方向滚动,以及鼠标越过JEditorPane
,滚动不工作了。
有什么建议吗?
答案1
小编典典您可以尝试将滚轮事件从内部滚动窗格转发到其父级。
innerScrollPane.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { innerScrollPane.getParent().dispatchEvent(e); }});
(二) 美化滚动条 - JScrollPane.js
JScrollPane资料
- Github
- 参考地址
Api查看
由于官网Api地址不能访问,查看Api只能去Github上下载对应的案例。或查看插件库的文档 - jQ22对应的案例
引入文件
<link type="text/css" href="style/jquery.jscrollpane.css" rel="stylesheet" media="all" />
<script type="text/javascript" src="js/jquery.jscrollpane.min.js"></script>
DOM结构
<div>
...内容
</div>
基本使用
$(function() {
var element = $(''.scroll-pane'').jScrollPane();
// 获取特定滚动条窗口的API参考,可以访问应用元素中的jsp变量
var api = element.data(''jsp'');
});
参数选项
$(''.scroll-pane'').jScrollPane(
showArrows - boolean (default false)//显示滑杆两边的箭头
maintainPosition - boolean (default true)//保持原位置
stickToBottom- boolean (default false)//滑到底部
stickToRight- boolean (default false)//滑到最右边
autoReinitialise - boolean (default false)//自动加载出现滑杆
autoReinitialiseDelay - int (default 500)//自动加载的时间延迟
verticalDragMinHeight - int (default 0)//垂直拖拽的最小高度
verticalDragMaxHeight - int (default 99999)//处置拖拽的最大高度
horizontalDragMinWidth - int (default 0)//水平拖拽的长度
horizontalDragMaxWidth - int (default 99999)//水平拖拽的最大长度
contentWidth - int (default undefined)//内幕内用的宽度
animateScroll - boolean (default false)//滚动动画
animateDuration - int (default 300)//动画延迟
animateEase - string (default ''linear'')//动画轨迹
hijackInternalLinks - boolean (default false)//截获内部链接
verticalGutter - int (default 4)//处置不掉长度
horizontalGutter - int (default 4)//水平不掉长度
mouseWheelSpeed - int (default 10)//鼠标疼速度
arrowButtonSpeed - int (default 10)//方向键按钮的速度
arrowRepeatFreq - int (default 100)//按钮事件重复频率
arrowScrollOnHover - boolean (default false)//接手鼠标在方向键上滑过的动作
verticalArrowPositions - string [split|before|after|os] (default split)//垂直方向上按钮的位置
horizontalArrowPositions - string [split|before|after|os] (default split)//水平方向上按钮的位置
enableKeyboardNavigation - boolean (default true)//是否接受键盘操作
hideFocus - boolean (default false)//隐藏焦点
clickOnTrack - boolean (default true)//路径上点击操作
trackClickSpeed - int (default 30)//互动轨迹上的点击速度
trackClickRepeatFreq - int (default 100)//滑动轨迹上的重复频率
);
com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.ScrollPaneStyle的实例源码
@Override public void stylePropertyChanged(StyleProperty styleProperty,Actor styleActor) { if (styleProperty.type == Drawable.class) { dialogFactory.showDialogDrawables(styleProperty); } else if (styleProperty.type == Color.class) { dialogFactory.showDialogColors(styleProperty); } else if (styleProperty.type == BitmapFont.class) { dialogFactory.showDialogFonts(styleProperty); } else if (styleProperty.type == Float.TYPE) { main.getUndoableManager().addUndoable(new UndoableManager.Doubleundoable(main,styleProperty,((Spinner) styleActor).getValue()),false); } else if (styleProperty.type == ScrollPanestyle.class) { main.getUndoableManager().addUndoable(new UndoableManager.SelectBoxUndoable(root,(SelectBox) styleActor),true); } else if (styleProperty.type == LabelStyle.class) { main.getUndoableManager().addUndoable(new UndoableManager.SelectBoxUndoable(root,true); } else if (styleProperty.type == ListStyle.class) { main.getUndoableManager().addUndoable(new UndoableManager.SelectBoxUndoable(root,true); } }
protected final Actor b(Skin paramSkin,Stage paramStage) { Label.LabelStyle localLabelStyle = new Label.LabelStyle((Label.LabelStyle)paramSkin.get("default",Label.LabelStyle.class)); localLabelStyle.fontColor = Color.WHITE; Label localLabel = new Label(this.a,localLabelStyle); localLabel.setWrap(true); localLabel.setAlignment(10); localLabel.setWidth(0.95F * paramStage.getWidth()); localLabel.setHeight(0.95F * paramStage.getHeight()); h localh = new h(localLabel,new ScrollPane.ScrollPanestyle(),0.0F,this.b,this.c); localh.setScrollY(0.0F); Table localTable = new Table(); localTable.setWidth(paramStage.getWidth() - 10.0F); localTable.setHeight(0.3F * paramStage.getHeight()); localTable.setX(5.0F); localTable.setY(5.0F); localTable.add(localh).a(e.a(1.0F)).b(e.b(1.0F)).a(4.0F,4.0F,4.0F).l().i(); return localTable; }
protected final Table b(Skin paramSkin,float paramFloat) { Label localLabel = new Label("Welcome,friend,to the struggle for a brighter age. Recruit the like minded for the Enlightened.\n\nSeek the future. Find a nearby Portal. Claim it. XM is power. XM is evolution. XM is all. Spread the enlightenment.\n\n- Collect XM\n- discover and claim new Portals\n- Link Portals to form XM Fields\n- dismantle Resistance XM Fields\n\n",(Label.LabelStyle)paramSkin.get("jarvis-message-label",Label.LabelStyle.class)); localLabel.setWrap(true); localLabel.setAlignment(10); localLabel.setWidth(paramFloat * 0.9F); localLabel.layout(); h localh = new h(localLabel,bs.l.c(),0.05F); localh.setScrollPercentY(0.0F); localh.setScrollingdisabled(true,false); Table localTable = new Table(); localTable.setX(0.0F); localTable.setWidth(paramFloat); localTable.add(localh).l().k().a(e.a(0.9F)).b(e.b(0.9F)).g(15.0F).e(e.b(0.1F)); return localTable; }
protected final Table b(Skin paramSkin,float paramFloat) { Label localLabel = new Label("Authentication complete. You are Now a Humanist agent. Our struggle is only beginning. If you kNow others who want to save the future,initiate them.\n\nKeep Exploring. Find a Portal near you. Claim it. Save humanity. Save yourself. Resist corrupting thoughts.\n\n- Collect XM\n- discover and claim new Portals\n- Link Portals to form XM Fields\n- dismantle Enlightened XM Fields\n\n",(Label.LabelStyle)paramSkin.get("message-label",bs.j.c(),false); Table localTable = new Table(); localTable.setX(0.0F); localTable.setWidth(paramFloat); localTable.add(localh).l().k().a(e.a(0.9F)).b(e.b(0.95F)).a(10.0F,10.0F,10.0F); return localTable; }
public final void a(Skin paramSkin,Stage paramStage) { this.k = ((Label.LabelStyle)paramSkin.get("mission-list",Label.LabelStyle.class)); this.l = ((Label.LabelStyle)paramSkin.get("mission-list-disabled",Label.LabelStyle.class)); this.d = ((TextButton.TextButtonStyle)paramSkin.get("mission-list",TextButton.TextButtonStyle.class)); this.e = ((TextButton.TextButtonStyle)paramSkin.get("mission-list-completed",TextButton.TextButtonStyle.class)); this.f = ((TextButton.TextButtonStyle)paramSkin.get("mission-list-selected",TextButton.TextButtonStyle.class)); this.g = ((Button.ButtonStyle)paramSkin.get("default",TextButton.TextButtonStyle.class)); this.h = ((Button.ButtonStyle)paramSkin.get("disabled",Button.ButtonStyle.class)); this.o = paramSkin.getDrawable("nav-button-clear"); this.b = new Table(); this.b.setWidth(paramStage.getWidth()); this.b.setHeight(paramStage.getHeight()); cc.a(this.a,new aa(paramSkin,(int)paramStage.getWidth(),cc.b(this.a),com.nianticproject.ingress.common.ui.widget.ag.c)); this.b.add(cc.c(this.a)); this.b.row(); this.c = new Table(); this.c.setWidth(-10 + (int)paramStage.getWidth()); ScrollPane localScrollPane = new ScrollPane(this.c,new ScrollPane.ScrollPanestyle()); localScrollPane.setScrollY(0.0F); localScrollPane.setScrollingdisabled(true,false); this.b.add(localScrollPane).g().o().p().j().a(5.0F,5.0F,5.0F); paramStage.addActor(this.b); }
public LogMenu() { label = new Label("",new LabelStyle(Fonts.smallHUD,Color.BLACK)); label.setWrap(true); Drawable background = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/LogBackground.png")); scrollPane = new ScrollPane(label,new ScrollPanestyle(background,null,null)); scrollPane.setScrollingdisabled(true,false); back = MenuTools.getBackButton(this); stage.addActor(scrollPane); stage.addActor(back); refresh(); }
public LogMenu() { label = new Label("",false); back = MenuTools.getBackButton(this); stage.addActor(scrollPane); stage.addActor(back); refresh(); }
private void addScrollPanestyles() { ScrollPanestyle style = new ScrollPanestyle(); Drawable scroll = newDrawable("pixel",1,0.20f); Drawable knob = newDrawable("pixel",0.40f); scroll.setMinWidth(10); knob.setMinWidth(10); style.vScroll = style.hScroll = scroll; style.vScrollKnob = style.hScrollKnob = knob; add("default",style); }
@Override public void layout () { Drawable bg = style.background; BitmapFont font = style.font; if (bg != null) { prefheight = Math.max(bg.getTopHeight() + bg.getBottomHeight() + font.getCapHeight() - font.getDescent() * 2,bg.getMinHeight()); } else prefheight = font.getCapHeight() - font.getDescent() * 2; float maxItemWidth = 0; for (int i = 0; i < items.size; i++) maxItemWidth = Math.max(font.getBounds(items.get(i).toString()).width,maxItemWidth); prefWidth = maxItemWidth; if (bg != null) prefWidth += bg.getLeftWidth() + bg.getRightWidth(); ListStyle listStyle = style.listStyle; ScrollPanestyle scrollStyle = style.scrollStyle; prefWidth = Math.max( prefWidth,maxItemWidth + (scrollStyle.background == null ? 0 : scrollStyle.background.getLeftWidth() + scrollStyle.background.getRightWidth()) + listStyle.selection.getLeftWidth() + listStyle.selection.getRightWidth() + Math.max(style.scrollStyle.vScroll != null ? style.scrollStyle.vScroll.getMinWidth() : 0,style.scrollStyle.vScrollKnob != null ? style.scrollStyle.vScrollKnob.getMinWidth() : 0)); }
public SelectBoxStyle (BitmapFont font,Color fontColor,Drawable background,ScrollPanestyle scrollStyle,ListStyle listStyle) { this.font = font; this.fontColor.set(fontColor); this.background = background; this.scrollStyle = scrollStyle; this.listStyle = listStyle; }
public SelectBoxStyle (SelectBoxStyle style) { this.font = style.font; this.fontColor.set(style.fontColor); if (style.disabledFontColor != null) this.disabledFontColor = new Color(style.disabledFontColor); this.background = style.background; this.backgroundOver = style.backgroundOver; this.backgroundOpen = style.backgroundOpen; this.backgrounddisabled = style.backgrounddisabled; this.scrollStyle = new ScrollPanestyle(style.scrollStyle); this.listStyle = new ListStyle(style.listStyle); }
public ScrollList (ListStyle liststyle,ScrollPanestyle scrollpanestyle ) { super(); list = new List (new String[]{""},liststyle); scrollpane = new ScrollPane (list,scrollpanestyle); scrollpane.setFadeScrollBars(false); addActor(scrollpane); }
public FilesListWidget(Skin skin) { super(false); style = skin.get(FilesListWidgetStyle.class); folderStyle = new FileIconWidgetStyle(style.folderIcon,style.font,style.fontColor,style.selected,style.over); fileStyle = new FileIconWidgetStyle(style.fileIcon,style.over); filesContainer = new Group(); ScrollPanestyle scrollStyle = skin.get(ScrollPanestyle.class); scrollPane = new ScrollPane(filesContainer,scrollStyle); scrollPane.setFlickScroll(false); scrollPane.setFlingTime(0); scrollPane.setSmoothScrolling(false); currentPath = new TextField("",skin); currentPath.addListener(new InputListener() { @Override public boolean keyDown(InputEvent event,int keycode) { switch (keycode) { case Keys.ENTER: String path = currentPath.getText(); FileHandle fileHandle = Gdx.files.absolute(path); if (fileHandle.exists()) { setSelectedFile(fileHandle,true); } return true; } return false; } }); add(currentPath).expandX(); add(scrollPane).expand(true,true); }
public a(com.nianticproject.ingress.shared.playerprofile.a parama,Skin paramSkin,c paramc,float paramFloat) { this.a = ((com.nianticproject.ingress.shared.playerprofile.a)an.a(parama)); this.b = ((Skin)an.a(paramSkin)); this.c = ((c)an.a(paramc)); this.h = l.a(32.0F); this.g = paramFloat; this.f = new Table(); this.f.defaults().j(l.a(8.0F)); ScrollPane.ScrollPanestyle localScrollPanestyle = (ScrollPane.ScrollPanestyle)paramSkin.get("avatar-color-picker",ScrollPane.ScrollPanestyle.class); ScrollPane localScrollPane = new ScrollPane(this.f,localScrollPanestyle); localScrollPane.setScrollingdisabled(false,true); localScrollPane.setFadeScrollBars(false); add(localScrollPane).o().g().c(this.h + 2.0F * paramFloat); }
public aa(Skin paramSkin,int paramInt,af paramaf,ag paramag) { this.c = paramSkin; this.a = paramaf; this.b = paramag; this.e = new Table(); this.d = new ab(this,this.e,new ScrollPane.ScrollPanestyle()); setWidth(paramInt); this.d.setWidth(paramInt); this.d.setScrollingdisabled(false,true); Table localTable1 = new Table(); Table localTable2 = new Table(); localTable2.setBackground(paramSkin.getDrawable("ops-title-background")); localTable1.add(localTable2).o().g(); Label localLabel = new Label("OPS",paramSkin,"ops-title"); localLabel.setAlignment(16,16); localTable2.add(localLabel).o().g().m().h(e.a(0.02F)); localTable1.row(); Table localTable3 = new Table(); this.f = new Table(); this.f.setBackground(paramSkin.getDrawable("ops-scroll-indicator-left")); this.g = new Table(); this.g.setBackground(paramSkin.getDrawable("ops-scroll-indicator-right")); localTable3.add(this.f).n().f().k().a(e.a(0.1F)); localTable3.add(this.g).n().f().m().a(e.a(0.1F)); Actor[] arrayOfActor = new Actor[2]; arrayOfActor[0] = this.d; arrayOfActor[1] = localTable3; localTable1.stack(arrayOfActor); Table localTable4 = new Table(); localTable4.setWidth(getWidth()); localTable4.setHeight(getHeight()); Button localButton = new Button(paramSkin,"ops-close"); localButton.addListener(new ac(this)); localTable4.add(localButton).n().k().j(); stack(new Actor[] { localTable1,localTable4 }); }
public h(Actor paramActor,ScrollPane.ScrollPanestyle paramScrollPanestyle,float paramFloat1,float paramFloat2,float paramFloat3) { super(paramActor,paramScrollPanestyle); this.c = paramFloat2; this.d = paramFloat3; this.e = paramFloat1; this.f = 0L; if (paramFloat1 > 0.0F); for (this.h = (0.5F * (paramFloat1 * paramFloat2)); ; this.h = 0.0F) { setScrollingdisabled(true,false); addListener(new i(this)); return; } }
public void resetProperties() { properties.clear(); if (clazz.equals(Button.class)) { newStyleProperties(ButtonStyle.class); } else if (clazz.equals(CheckBox.class)) { newStyleProperties(CheckBoxStyle.class); properties.get("checkBoxOn").optional = false; properties.get("checkBoxOff").optional = false; properties.get("font").optional = false; } else if (clazz.equals(ImageButton.class)) { newStyleProperties(ImageButtonStyle.class); } else if (clazz.equals(ImageTextButton.class)) { newStyleProperties(ImageTextButtonStyle.class); properties.get("font").optional = false; } else if (clazz.equals(Label.class)) { newStyleProperties(LabelStyle.class); properties.get("font").optional = false; } else if (clazz.equals(List.class)) { newStyleProperties(ListStyle.class); properties.get("font").optional = false; properties.get("fontColorSelected").optional = false; properties.get("fontColorUnselected").optional = false; properties.get("selection").optional = false; } else if (clazz.equals(ProgressBar.class)) { newStyleProperties(ProgressBarStyle.class); //Though specified as optional in the doc,there are bugs without "background" being mandatory properties.get("background").optional = false; } else if (clazz.equals(ScrollPane.class)) { newStyleProperties(ScrollPanestyle.class); } else if (clazz.equals(SelectBox.class)) { newStyleProperties(SelectBoxStyle.class); properties.get("font").optional = false; properties.get("fontColor").optional = false; properties.get("scrollStyle").optional = false; properties.get("scrollStyle").value = "default"; properties.get("listStyle").optional = false; properties.get("listStyle").value = "default"; } else if (clazz.equals(Slider.class)) { newStyleProperties(SliderStyle.class); //Though specified as optional in the doc,there are bugs without "background" being mandatory properties.get("background").optional = false; } else if (clazz.equals(SplitPane.class)) { newStyleProperties(SplitPanestyle.class); properties.get("handle").optional = false; } else if (clazz.equals(TextButton.class)) { newStyleProperties(TextButtonStyle.class); properties.get("font").optional = false; } else if (clazz.equals(TextField.class)) { newStyleProperties(TextFieldStyle.class); properties.get("font").optional = false; properties.get("fontColor").optional = false; } else if (clazz.equals(TextTooltip.class)) { newStyleProperties(TextTooltipStyle.class); properties.get("label").optional = false; properties.get("label").value = "default"; } else if (clazz.equals(Touchpad.class)) { newStyleProperties(TouchpadStyle.class); } else if (clazz.equals(Tree.class)) { newStyleProperties(TreeStyle.class); properties.get("plus").optional = false; properties.get("minus").optional = false; } else if (clazz.equals(Window.class)) { newStyleProperties(WindowStyle.class); properties.get("titleFont").optional = false; } }
@Override public Actor parse(CocoStudioUIEditor editor,ObjectData widget) { ScrollPanestyle style = new ScrollPanestyle(); if (widget.getFileData() != null) { style.background = editor .findDrawable(widget,widget.getFileData()); } ScrollPane scrollPane = new ScrollPane(null,style); if ("Vertical_Horizontal".equals(widget.getScrollDirectionType())) { scrollPane.setForceScroll(true,true); } else if ("Horizontal".equals(widget.getScrollDirectionType())) { scrollPane.setForceScroll(true,false); } else if ("Vertical".equals(widget.getScrollDirectionType())) { scrollPane.setForceScroll(false,true); } scrollPane.setClamp(widget.isClipAble()); scrollPane.setFlickScroll(widget.isIsBounceEnabled()); Table table = new Table(); table.setSize(widget.getInnerNodeSize().getWidth(),widget .getInnerNodeSize().getHeight()); if (widget.getComboBoxIndex() == 0) {// 无颜色 } else if (widget.getComboBoxIndex() == 1) {// 单色 pixmap pixmap = new pixmap((int) table.getWidth(),(int) table.getHeight(),Format.RGBA8888); Color color = editor.getColor(widget.getSingleColor(),widget.getBackColorAlpha()); pixmap.setColor(color); pixmap.fill(); Drawable drawable = new TextureRegionDrawable(new TextureRegion( new Texture(pixmap))); table.setBackground(drawable); pixmap.dispose(); } scrollPane.setWidget(table); return scrollPane; }
public CreditsTable() { header = new Label("Credits",GuiStyles.headerLabelStyle); resourcesHeader = new Label("Resources",GuiStyles.normalLabelStyle); playButton = new PlayButton(); menuButton = new MenuButton(); innerTable = new Table(); scrollPane = new ScrollPane(innerTable); ScrollPanestyle scrollPanestyle = new ScrollPanestyle(); scrollPane.setStyle(scrollPanestyle); Texture bg = new Texture(Gdx.files.internal("border.png")); /*TextureRegion leftCorner = new TextureRegion(bg,16,16); TextureRegion top = new TextureRegion(bg,64,16); Texture topTex = top;*/ scrollPanestyle.background = new NinePatchDrawable(new NinePatch(new TextureRegion(bg),16)); scrollPanestyle.vScrollKnob = new NinePatchDrawable(new NinePatch(new Texture(Gdx.files.internal("knob.png")),3,3)); scrollPane.setFadeScrollBars(false); addCreditsHeader("Developers",innerTable); addCredits("Creator:","mcprog",innerTable); addCreditsHeader("Resources",innerTable); addCredits("Death Sound:","braqoon",innerTable); addCredits("Trees:","Reiner \"Tiles\" Prokein",innerTable); addCredits("Font:","DeNada Industries",innerTable); addCreditsHeader("Shout Out",innerTable); addShoutOut("CSWS",innerTable); addShoutOut("History Channel's Vikings",innerTable); addShoutOut("ime990",innerTable); addShoutOut("Kai_Valhalla",innerTable); addShoutOut("Scandinavia",innerTable); add(header).colspan(2); row(); add(scrollPane).colspan(2).height(300).width(900); row(); add(playButton).pad(20); add(menuButton).pad(20); }
public ScrollList (Skin skin) { this(skin.get(ListStyle.class),skin.get(ScrollPanestyle.class)); }
public LicenseScreen (Game g) { game = g; stage = new Stage(new FitViewport(WIDTH,HEIGHT)); skin = new Skin(); assets = new Assets(); assets.initMainMenu(); Gdx.input.setInputProcessor(stage); FileHandle handle; handle = Gdx.files.internal(LICENSE_PATH); licenseString = handle.readString(); Table table = new Table(); table.setFillParent(true); stage.addActor(table); skin.add("default",new BitmapFont(Gdx.files.internal(FONT_PATH))); LabelStyle labelStyle = new LabelStyle(); labelStyle.font = skin.getFont("default"); skin.add("default",labelStyle); ScrollPanestyle scrollPanestyle = new ScrollPanestyle(); skin.add("default",scrollPanestyle); TextButtonStyle textButtonStyle = new TextButtonStyle(); textButtonStyle.font = skin.getFont("default"); textButtonStyle.up = new NinePatchDrawable(assets.getBoxPatch()); skin.add("default",textButtonStyle); Label license = new Label(licenseString,skin); ScrollPane scrollPane = new ScrollPane(license,skin); scrollPane.setFlickScroll(true); table.add(scrollPane); table.row(); TextButton backButton = new TextButton("Back",skin); table.add(backButton).padTop(TABLE_PAD); table.padTop(TABLE_PAD); table.padBottom(TABLE_PAD); table.row(); backButton.addListener(new @R_301_1839@() { public void changed (ChangeEvent event,Actor actor) { dispose(); game.setScreen(new MainMenuScreen(game)); } }); }
public CategoryStatsScreen(MissingWords missingWords) { super(missingWords); font = new BitmapFont(Gdx.files.internal("fonts/title.fnt"),Gdx.files.internal("fonts/title.png"),false); fontList = new BitmapFont(Gdx.files.internal("fonts/listFont.fnt"),Gdx.files.internal("fonts/listFont.png"),false); /* Creamos el fondo de pantalla */ background = new Background(MissingWords.myManager.get("background.png",Texture.class)); stage.addActor(background); /* Creamos el bot�n de vuelta atr�s */ backButton = new BackButton(); backButton.addListener(new BackButtonListener(missingWords)); /* Creamos la tabla que ocupar� todo el stage (pantalla) */ stageTable = new Table(); stageTable.setFillParent(true); /* Creamos la etiqueta de la categor�a */ title = new Label(null,new LabelStyle(font,font.getColor())); /* Creamos el progreso de la categor�a */ progress = new Label(null,font.getColor())); /* Creamos la lista de palabras de la categor�a */ list = new List<String>(new ListStyle( fontList,fontList.getColor(),new TextureRegionDrawable( new TextureRegion(MissingWords.myManager.get("selection.png",Texture.class))))); /* Creamos el scroll para la lista de palabras */ ScrollPane scroll = new ScrollPane(list,new ScrollPanestyle(new TextureRegionDrawable( new TextureRegion(MissingWords.myManager.get("background.png",Texture.class))),new TextureRegionDrawable( new TextureRegion(MissingWords.myManager.get("verticalScroll.png",new TextureRegionDrawable( new TextureRegion(MissingWords.myManager.get("squareBlue.png",Texture.class))))); /* Creamos la tabla izquierda del SplitPane */ left = new Table(); left.add(title).expand(); left.row(); left.add(progress).expand(); left.row(); left.add(backButton).align(Align.left).pad(10); /* Creamos la tabla derecha del SplitPane */ right = new Table(); right.add(scroll).fill().expand(); /* Creamos el SplitPane */ SplitPane split = new SplitPane(left,right,false,new SplitPanestyle( new TextureRegionDrawable( new TextureRegion(MissingWords.myManager.get("split.png",Texture.class))))); stageTable.add(split).fill().expand(); // A�adimos el SplitPane a la stageTable stage.addActor(stageTable); // A�adimos la stageTable al stage }
public void setStyle(ScrollPanestyle style) { if (style == null) throw new IllegalArgumentException("style cannot be null."); this.style = style; invalidateHierarchy(); }
public final void a(Skin paramSkin,Stage paramStage) { Table localTable1 = new Table(); localTable1.setWidth(paramStage.getWidth()); localTable1.setHeight(paramStage.getHeight()); Table localTable2 = new Table(); this.f = new al(this.b,paramStage,this.c); localTable2.add(this.f).o().g().h(24.0F); localTable2.row(); localTable2.add(new Image(com.nianticproject.ingress.common.b.c.a(paramSkin,46783))).c(l.a(2.0F)).o().g(); localTable2.row(); Table localTable3 = new Table(); this.m = new Label("",(Label.LabelStyle)paramSkin.get("profiles-select-badge-for-details",Label.LabelStyle.class)); paramSkin.get("default",TextButton.TextButtonStyle.class); localTable3.add(this.m); localTable2.add(localTable3).h(l.a(16.0F)).j(l.a(16.0F)); localTable2.row(); float f1 = l.a(24.0F); this.g = new z(this.a,Integer.valueOf(5),localTable1.getWidth(),f1,0.0F); Table localTable4 = new Table(); localTable4.top(); localTable4.add(this.g).o().g().k(f1); ScrollPane localScrollPane = new ScrollPane(localTable4,(ScrollPane.ScrollPanestyle)paramSkin.get("profiles",ScrollPane.ScrollPanestyle.class)); localScrollPane.setScrollingdisabled(true,false); localScrollPane.setFadeScrollBars(false); localTable2.add(localScrollPane).f().n(); Table localTable5 = new Table(); localTable5.setBackground(com.nianticproject.ingress.common.b.c.a(paramSkin,0)); ProgressIndicator localProgressIndicator = new ProgressIndicator(paramSkin); localProgressIndicator.a(true); localTable5.add(localProgressIndicator).i(); Table localTable6 = new Table(); this.k = new Label("",(Label.LabelStyle)paramSkin.get("default",Label.LabelStyle.class)); localTable6.add(this.k).i(); this.l = new f("",(TextButton.TextButtonStyle)paramSkin.get("default",TextButton.TextButtonStyle.class)); localTable6.row(); localTable6.add(this.l).i().h(l.a(8.0F)); this.h = localTable5; this.i = localTable2; this.j = localTable6; Table localTable7 = new Table(); d locald = new d(paramSkin,"ops-close"); locald.addListener(new ar(this)); localTable7.add(locald).n().k().j(); Actor[] arrayOfActor = new Actor[4]; arrayOfActor[0] = this.i; arrayOfActor[1] = this.h; arrayOfActor[2] = this.j; arrayOfActor[3] = localTable7; localTable1.stack(arrayOfActor).f().n(); paramStage.addActor(localTable1); }
public final void a(Skin paramSkin,Stage paramStage) { this.f = new Table(); this.f.setWidth(paramStage.getWidth()); this.f.setHeight(paramStage.getHeight()); if (this.c != null) { this.e = new aa(paramSkin,this.c,ag.b); if (this.a) { this.f.add(this.e); this.f.row(); } } Table localTable1 = this.f; float f1 = this.f.getWidth(); Table localTable2 = new Table(); localTable2.top(); float f2 = l.a(24.0F); this.l = new al(this.b,this.a); localTable2.add(this.l).o().g(); this.m = new z(this.d,Integer.valueOf(2),f2,l.a(16.0F),l.a(16.0F)); localTable2.row(); localTable2.add(this.m).o().g().k(f2); this.m.setBackground(paramSkin.getTiledDrawable("tile-diag")); localTable2.row(); localTable2.add(new Image(com.nianticproject.ingress.common.b.c.a(paramSkin,46783))).c(l.a(2.0F)).o().g().k(f2); this.n = new af(paramSkin,f2); localTable2.row(); localTable2.add(this.n).o().g().k(f2); ScrollPane localScrollPane = new ScrollPane(localTable2,false); Table localTable3 = new Table(); Table localTable4 = new Table(); ProgressIndicator localProgressIndicator = new ProgressIndicator(paramSkin); localProgressIndicator.a(true); localTable3.add(localProgressIndicator).i(); this.j = new Label("",Label.LabelStyle.class)); localTable4.add(this.j).i(); this.k = new f("",TextButton.TextButtonStyle.class)); localTable4.row(); localTable4.add(this.k).i().h(l.a(8.0F)); Table localTable5 = new Table(); this.g = localScrollPane; this.h = localTable3; this.i = localTable4; Table localTable6 = new Table(); d locald = new d(paramSkin,"ops-close"); locald.addListener(new be(this)); localTable6.add(locald).n().k().j(); if (!this.a); for (boolean bool = true; ; bool = false) { localTable6.setVisible(bool); Actor[] arrayOfActor = new Actor[4]; arrayOfActor[0] = this.g; arrayOfActor[1] = this.h; arrayOfActor[2] = this.i; arrayOfActor[3] = localTable6; localTable5.stack(arrayOfActor).n().f(); localTable1.add(localTable5).f().n(); paramStage.addActor(this.f); return; } }
ab(aa paramaa,Actor paramActor,ScrollPane.ScrollPanestyle paramScrollPanestyle) { super(paramActor,paramScrollPanestyle); }
protected final Table a(Skin paramSkin,Drawable paramDrawable,List<String> paramList,String paramString1,String paramString2,float paramFloat2) { Table localTable1 = new Table(); localTable1.setX(0.0F); localTable1.setWidth(paramFloat1); Table localTable2 = new Table(); this.e = new Spectrograph(paramSkin); Table localTable3 = new Table(); localTable3.setBackground(paramSkin.getDrawable("message-window")); localTable3.add(this.e).n().f().a(4.0F,4.0F); localTable2.add(localTable3).b(Integer.valueOf(2)).b().i().a(e.a(0.99F)).b(e.b(0.68F)); localTable2.row(); ImageButton localImageButton1 = new ImageButton(paramSkin,"audio-pause"); ImageButton localImageButton2 = new ImageButton(paramSkin,"audio-rewind"); this.a = new f(this.e); localImageButton1.addListener(new c(this,localImageButton1,paramSkin)); localImageButton2.addListener(new d(this,paramSkin)); Table localTable4 = new Table(); localTable4.add(localImageButton1).a(e.a(0.25F)).b(e.b(0.9F)); localTable4.add(localImageButton2).a(e.a(0.25F)).b(e.b(0.9F)); localTable2.add(localTable4).a(e.a(1.0F)).b(e.b(0.35F)).i(); localTable1.add(localTable2).b(Integer.valueOf(2)).b().i().a(e.a(0.99F)).b(e.b(0.3F)); localTable1.row(); Table localTable5 = new Table(); e locale = e.a(0.04F); localTable5.defaults().j().k().o().g().f(locale).h(locale); boolean bool = br.b(paramString2); float f1 = 0.0F; if (!bool) { Label localLabel1 = new Label("Mission - " + paramString2,(Label.LabelStyle)paramSkin.get("mission-briefing-title-old",Label.LabelStyle.class)); localTable5.add(localLabel1); localTable5.row(); f1 = 0.0F + localLabel1.getTextBounds().height; } if ((paramList != null) && (!paramList.isEmpty())) { Label localLabel3 = new Label("Objectives",Label.LabelStyle.class)); localTable5.add(localLabel3); localTable5.row(); float f4 = f1 + localLabel3.getTextBounds().height; Iterator localIterator = paramList.iterator(); Label localLabel4; for (f1 = f4; localIterator.hasNext(); f1 += localLabel4.getTextBounds().height) { String str = (String)localIterator.next(); localLabel4 = new Label("- " + str,(Label.LabelStyle)paramSkin.get("mission-briefing-objective",Label.LabelStyle.class)); localLabel4.setWrap(true); localTable5.add(localLabel4); localTable5.row(); } } Label localLabel2 = new Label(paramString1 + "\n ",Label.LabelStyle.class)); localLabel2.setWrap(true); localLabel2.setAlignment(10); localLabel2.setWidth(0.9F * paramFloat1); localLabel2.layout(); float f2 = localLabel2.getTextBounds().height; float f3 = 1.0F - f2 / (f1 + f2); localTable5.add(localLabel2).l().a(e.a(1.0F)).b(e.a()); h localh = new h(localTable5,f3,paramFloat2,d); localh.setScrollPercentY(0.0F); localh.setScrollingdisabled(true,false); Table localTable6 = new Table(); localTable6.setBackground(paramDrawable); localTable6.add(localh).o().g().b(e.b(0.85F)).j().k(); localTable1.add(localTable6).b(Integer.valueOf(2)).c().i().a(e.a(0.99F)).b(e.b(0.69F)); localTable1.row(); return localTable1; }
/** * @param widget * May be null. */ public ScrollPane(Actor widget) { this(widget,new ScrollPanestyle()); }
/** * @param widget * May be null. */ public ScrollPane(Actor widget,Skin skin) { this(widget,skin.get(ScrollPanestyle.class)); }
/** * @param widget * May be null. */ public ScrollPane(Actor widget,Skin skin,String styleName) { this(widget,skin.get(styleName,ScrollPanestyle.class)); }
/** * Returns the scroll pane's style. Modifying the returned style may not * have an effect until {@link #setStyle(ScrollPanestyle)} is called. */ public ScrollPanestyle getStyle() { return style; }
e822. 监听 JScrollPane 的滚动
A scrollbar in a scroll pane fires adjustment events whenever its value changes.
// Create a scrollable text area
JTextArea textArea = new JTextArea();
JScrollPane pane = new JScrollPane(textArea);
// Listen for value changes in the scroll pane''s scrollbars
AdjustmentListener listener = new MyAdjustmentListener();
pane.getHorizontalScrollBar().addAdjustmentListener(listener);
pane.getVerticalScrollBar().addAdjustmentListener(listener);
class MyAdjustmentListener implements AdjustmentListener {
// This method is called whenever the value of a scrollbar is changed,
// either by the user or programmatically.
public void adjustmentValueChanged(AdjustmentEvent evt) {
Adjustable source = evt.getAdjustable();
// getValueIsAdjusting() returns true if the user is currently
// dragging the scrollbar''s knob and has not picked a final value
if (evt.getValueIsAdjusting()) {
// The user is dragging the knob
return;
}
// Determine which scrollbar fired the event
int orient = source.getOrientation();
if (orient == Adjustable.HORIZONTAL) {
// Event from horizontal scrollbar
} else {
// Event from vertical scrollbar
}
// Determine the type of event
int type = evt.getAdjustmentType();
switch (type) {
case AdjustmentEvent.UNIT_INCREMENT:
// Scrollbar was increased by one unit
break;
case AdjustmentEvent.UNIT_DECREMENT:
// Scrollbar was decreased by one unit
break;
case AdjustmentEvent.BLOCK_INCREMENT:
// Scrollbar was increased by one block
break;
case AdjustmentEvent.BLOCK_DECREMENT:
// Scrollbar was decreased by one block
break;
case AdjustmentEvent.TRACK:
// The knob on the scrollbar was dragged
break;
}
// Get current value
int value = evt.getValue();
}
}
Java JTextPane JScrollPane显示问题
以下类实现了chatGUI。正常运行时,屏幕如下所示:
精美的ChatGUI
http://img21.imageshack.us/img21/7177/rightchat.jpg
当我输入较大长度的文本时,问题经常出现。50到100个字符的gui变得疯狂。聊天记录框如下所示缩小
图片http://img99.imageshack.us/img99/6962/errorgui.jpg。
关于什么原因的任何想法?
谢谢。
PS:下面的附加类是完整的代码。您可以复制它并在计算机上进行编译,以确切地了解我的意思。
注意:一旦GUI变得疯狂,那么如果我单击“清除”按钮,历史记录窗口将清除,并且GUI返回到再次正确显示。
package Sartre.Connect4;import javax.swing.*;import java.net.*;import java.awt.*;import java.awt.event.*;import javax.swing.text.StyledDocument;import javax.swing.text.Style;import javax.swing.text.StyleConstants;import javax.swing.text.BadLocationException;import java.io.BufferedOutputStream;import javax.swing.text.html.HTMLEditorKit;import java.io.FileOutputStream;import java.io.IOException;import java.io.FileNotFoundException;import javax.swing.filechooser.FileNameExtensionFilter;import javax.swing.JFileChooser;/** * Chat form class * @author iAmjad */public class ChatGUI extends JDialog implements ActionListener {/** * Used to hold chat history data */private JTextPane textPaneHistory = new JTextPane();/** * provides scrolling to chat history pane */private JScrollPane scrollPaneHistory = new JScrollPane(textPaneHistory);/** * used to input local message to chat history */private JTextPane textPaneHome = new JTextPane();/** * Provides scrolling to local chat pane */private JScrollPane scrollPaneHomeText = new JScrollPane(textPaneHome);/** * JLabel acting as a statusbar */private JLabel statusBar = new JLabel("Ready");/** * Button to clear chat history pane */private JButton JBClear = new JButton("Clear");/** * Button to save chat history pane */private JButton JBSave = new JButton("Save");/** * Holds contentPane */private Container containerPane;/** * Layout GridBagLayout manager */private GridBagLayout gridBagLayout = new GridBagLayout();/** * GridBagConstraints */private GridBagConstraints constraints = new GridBagConstraints();/** * Constructor for ChatGUI */public ChatGUI(){ setTitle("Chat"); // set up dialog icon URL url = getClass().getResource("Resources/SartreIcon.jpg"); ImageIcon imageIcon = new ImageIcon(url); Image image = imageIcon.getImage(); this.setIconImage(image); this.setAlwaysOnTop(true); setLocationRelativeTo(this.getParent()); //////////////// End icon and placement ///////////////////////// // Get pane and set layout manager containerPane = getContentPane(); containerPane.setLayout(gridBagLayout); ///////////////////////////////////////////////////////////// //////////////// Begin Chat History ////////////////////////////// textPaneHistory.setToolTipText("Chat History Window"); textPaneHistory.setEditable(false); textPaneHistory.setPreferredSize(new Dimension(350,250)); scrollPaneHistory.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPaneHistory.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); // fill Chat History GridBagConstraints constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 10; constraints.gridheight = 10; constraints.weightx = 100; constraints.weighty = 100; constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(10,10,10,10); constraints.ipadx = 0; constraints.ipady = 0; gridBagLayout.setConstraints(scrollPaneHistory, constraints); // add to the pane containerPane.add(scrollPaneHistory); /////////////////////////////// End Chat History /////////////////////// ///////////////////////// Begin Home Chat ////////////////////////////// textPaneHome.setToolTipText("Home Chat Message Window"); textPaneHome.setPreferredSize(new Dimension(200,50)); textPaneHome.addKeyListener(new MyKeyAdapter()); scrollPaneHomeText.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPaneHomeText.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); // fill Chat History GridBagConstraints constraints.gridx = 0; constraints.gridy = 10; constraints.gridwidth = 6; constraints.gridheight = 1; constraints.weightx = 100; constraints.weighty = 100; constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(10,10,10,10); constraints.ipadx = 0; constraints.ipady = 0; gridBagLayout.setConstraints(scrollPaneHomeText, constraints); // add to the pane containerPane.add(scrollPaneHomeText); ////////////////////////// End Home Chat ///////////////////////// ///////////////////////Begin Clear Chat History //////////////////////// JBClear.setToolTipText("Clear Chat History"); // fill Chat History GridBagConstraints constraints.gridx = 6; constraints.gridy = 10; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.weightx = 100; constraints.weighty = 100; constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(10,10,10,10); constraints.ipadx = 0; constraints.ipady = 0; gridBagLayout.setConstraints(JBClear, constraints); JBClear.addActionListener(this); // add to the pane containerPane.add(JBClear); ///////////////// End Clear Chat History //////////////////////// /////////////// Begin Save Chat History ////////////////////////// JBSave.setToolTipText("Save Chat History"); constraints.gridx = 8; constraints.gridy = 10; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.weightx = 100; constraints.weighty = 100; constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(10,10,10,10); constraints.ipadx = 0; constraints.ipady = 0; gridBagLayout.setConstraints(JBSave, constraints); JBSave.addActionListener(this); // add to the pane containerPane.add(JBSave); ///////////////////// End Save Chat History ///////////////////// /////////////////// Begin Status Bar ///////////////////////////// constraints.gridx = 0; constraints.gridy = 11; constraints.gridwidth = 10; constraints.gridheight = 1; constraints.weightx = 100; constraints.weighty = 50; constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(0,10,5,0); constraints.ipadx = 0; constraints.ipady = 0; gridBagLayout.setConstraints(statusBar, constraints); // add to the pane containerPane.add(statusBar); ////////////// End Status Bar //////////////////////////// // set resizable to false this.setResizable(false); // pack the GUI pack();}/** * Deals with necessary menu click events * @param event */public void actionPerformed(ActionEvent event) { Object source = event.getSource(); // Process Clear button event if (source == JBClear){ textPaneHistory.setText(null); statusBar.setText("Chat History Cleared"); } // Process Save button event if (source == JBSave){ // process only if there is data in history pane if (textPaneHistory.getText().length() > 0){ // process location where to save the chat history file JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(false); chooser.setAcceptAllFileFilterUsed(false); FileNameExtensionFilter filter = new FileNameExtensionFilter("HTML Documents", "htm", "html"); chooser.setFileFilter(filter); int option = chooser.showSaveDialog(ChatGUI.this); if (option == JFileChooser.APPROVE_OPTION) { // Set up document to be parsed as HTML StyledDocument doc = (StyledDocument)textPaneHistory.getDocument(); HTMLEditorKit kit = new HTMLEditorKit(); BufferedOutputStream out; try { // add final file name and extension String filePath = chooser.getSelectedFile().getAbsoluteFile() + ".html"; out = new BufferedOutputStream(new FileOutputStream(filePath)); // write out the HTML document kit.write(out, doc, doc.getStartPosition().getOffset(), doc.getLength()); } catch (FileNotFoundException e) { JOptionPane.showMessageDialog(ChatGUI.this, "Application will now close. \n A restart may cure the error!\n\n" + e.getMessage(), "Fatal Error", JOptionPane.WARNING_MESSAGE, null); System.exit(2); } catch (IOException e){ JOptionPane.showMessageDialog(ChatGUI.this, "Application will now close. \n A restart may cure the error!\n\n" + e.getMessage(), "Fatal Error", JOptionPane.WARNING_MESSAGE, null); System.exit(3); } catch (BadLocationException e){ JOptionPane.showMessageDialog(ChatGUI.this, "Application will now close. \n A restart may cure the error!\n\n" + e.getMessage(), "Fatal Error", JOptionPane.WARNING_MESSAGE, null); System.exit(4); } statusBar.setText("Chat History Saved"); } } }}/** * Process return key for sending the message */private class MyKeyAdapter extends KeyAdapter { @Override @SuppressWarnings("static-access") public void keyPressed(KeyEvent ke) { //DateTime dateTime = new DateTime(); //String nowdateTime = dateTime.getDateTime(); int kc = ke.getKeyCode(); if (kc == ke.VK_ENTER) { try { // Process only if there is data if (textPaneHome.getText().length() > 0){ // Add message origin formatting StyledDocument doc = (StyledDocument)textPaneHistory.getDocument(); Style style = doc.addStyle("HomeStyle", null); StyleConstants.setBold(style, true); String home = "Home [" + nowdateTime + "]: "; doc.insertString(doc.getLength(), home, style); StyleConstants.setBold(style, false); doc.insertString(doc.getLength(), textPaneHome.getText() + "\n", style); // update caret location textPaneHistory.setCaretPosition(doc.getLength()); textPaneHome.setText(null); statusBar.setText("Message Sent"); } } catch (BadLocationException e) { JOptionPane.showMessageDialog(ChatGUI.this, "Application will now close. \n A restart may cure the error!\n\n" + e.getMessage(), "Fatal Error", JOptionPane.WARNING_MESSAGE, null); System.exit(1); } ke.consume(); } }}}
答案1
小编典典首先有很多一般性评论:
a)发布代码时发布SSCCE。如果您不知道什么是SSCCE,请搜索论坛或网络。我们只有有限的时间来查看代码,而300行的代码太多了。例如:
- 设置了代码,对话框图标与问题无关,并且由于我们无权访问您的资源文件而无法运行
- 执行保存的代码无关紧要,因为这不是您要解决的问题
- 如前所述,main()方法丢失了
b)使用正确的Java命名约定。变量名以小写字母开头。“ JBSave”和“ JBClear”不是标准名称,这会使您的代码难以读取。
c)我也同意Gridbaglayout很复杂,并且其他布局管理器(如前面给出的BorderLayout方法)更易于使用。具体来说,您对gridx和gridy的理解不正确。它们应用于指示“顺序”的行和列位置。也就是说,您应该使用(0,0),(0,1),(1,1),(2,1)。您的网格数跳到10。10不能反映相对大小。因此,您缺少行1、2、3、4、5、6、7
…是的,它可能会起作用,但是在阅读代码时却难以理解。
d)不要使用KeyListener来处理文本窗格中的Enter键。Swing被设计为使用“键绑定”。阅读Swing教程中有关同一主题的部分,以获取更多信息。
最后,对代码的修复很简单:
textPaneHome.setToolTipText("Home Chat Message Window");// textPaneHome.setPreferredSize(new Dimension(200,50)); textPaneHome.addKeyListener(new MyKeyAdapter()); scrollPaneHomeText.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrollPaneHomeText.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPaneHomeText.setPreferredSize(new Dimension(200,50));
通常,永远不要设置添加到滚动窗格的组件的首选大小。在这种情况下,将文本设置为null时,首选大小将重置为0,并且所有组件的布局似乎都已重做。
关于JScrollPane中的JScrollPane和jscrollpane用法的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于(二) 美化滚动条 - JScrollPane.js、com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.ScrollPaneStyle的实例源码、e822. 监听 JScrollPane 的滚动、Java JTextPane JScrollPane显示问题等相关内容,可以在本站寻找。
本文标签: