Swing/AWT/SWT :: Layouts - Finding Item Location

Jun 11, 2014

I have a large JPanel which uses a GridBagLayout in which I put other JPanels inside the cells. The main JPanel is then added to a JScrollPane. What I'm looking to provide the user a way to automatically scroll to a particular item in the scrollable area (i.e. each of the child JPanels would represent - let's say a person for argument sake - and an user would like to click a button or bring that JPanel into focus / view.

The JPanels are added within a loop to the grid and references of these JPanels at the moment aren't store in an array or anything, so it's a case of being added and that's it. Also there's the case of where was the object exactly added and also how to have the scrollbar move to the proper focus location (both horizontally and vertically).

View Replies


ADVERTISEMENT

JSF :: Finding Index Of Entry In ArrayList - Select Item

Oct 2, 2014

I have a JSF application with this code in the xhtml page:

<h:selectOneListbox id="selectProduct" size="10" style="width:10em; font-family:monospace" value="#{mybean.product}">
<f:selectItems value="#{mybean.products}" />
</h:selectOneListbox>

and the corresponding snippets of the Java code are:

// Class member variables
// ...
private String product;
private ArrayList<String> productValues;
private ArrayList<String> productLabels;
private SelectItem[] products;
// ... Various properties etc.
public String getLocation() { // Displayed on a page

[code]....

Most of this works correctly using only ArrayList SelectItem products without the two ArrayList and the separate SelectItem[], and the values and labels are put directly into products here. The menu works and I can select an item. However, I am unable to find the correct method for finding the index in the submit method,namely:

public void submit(ActionEvent e) {
showProduct = true;
prodNum = products.indexOf(product); // --- Here is the problem!
updateProduct();
}

which has not been changed here. In spite of trying out various ideas, prodNum always returns with -1, which means it cannot find the index of the selected product, where product is a String. Everything else seems to work correctly, and products.get(prodNum).getLabel() works if I manually give prodNum a valid index, but because it's -1 it fails.

View Replies View Related

Swing/AWT/SWT :: Netbeans GUI Creator With Border And Gridbag Layouts?

Jan 6, 2014

I'm trying to use netbeans GUI creator to create a chessprogram. However, the default "freeflow" layout is very difficult to work with. However, when I switch the layout to gridbag or border layout, I can't figure out really how to do anything. I don't know how to resize or position elements. Any good set of tutorials for using netbeans GUI creator with non standard layouts?

(I originally used absolute layout, which I can easily add and position elements in, but which I abandoned because i want the chessboard squares to resize when the window changes size).

View Replies View Related

Swing/AWT/SWT :: Change Location Of Component Using Grid Bag Layout

Jun 13, 2014

How to change the location of a grid bag positioned component after it's already been added to the layout earlier?

Example is if I want component 1 to change from row 1 to row 2.

View Replies View Related

Swing/AWT/SWT :: Finding Strings In A JTable

Jan 31, 2015

I am having a problem finding string objects in a jTable. I use setValueAt() to write string variables into a jTable.

I can then use getValueAt() to search to find any of those strings. All works fine until I edit an entry in the table. Then I can never find that string again.

In fact, if I just click in the cell type a character, then delete that character, something changes. The contents of the cell look the same but the search for it doesn't find it.

For example if I have a string "xyz" that was written in a cell. If I set the search value, "a=xyz", and "b=getValueAt(some cell)".

Then at the compare:

if(a==b) I can hover over a and b and I see that;
a = (java.lang.String) xyz

and

b = (java.lang.String) xyz

[note I am using NetBeans to do this]

after the compare, the true path is taken .

If I then click in the cell then click out and try the same compare, everything is exactly the same including what gets reported when I hover. But the false path is taken at the "if".

View Replies View Related

Swing/AWT/SWT :: GetSelectedItem Isn't Getting Selected Item

Oct 9, 2014

I was wanting to select an item in a comboBox and display it in a text field but all it's doing at the minute is retrieving the first item in the comboBox and placing that in the txt field

String value = (String) comboBoxEnv.getSelectedItem().toString();
if(comboBoxEnv.getSelectedItem()!= null){
txtTo.setText(value);

View Replies View Related

Swing/AWT/SWT :: How To Pass Value And Add Item Into Combobox

Nov 15, 2014

createConnection();
try{
String str = "select * from stocks";
stmt = conn.prepareStatement(str);
ResultSet rs = stmt.executeQuery();

[Code] .....

I have this code in my another package , i want to call it in other package , but i dunno how to do that.

View Replies View Related

Swing/AWT/SWT :: Finding Out Old Split Times For Stopwatch

Mar 17, 2014

I am working on splitting a time for a stopwatch and printing it on console,

String splitTimesStr = "";
currentTime = System.currentTimeMillis();
long secsTaken = (currentTime - startTime) / 1000;
long split = secsTaken - startTime;

[Code] ...

it produces
Split time: 00:02
Split time: 00:05
Split time: 00:08
Split time: 00:09

when it should produce
Split time: 00:02
Split time: 00:03
Split time: 00:03
Split time: 00:01

its printing out the time on stopwatch rather than: time on stopwatch - old time, how would i code this?

View Replies View Related

Swing/AWT/SWT :: Changing Color Of JList Item

Oct 23, 2014

is there a good way to change the color of a JList item that isn't selected? I'm throwing my hand at building a client/server chat app and on the client side, I need to highlight the name of the person (which is in a JList) who has sent a message to the client GUI.

View Replies View Related

Swing/AWT/SWT :: Create A Sub Menu For Every List Item In A Jlist

Oct 8, 2014

I would like to create a sub menu for every list item in a Jlist. I need the UI like avast interface. If we hover over an list item, its sub menu should be shown. I attempted to put an sub menu but didn't work. Is this possible in Swing?

View Replies View Related

Swing/AWT/SWT :: Way To Search Item Objects Inside A Jcombobox?

Apr 17, 2014

I am developing a java based software connected with a mysql database. I have an Item table in my database. I created a bean class which can keep all item data with it and. Then I loaded each Item data in to its object and fill a Jcombobox. Now I want to search with Item name and get all Item data when selecting that item. I have overidden the toString method to Item name in that class. Is there any way to search my Item objects inside a jcombobox?

View Replies View Related

Calculator Grid Layouts

Aug 19, 2014

So I'm making a calculator using JFrame and that stuff and I need figuring out the GridLayouts. I'm not doing this for homework or anything just for fun. I don't need all the grid layouts.

View Replies View Related

Swing/AWT/SWT :: Making Two JComboboxes To Be In Sync When One Selects Item From Dropdownlist?

Jan 17, 2015

basically I would like to know how to to the following Java. Example... Say I have one JComboBox, and it is populated with 10 items which reads from a text file ("apple","banana","kiwi","orange","grape fruit"), and the other JComboBox holds the price ($1,$2,$4, etc etc...you get the drift).

How do I make in such a way when I select for example banana from the JCombobox that it syncs the other JCombox to the correct price?

Basically syncing the two JCombobox so that you do not need to select the price yourself - it does it automatically for you.

View Replies View Related

Swing/AWT/SWT :: Popup Menu Will Become Invisible Does Not Capture Selected Value / Item

Nov 1, 2014

I have a combobox with this PopupMenuListener. All works fine, except that the popupMenuWillBecomeInvisible method does not capture the selection made and neither does it show the selection.

PopupMenuListener pmlMqMessagePurged = new PopupMenuListener() {
@SuppressWarnings("unchecked")
public void popupMenuWillBecomeVisible(PopupMenuEvent arg0) {
try {
JdbcSqlServerDataSource ds = new JdbcSqlServerDataSource(
DbConnectionURL.UToolDbHostName, 0,

[Code] .....

The popupMenuWillBecomeInvisible does fire but the System.out.println() returns 'nul'l as answer to the value i have selected from the combobox.

View Replies View Related

JavaFX 2.0 :: How To Combine FXML Layouts Without Code

Jan 4, 2015

recently I've started using javafx and I wonder if there a way to combine FXML layouts without Java code, like insert smaller layout into bigger one?

View Replies View Related

JavaFX 2.0 :: FXML Schema - Creating Dynamic Layouts

Jan 15, 2015

I need to create dynamic Layouts that are created from java source code, using JAXB. As FXML does not have a schema, this gets me in trouble.

Scene Builder cannot be used for dynamic Layouts, but if there really is no schema I could use, maybe someone knows how Scene Builder generates the fxml files.

View Replies View Related

Specifying File Location?

Mar 10, 2014

How to specify the file location. One way would be

PrintWriter outputFile=new PrintWriter("A:PriceList.txt");

My problem occurs when I try to specify a file location as show below

//Open an output file that appends data and does not delete it
FileWriter append_data=new FileWriter("C:hello.txt",true);
//Make a file that cvan print data into it
PrintWriter outputfile=new PrintWriter(append_data);

Apparently, I believe this is not the right way to set my own path for the file... How can I specify my file path.

One more question would be that suppose I want to specify the file location on Desktop. What the format for that?

View Replies View Related

JSP :: How To Mark The Location List On Map

Sep 16, 2014

I'm trying to mark a list of locations on a map. probem is how to get this list object inside javascript? This is the JSP

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

[Code] ....

View Replies View Related

How To Specify Location Of Opened Window

May 8, 2014

I am writing a small app to automate some actions on my computer this requires me to open an application and click on a button I am using

Process child0 = Runtime.getRuntime().exec("/home/user/application");

to do this. The problem is every time it opens at a different lcation on the screen so i cannot click on it using the robot class due to x,y coordinates being different every time. with selenium you can use .setlocation(x,y) method but how can this be done for other applications.

View Replies View Related

How To Delete Files From Ftp Location

Jan 28, 2014

how to delete the files from ftp location

View Replies View Related

Displaying Memory Location Instead Of Name?

Jan 28, 2014

Aatrox
Champions@3622e177
Champions@4805e9f1
Champions@57e40274
Champions@354124d6
Champions@262f4813
Champions@64f01d52
Frozen Heart
Randuin's Omen

As you can see instead of displaying the champion name it is displaying the memory location and I do not know how to fix it.

class Champions
{
String name;
Champions [] weak = new Champions [3];
Champions [] strong = new Champions [3];
String [] items = new String [3];
public static void main (String [] args)
{

[Code]...

View Replies View Related

Copy A Exe File From One Location To Another?

Aug 1, 2014

I'm trying to copy a exe file from one location to another. It seems simple, but I have failed to find anything about it besides coping the contents in txt files, but that does nothing for executable.

View Replies View Related

SOP Returning Memory Location?

Jul 15, 2014

For some reason my code returns the memory address of the array when its a print statement with a string, but it works fine when its in a separate print statement all by itself. Why? Do I need to create a toString method that converts a char array to a String to something? The reason why I ask that is becuase on Eclipse line 10 has a warning stating "Must explicitly convert char[] to a String".

public class Ex {
private String word;
public Ex(String word) {
this.word = word;
}
public char[] Display(){
char[] wordChars = this.word.toCharArray();
return wordChars;

[Code] .....

Result:

Hello world
The word is: [C@1db9742

I also tried this, knowing that it's a long shot, but that didnt do anything...

public String toString(){
Ex ex = new Ex(this.word);
char[] word = ex.Display();
String updated = word.toString();//counter intuitive?
return updated;
}

View Replies View Related

InputStreamReader Looking For File Location

Apr 26, 2014

The file (let's call it file.txt) is on the C: of my machine. I'm using :

System.out.print("Where is the file?: "); BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

And looking for the user to enter the location of the file in the console. How do I (the user) enter the path to the file in the console. I have tried everything... "C:file.txt", C:file.txt, and a million other combinations. Nothing seems to work. How does the console expect the file path to be written so it knows how to pick up the file?

View Replies View Related

Getting Char At A Location In String

Oct 21, 2014

I found a fun program online and something so simple is giving me an issue. I c++ it is pretty simple fix, I can just call the strings location like an array. In java this is not the case. So far i have tried:

myString.charAt();
myString.indexOf();

There are a few other I found on google but I forget at the moment. I am just trying to close the gap on a string. It was a full sentence and I used replaceAll a few times to get several words I didn't want in the file out.

View Replies View Related

Displaying Location Of Array Index

Feb 9, 2014

My project was to create an array holding 10 integers and populate the array with 10 random numbers. Then ask the user to guess the number. Prompt the user with a while loop if their input is out of range. Determine if the users number is in the array, and display which index location the number is in. I got most of the code done but am having trouble displaying the index location.

import javax.swing.*;
public class Homework4 {
public static void main(String[] args) {
int[] numarray = new int [10];
char repeatcode = 'y';

[code]....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved