Java Code Examples for net.runelite.api.widgets.Widget#setOriginalY()
The following examples show how to use
net.runelite.api.widgets.Widget#setOriginalY() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChatboxTextInput.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
protected void update() { Widget container = chatboxPanelManager.getContainerWidget(); container.deleteAllChildren(); Widget promptWidget = container.createChild(-1, WidgetType.TEXT); promptWidget.setText(this.prompt); promptWidget.setTextColor(0x800000); promptWidget.setFontId(fontID); promptWidget.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); promptWidget.setOriginalX(0); promptWidget.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); promptWidget.setOriginalY(8); promptWidget.setOriginalHeight(24); promptWidget.setXTextAlignment(WidgetTextAlignment.CENTER); promptWidget.setYTextAlignment(WidgetTextAlignment.CENTER); promptWidget.setWidthMode(WidgetSizeMode.MINUS); promptWidget.revalidate(); buildEdit(0, 50, container.getWidth(), 0); }
Example 2
Source File: FriendsChatPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void loadFriendsChats() { Widget chatList = client.getWidget(WidgetInfo.FRIENDS_CHAT_LIST); if (chatList == null) { return; } int y = 2; chatList.setChildren(null); for (String chat : Lists.reverse(chats)) { Widget widget = chatList.createChild(-1, WidgetType.TEXT); widget.setFontId(494); widget.setTextColor(0xffffff); widget.setText(chat); widget.setOriginalHeight(14); widget.setOriginalWidth(142); widget.setOriginalY(y); widget.setOriginalX(20); widget.revalidate(); y += 14; } }
Example 3
Source File: ChatboxPerformancePlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private void fixDarkBackground() { int currOpacity = 256; int prevY = 0; Widget[] children = client.getWidget(WidgetInfo.CHATBOX_TRANSPARENT_BACKGROUND).getDynamicChildren(); Widget prev = null; for (Widget w : children) { if (w.getType() != WidgetType.RECTANGLE) { continue; } if (prev != null) { int relY = w.getRelativeY(); prev.setHeightMode(WidgetSizeMode.ABSOLUTE); prev.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); prev.setRelativeY(prevY); prev.setOriginalY(prev.getRelativeY()); prev.setHeight(relY - prevY); prev.setOriginalHeight(prev.getHeight()); prev.setOpacity(currOpacity); } prevY = w.getRelativeY(); currOpacity -= 3; // Rough number, can't get exactly the same as Jagex because of rounding prev = w; } if (prev != null) { prev.setOpacity(currOpacity); } }
Example 4
Source File: FriendsChatPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private void loadFriendsChats() { Widget chatList = client.getWidget(WidgetInfo.FRIENDS_CHAT_LIST); if (chatList == null) { return; } int y = 2; chatList.setChildren(null); for (String chat : Lists.reverse(chats)) { Widget widget = chatList.createChild(-1, WidgetType.TEXT); widget.setFontId(494); widget.setHasListener(true); widget.setTextColor(0xffffff); widget.setText(chat); widget.setTextShadowed(true); widget.setBorderType(1); widget.setAction(0, String.format("Join %s", chat)); widget.setOnOpListener(ScriptID.CUSTOM_JOIN_CLAN, widget.getText()); widget.setOriginalHeight(14); widget.setOriginalWidth(142); widget.setOriginalY(y); widget.setOriginalX(20); widget.revalidate(); y += 14; } }
Example 5
Source File: ItemStatPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private static void createSeparator(Widget parent, int y) { Widget separator = parent.createChild(-1, WidgetType.GRAPHIC); separator.setOriginalWidth(parent.getWidth()); separator.setOriginalY(y); separator.setOriginalHeight(32); separator.setSpriteId(SpriteID.UNKNOWN_BORDER_EDGE_HORIZONTAL_995); separator.revalidate(); }
Example 6
Source File: ItemStatPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private static Widget createText(Widget parent, String text, int fontId, int textColor, int x, int y, int width, int height) { final Widget widget = parent.createChild(-1, WidgetType.TEXT); widget.setText(text); widget.setFontId(fontId); widget.setTextColor(textColor); widget.setTextShadowed(true); widget.setOriginalHeight(height == -1 ? TEXT_HEIGHT : height); widget.setOriginalWidth(width); widget.setOriginalY(y); widget.setOriginalX(x); widget.revalidate(); return widget; }
Example 7
Source File: TabInterface.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private Widget createGraphic(Widget container, String name, int spriteId, int itemId, int width, int height, int x, int y, boolean hasListener) { Widget widget = container.createChild(-1, WidgetType.GRAPHIC); widget.setOriginalWidth(width); widget.setOriginalHeight(height); widget.setOriginalX(x); widget.setOriginalY(y); widget.setSpriteId(spriteId); if (itemId > -1) { widget.setItemId(itemId); widget.setItemQuantity(-1); widget.setBorderType(1); } if (hasListener) { widget.setOnOpListener(ScriptID.NULL); widget.setHasListener(true); } widget.setName(name); widget.revalidate(); return widget; }
Example 8
Source File: ItemStatPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private static void createSeparator(Widget parent, int y) { Widget separator = parent.createChild(-1, WidgetType.GRAPHIC); separator.setOriginalWidth(parent.getWidth()); separator.setOriginalY(y); separator.setOriginalHeight(32); separator.setSpriteId(SpriteID.UNKNOWN_BORDER_EDGE_HORIZONTAL_995); separator.revalidate(); }
Example 9
Source File: ItemStatPlugin.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
private static Widget createText(Widget parent, String text, int fontId, int textColor, int x, int y, int width, int height) { final Widget widget = parent.createChild(-1, WidgetType.TEXT); widget.setText(text); widget.setFontId(fontId); widget.setTextColor(textColor); widget.setTextShadowed(true); widget.setOriginalHeight(height == -1 ? TEXT_HEIGHT : height); widget.setOriginalWidth(width); widget.setOriginalY(y); widget.setOriginalX(x); widget.revalidate(); return widget; }
Example 10
Source File: BronzeManPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
private void addItemToCollectionLog(Widget collectionView, Integer itemId, int x, int y, int index) { String itemName = itemManager.getItemDefinition(itemId).getName(); Widget newItem = collectionView.createChild(index, 5); newItem.setContentType(0); newItem.setItemId(itemId); newItem.setItemQuantity(1); newItem.setItemQuantityMode(0); newItem.setModelId(-1); newItem.setModelType(1); newItem.setSpriteId(-1); newItem.setBorderType(1); newItem.setFilled(false); newItem.setRelativeX(x); newItem.setRelativeY(y); newItem.setOriginalX(x); newItem.setOriginalY(y); newItem.setOriginalWidth(36); newItem.setOriginalHeight(32); newItem.setWidth(36); newItem.setHeight(32); newItem.setHasListener(true); newItem.setAction(1, "Inspect"); newItem.setOnOpListener((JavaScriptCallback) e -> handleItemAction(itemName)); newItem.setName(itemName); newItem.revalidate(); }
Example 11
Source File: WikiSearchChatboxTextInput.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
@Override protected void update() { Widget container = chatboxPanelManager.getContainerWidget(); container.deleteAllChildren(); Widget promptWidget = container.createChild(-1, WidgetType.TEXT); promptWidget.setText(getPrompt()); promptWidget.setTextColor(0x800000); promptWidget.setFontId(getFontID()); promptWidget.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); promptWidget.setOriginalX(0); promptWidget.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); promptWidget.setOriginalY(5); promptWidget.setOriginalHeight(LINE_HEIGHT); promptWidget.setXTextAlignment(WidgetTextAlignment.CENTER); promptWidget.setYTextAlignment(WidgetTextAlignment.CENTER); promptWidget.setWidthMode(WidgetSizeMode.MINUS); promptWidget.revalidate(); buildEdit(0, 5 + LINE_HEIGHT, container.getWidth(), LINE_HEIGHT); Widget separator = container.createChild(-1, WidgetType.LINE); separator.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); separator.setOriginalX(0); separator.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); separator.setOriginalY(4 + (LINE_HEIGHT * 2)); separator.setOriginalHeight(0); separator.setOriginalWidth(16); separator.setWidthMode(WidgetSizeMode.MINUS); separator.revalidate(); for (int i = 0; i < predictions.size(); i++) { String pred = predictions.get(i); int y = 6 + (LINE_HEIGHT * (2 + i)); Widget bg = container.createChild(-1, WidgetType.RECTANGLE); bg.setTextColor(0x4444DD); bg.setFilled(true); bg.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); bg.setOriginalX(1); bg.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); bg.setOriginalY(y); bg.setOriginalHeight(LINE_HEIGHT); bg.setOriginalWidth(16); bg.setWidthMode(WidgetSizeMode.MINUS); bg.revalidate(); bg.setName("<col=ff9040>" + pred); bg.setAction(0, "Open"); bg.setHasListener(true); bg.setOnOpListener((JavaScriptCallback) ev -> search(pred)); Widget text = container.createChild(-1, WidgetType.TEXT); text.setText(pred); text.setFontId(getFontID()); text.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); text.setOriginalX(0); text.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); text.setOriginalY(y); text.setOriginalHeight(LINE_HEIGHT); text.setXTextAlignment(WidgetTextAlignment.CENTER); text.setYTextAlignment(WidgetTextAlignment.CENTER); text.setWidthMode(WidgetSizeMode.MINUS); text.revalidate(); if (i == selectedPrediction) { text.setTextColor(0xFFFFFF); } else { bg.setOpacity(255); text.setTextColor(0x000000); bg.setOnMouseRepeatListener((JavaScriptCallback) ev -> text.setTextColor(0xFFFFFF)); bg.setOnMouseLeaveListener((JavaScriptCallback) ev -> text.setTextColor(0x000000)); } } }
Example 12
Source File: TabInterface.java From plugins with GNU General Public License v3.0 | 4 votes |
private void updateBounds() { Widget itemContainer = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER); if (itemContainer == null) { return; } int height = itemContainer.getHeight(); // If player isn't using normal bank tabs if (itemContainer.getRelativeY() == 0) { height -= (TAB_HEIGHT + MARGIN); } bounds.setSize(TAB_WIDTH + MARGIN * 2, height); bounds.setLocation(MARGIN, TAB_HEIGHT + MARGIN); Widget incinerator = client.getWidget(WidgetInfo.BANK_INCINERATOR); if (incinerator != null && !incinerator.isHidden()) { incinerator.setOriginalHeight(INCINERATOR_HEIGHT); incinerator.setOriginalWidth(INCINERATOR_WIDTH); incinerator.setOriginalY(INCINERATOR_HEIGHT); Widget child = incinerator.getDynamicChildren()[0]; child.setOriginalHeight(INCINERATOR_HEIGHT); child.setOriginalWidth(INCINERATOR_WIDTH); child.setWidthMode(WidgetSizeMode.ABSOLUTE); child.setHeightMode(WidgetSizeMode.ABSOLUTE); child.setType(WidgetType.GRAPHIC); child.setSpriteId(TabSprites.INCINERATOR.getSpriteId()); incinerator.revalidate(); bounds.setSize(TAB_WIDTH + MARGIN * 2, height - incinerator.getHeight()); } if (upButton != null) { Point p = upButton.getCanvasLocation(); canvasBounds.setBounds(p.getX(), p.getY() + BUTTON_HEIGHT, bounds.width, maxTabs * TAB_HEIGHT + maxTabs * MARGIN); } }
Example 13
Source File: TabInterface.java From plugins with GNU General Public License v3.0 | 4 votes |
private void updateTabs() { int y = bounds.y + MARGIN + BUTTON_HEIGHT; if (maxTabs >= tabManager.size()) { currentTabIndex = 0; } else { y -= (currentTabIndex * TAB_HEIGHT + currentTabIndex * MARGIN); } int itemX = BANK_ITEM_START_X; int itemY = BANK_ITEM_START_Y; int rowIndex = 0; for (TagTab tab : tabManager.getTabs()) { updateWidget(tab.getBackground(), y); updateWidget(tab.getIcon(), y + 4); // Edge case where item icon is 1 pixel out of bounds tab.getIcon().setHidden(tab.getBackground().isHidden()); // Keep item widget shown while drag scrolling if (client.getDraggedWidget() == tab.getIcon()) { tab.getIcon().setHidden(false); } y += TAB_HEIGHT + MARGIN; Widget item = tab.getMenu(); item.setOriginalX(itemX); item.setOriginalY(itemY); item.revalidate(); rowIndex++; if (rowIndex == BANK_ITEMS_PER_ROW) { itemX = BANK_ITEM_START_X; itemY += BANK_ITEM_Y_PADDING + BANK_ITEM_HEIGHT; rowIndex = 0; } else { itemX += BANK_ITEM_X_PADDING + BANK_ITEM_WIDTH; } } boolean hidden = !(tabManager.size() > 0); upButton.setHidden(hidden); upButton.setOriginalY(bounds.y); upButton.revalidate(); downButton.setHidden(hidden); downButton.setOriginalY(bounds.y + maxTabs * TAB_HEIGHT + MARGIN * maxTabs + BUTTON_HEIGHT + MARGIN); downButton.revalidate(); }
Example 14
Source File: TabInterface.java From plugins with GNU General Public License v3.0 | 4 votes |
private void updateWidget(Widget t, int y) { t.setOriginalY(y); t.setHidden(y < (bounds.y + BUTTON_HEIGHT + MARGIN) || y > (bounds.y + bounds.height - TAB_HEIGHT - MARGIN - BUTTON_HEIGHT)); t.revalidate(); }
Example 15
Source File: QuestListPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
private void updateFilter(String filter) { filter = filter.toLowerCase(); final Widget container = client.getWidget(WidgetInfo.QUESTLIST_CONTAINER); final Widget freeList = client.getWidget(QuestContainer.FREE_QUESTS.widgetInfo); final Widget memberList = client.getWidget(QuestContainer.MEMBER_QUESTS.widgetInfo); final Widget miniList = client.getWidget(QuestContainer.MINI_QUESTS.widgetInfo); if (container == null || freeList == null || memberList == null || miniList == null) { return; } updateList(QuestContainer.FREE_QUESTS, filter); updateList(QuestContainer.MEMBER_QUESTS, filter); updateList(QuestContainer.MINI_QUESTS, filter); memberList.setOriginalY(freeList.getOriginalY() + freeList.getOriginalHeight() + (freeList.getOriginalHeight() == 0 ? 0 : ENTRY_PADDING)); miniList.setOriginalY(memberList.getOriginalY() + memberList.getOriginalHeight() + (memberList.getOriginalHeight() == 0 ? 0 : ENTRY_PADDING)); // originalHeight is changed within updateList so revalidate all lists freeList.revalidate(); memberList.revalidate(); miniList.revalidate(); int y = miniList.getRelativeY() + miniList.getHeight() + 10; int newHeight; if (container.getScrollHeight() > 0) { newHeight = (container.getScrollY() * y) / container.getScrollHeight(); } else { newHeight = 0; } container.setScrollHeight(y); container.revalidateScroll(); clientThread.invokeLater(() -> client.runScript( ScriptID.UPDATE_SCROLLBAR, WidgetInfo.QUESTLIST_SCROLLBAR.getId(), WidgetInfo.QUESTLIST_CONTAINER.getId(), newHeight )); }
Example 16
Source File: QuestListPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
private void updateList(QuestContainer questContainer, String filter) { Widget list = client.getWidget(questContainer.widgetInfo); if (list == null) { return; } Collection<QuestWidget> quests = questSet.get(questContainer); if (quests != null && // Check to make sure the list hasn't been rebuild since we were last her // Do this by making sure the list's dynamic children are the same as when we last saw them quests.stream().noneMatch(w -> { Widget codeWidget = w.getQuest(); if (codeWidget == null) { return false; } return list.getChild(codeWidget.getIndex()) == codeWidget; })) { quests = null; } if (quests == null) { // Find all of the widgets that we care about, sorting by their Y value quests = Arrays.stream(list.getDynamicChildren()) .sorted(Comparator.comparing(Widget::getRelativeY)) .filter(w -> !QUEST_HEADERS.contains(w.getText())) .map(w -> new QuestWidget(w, Text.removeTags(w.getText()).toLowerCase())) .collect(Collectors.toList()); questSet.put(questContainer, quests); } // offset because of header int y = 20; for (QuestWidget questInfo : quests) { Widget quest = questInfo.getQuest(); QuestState questState = QuestState.getByColor(quest.getTextColor()); boolean hidden; if (!filter.isEmpty()) { // If searching, show result regardless of filtered state hidden = !questInfo.getTitle().contains(filter); } else { // Otherwise hide if it doesn't match the filter state if (currentFilterState == QuestState.NOT_COMPLETED) { hidden = questState == QuestState.COMPLETE; } else { hidden = currentFilterState != QuestState.ALL && questState != currentFilterState; } } quest.setHidden(hidden); quest.setOriginalY(y); quest.revalidate(); if (!hidden) { y += quest.getHeight(); } } long hiddenCount = quests.stream() .filter(q -> q.getQuest().isHidden()) .count(); list.setOriginalHeight(hiddenCount == quests.size() ? 0 : y); }
Example 17
Source File: QuestListPlugin.java From runelite with BSD 2-Clause "Simplified" License | 4 votes |
private void updateList(QuestContainer questContainer, String filter) { Widget list = client.getWidget(questContainer.widgetInfo); if (list == null) { return; } Collection<QuestWidget> quests = questSet.get(questContainer); if (quests != null) { // Check to make sure the list hasn't been rebuild since we were last her // Do this by making sure the list's dynamic children are the same as when we last saw them if (quests.stream().noneMatch(w -> { Widget codeWidget = w.getQuest(); if (codeWidget == null) { return false; } return list.getChild(codeWidget.getIndex()) == codeWidget; })) { quests = null; } } if (quests == null) { // Find all of the widgets that we care about, sorting by their Y value quests = Arrays.stream(list.getDynamicChildren()) .sorted(Comparator.comparing(Widget::getRelativeY)) .filter(w -> !QUEST_HEADERS.contains(w.getText())) .map(w -> new QuestWidget(w, Text.removeTags(w.getText()).toLowerCase())) .collect(Collectors.toList()); questSet.put(questContainer, quests); } // offset because of header int y = 20; for (QuestWidget questInfo : quests) { Widget quest = questInfo.getQuest(); QuestState questState = QuestState.getByColor(quest.getTextColor()); boolean hidden; if (!filter.isEmpty()) { // If searching, show result regardless of filtered state hidden = !questInfo.getTitle().contains(filter); } else { // Otherwise hide if it doesn't match the filter state if (currentFilterState == QuestState.NOT_COMPLETED) { hidden = questState == QuestState.COMPLETE; } else { hidden = currentFilterState != QuestState.ALL && questState != currentFilterState; } } quest.setHidden(hidden); quest.setOriginalY(y); quest.revalidate(); if (!hidden) { y += quest.getHeight(); } } list.setOriginalHeight(y); }
Example 18
Source File: BronzeManPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
private void updateList(Widget collectionView, String filter) { if (itemEntries == null) { itemEntries = Arrays.stream(collectionView.getDynamicChildren()) .sorted(Comparator.comparing(Widget::getRelativeY)) .collect(Collectors.toList()); } itemEntries.forEach(w -> w.setHidden(true)); Collection<Widget> matchingItems = itemEntries.stream() .filter(w -> w.getName().toLowerCase().contains(filter)) .collect(Collectors.toList()); int x = 0; int y = 0; for (Widget entry : matchingItems) { entry.setHidden(false); entry.setOriginalY(y); entry.setOriginalX(x); entry.revalidate(); x = x + 42; if (x > 210) { x = 0; y = y + 40; } } y += 3; int newHeight = 0; if (collectionView.getScrollHeight() > 0) { newHeight = (collectionView.getScrollY() * y) / collectionView.getScrollHeight(); } collectionView.setScrollHeight(y); collectionView.revalidateScroll(); Widget scrollbar = client.getWidget(COLLECTION_LOG_GROUP_ID, COLLECTION_VIEW_SCROLLBAR); client.runScript( ScriptID.UPDATE_SCROLLBAR, scrollbar.getId(), collectionView.getId(), newHeight ); }
Example 19
Source File: MusicPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
private void updateList(Widget musicList, String filter) { if (tracks == null) { tracks = Arrays.stream(musicList.getDynamicChildren()) .sorted(Comparator.comparing(Widget::getRelativeY)) .collect(Collectors.toList()); } tracks.forEach(w -> w.setHidden(true)); Collection<Widget> relevantTracks = tracks.stream() .filter(w -> w.getText().toLowerCase().contains(filter)) .filter(w -> currentMusicFilter == MusicState.ALL || w.getTextColor() == currentMusicFilter.getColor()) .collect(Collectors.toList()); // Original music track list has a little offset int y = 3; for (Widget track : relevantTracks) { track.setHidden(false); track.setOriginalY(y); track.revalidate(); y += track.getHeight(); } y += 3; int newHeight = 0; if (musicList.getScrollHeight() > 0) { newHeight = (musicList.getScrollY() * y) / musicList.getScrollHeight(); } musicList.setScrollHeight(y); musicList.revalidateScroll(); client.runScript( ScriptID.UPDATE_SCROLLBAR, WidgetInfo.MUSIC_TRACK_SCROLLBAR.getId(), WidgetInfo.MUSIC_TRACK_LIST.getId(), newHeight ); }
Example 20
Source File: WikiSearchChatboxTextInput.java From plugins with GNU General Public License v3.0 | 4 votes |
@Override protected void update() { Widget container = chatboxPanelManager.getContainerWidget(); container.deleteAllChildren(); Widget promptWidget = container.createChild(-1, WidgetType.TEXT); promptWidget.setText(getPrompt()); promptWidget.setTextColor(0x800000); promptWidget.setFontId(getFontID()); promptWidget.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); promptWidget.setOriginalX(0); promptWidget.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); promptWidget.setOriginalY(5); promptWidget.setOriginalHeight(LINE_HEIGHT); promptWidget.setXTextAlignment(WidgetTextAlignment.CENTER); promptWidget.setYTextAlignment(WidgetTextAlignment.CENTER); promptWidget.setWidthMode(WidgetSizeMode.MINUS); promptWidget.revalidate(); buildEdit(0, 5 + LINE_HEIGHT, container.getWidth(), LINE_HEIGHT); Widget separator = container.createChild(-1, WidgetType.LINE); separator.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); separator.setOriginalX(0); separator.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); separator.setOriginalY(4 + (LINE_HEIGHT * 2)); separator.setOriginalHeight(0); separator.setOriginalWidth(16); separator.setWidthMode(WidgetSizeMode.MINUS); separator.revalidate(); for (int i = 0; i < predictions.size(); i++) { String pred = predictions.get(i); int y = 6 + (LINE_HEIGHT * (2 + i)); Widget bg = container.createChild(-1, WidgetType.RECTANGLE); bg.setTextColor(0x4444DD); bg.setFilled(true); bg.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); bg.setOriginalX(1); bg.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); bg.setOriginalY(y); bg.setOriginalHeight(LINE_HEIGHT); bg.setOriginalWidth(16); bg.setWidthMode(WidgetSizeMode.MINUS); bg.revalidate(); bg.setName("<col=ff9040>" + pred); bg.setAction(0, "Open"); bg.setHasListener(true); bg.setOnOpListener((JavaScriptCallback) ev -> search(pred)); Widget text = container.createChild(-1, WidgetType.TEXT); text.setText(pred); text.setFontId(getFontID()); text.setXPositionMode(WidgetPositionMode.ABSOLUTE_CENTER); text.setOriginalX(0); text.setYPositionMode(WidgetPositionMode.ABSOLUTE_TOP); text.setOriginalY(y); text.setOriginalHeight(LINE_HEIGHT); text.setXTextAlignment(WidgetTextAlignment.CENTER); text.setYTextAlignment(WidgetTextAlignment.CENTER); text.setWidthMode(WidgetSizeMode.MINUS); text.revalidate(); if (i == selectedPrediction) { text.setTextColor(0xFFFFFF); } else { bg.setOpacity(255); text.setTextColor(0x000000); bg.setOnMouseRepeatListener((JavaScriptCallback) ev -> text.setTextColor(0xFFFFFF)); bg.setOnMouseLeaveListener((JavaScriptCallback) ev -> text.setTextColor(0x000000)); } } }