Swing/AWT/SWT :: How To Access Elements Of TreeViewer Selection
Dec 27, 2014
I have a hierarchical data structure (Machine, Component, Measurement, Fault are classes) displayed in a TreeViewer. I have added SelectionChanged and DoubleClick listeners, but can't find a way to get to the data stored in the selected instance of the data structure class. For example, the selection is a Measurement which has a String name field. I can see the data in the Element in Debug-Variables, but I can't find any getters to access it. I tried casting the selection as a Measurement but it is an ISelection, or TreeSelection class and it won't accept the cast.
It seems there should be get methods to access the data in the selection, but there aren't, so I'm must be missing something fundamental.
im trying to make a small program where the user enters their selection choice and it prints out the corresponding information. for example, if they choose "3", i want "3. Soup de Jour" to print out
import java.util.Scanner; public class rest { public static void main(String[] args)
I have an addressBook GUI where I have a JList that populates with the contacts names, and once I double click a contacts name I'm wanting to fill the textfields with the contacts corresponding data.
ex) ContactType: Family (enum), Name: Zoidberg, Address: 111 Space Drive, City: New York City, etc...
I've got it to where I select open from the JMenu, it populates the JList, but once I select a contacts name, all the textfields are populated, but only with the contacts name
What am i doing wrong here, and how can i fix it to where it fills out the correct data?
Here's my code so far:
public class AddressBookGUI extends JFrame { private final int WIDTH = 450; private final int HEIGHT = 300; private JLabel currentlySelected; private JTextField contactTypeTextField;
[code]...
I'm certain the logic is messed up near the end where i set all text fields to the index, because no matter what field i want to fill it's at it's going to set it to whatever index I select, but I don't know how to fix it.
I am working on a project (assignment) and i want to be able to click on jlabel and the select border will show (as shown in the image attached) and i used it to resize the jlabel. I tried
@Override public void componentResized(ComponentEvent e) { super.componentResized(e); setPreferredSize(getSize()); } });`
yet is not working. I tried some other code that are not working.
I know how to do single selection, but I would like to do multiple row selection only by using CTRL + click without the option of dragging the mouse to select rows. So the user would have to hit ctrl + click each time to highlight additional rows.
I have a ComboBox I'm using for a cellEditor. The list of items in the comboBox might have colors behind them, which I've managed to render. What I haven't figured out is a good way to keep the color in the cell after the item is selected.I don't' want to have a persistent comboBox in the cell, i only want to see it when editing that cell.
public TableCellEditor getCellEditor(int row, int col) { if (row==theRow && col==theCol) { JComboBox<?> combo = new JComboBox<Object>(getPickListEntries()); combo.setRenderer(new PickListRenderer(combo)); combo.setBorder(BorderFactory.createEmptyBorder()); }
in above BCXXXXXX is the Url of DB and the ones in Square bracket are results of some query.I want to display them in format as in below picture:my code for GUI is as follows
package gui;
/** * Class that takes a query as input from GUI and fetches the required output from Database and display it on GUI. */ import java.sql.*; import java.util.*; import java.awt.event.*; import javax.swing.*; import com.POS;
import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class array { public static void main(String[] args)
[Code] ...
Is there a way to write this, where, alpha is one array.
Write a program that declares an array "alpha" of 50 elements of type "double". Initialize the array so that the first 25 elements are equal to the square of the index variable and the last 25 elements are equal to three times the index variable. Output the array so that 10 elements per line are printed.
If I have an array of 50 integers, can I break that to read in lines of 10?
I'm trying to acces my variable "cost" so when i press a button it prints the cost(for now) but the int value just prints 0
public class Holiday extends JFrame { private RoutinePanel routine; // A panel for routine charge checkboxes private JPanel HolidayPanel; // A panel for non-routine charges
I am new to threads, This is a project about 2048 game to be more accurate, and i want this project to run in this thread that i make in main...
My main:
public class Execute { public static void main(String[] args){ Display d = new Display(); Shell s = new Shell(d); Model m = new Game2048Model(); View ui = new Game2048View(m.getBoardArr(),d,s);
[Code] ....
And the error is:
Exception in thread "Thread-0" org.eclipse.swt.SWTException: Invalid thread access at org.eclipse.swt.SWT.error(Unknown Source) at org.eclipse.swt.SWT.error(Unknown Source) at org.eclipse.swt.SWT.error(Unknown Source) at org.eclipse.swt.widgets.Display.error(Unknown Source) at org.eclipse.swt.widgets.Display.checkDevice(Unknown Source) at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source) at view.Game2048View.run(Game2048View.java:55) //problem at Run at java.lang.Thread.run(Unknown Source)
I am trying to make a 2d array that keeps track of comparison counts. what I have so far works ok but writes over the previous elements with 0. can't seem to find where I am re-initializing the previous elements.
//this is one of my fill sort arrays
public void fillSelectionArray(int index, long countSum) { //rand = new Random( ); //for ( int i = 0; i < listsize; i++) { selectionList[ index -1] = countSum; // }
This program allows the user to select one of each different type of skateboard/accessories items. Then it allows the user to select as many misc items as he or she chooses. The program works fine for the single choices, but I cannot solve the latter part. I have a get method in the misc class that is trying to pull out any selection or selections that were made by the user, but it simply does nothing...
Here's my program, I have four panel classes for each skateboard type, and then I have one class that takes care of adding each panel to the content pane, and calculating the total cost of the item.
Decks Panel Class:
import java.awt.event.*; import javax.swing.*; // The DecksPanel class allows the user to selects a specific type of skateboard public class DecksPanel extends JPanel
However, whenever I run the method, the element that should go last, Zachary, in this case, ends up getting moved to the front for some reason. I'm not sure why.
I tried changing what the first element was initialized to, to the variable i as that would logically work as well, but it ends up missing the first element in the list.
Java Code:
public static void selectionStringAscendingSort (String[] words){ int i, j, first; String temp; for ( i = 1; i < words.length; i++ ) { first = 0; //initialize to subscript of first element for(j = i; j < words.length; j ++){ //locate smallest element between positions 1 and i. if( words[ j ].compareTo(words[ first ]) <0 ) first = j; } temp = words[ first ]; //swap smallest found with element in position i. words[ first ] = words[ i ]; words[ i ] = temp; System.out.println(Arrays.toString(words)); } System.out.println(Arrays.toString(words)); } mh_sh_highlight_all('java');
I'm trying to run a simple code which is to just print out "Hello World", but whenever I run it, a message appears that reads: "Select a way to run Project_1(Which is the Java Project)"
The selections for it are: Java Applet and Java Application.Whenever I click Java Applet it reads: Selection does not contain an applet.When I click Java Application: Selection does not contain a main type.Here is the code which I believe is correct:
package packag_1; public class Num_1 { public static void main(String args){ System.out.println("Hello World"); } }
I need selecting which design pattern to use in my case.
I am creating a list of objects "items" to be presented in a list for the user to choose from, all objects have a title and a check box. Some objects have additional textbox for user input, some objects have additional image for illustration, and some objects have additional textbox and image as well.
I read and saw online videos but not sure if my selection "Factory Design Pattern" is the best match.
I am trying to write a program that graphically displays a selection sort. It needs to sort bars of various heights, and the bars heights are generated from an array of random integers. The program needs to show the bars swapping as they are being sorted, I am having trouble getting the bars to draw, it needs to look like a bar graph. Here is my code thus far (not counting my boiler plate):
import java.util.*; import java.awt.event.*; import javax.swing.*; import javax.swing.Timer; import java.awt.*; import java.util.Random; public class SelectionSortPanel extends JPanel
[Code] ....
Also right now it is giving an error from the compareTo method?
Mike Smith with a customer id of 100 has an account number of 1000 and a balance of $5,000.00 Hank Jones with a customer id of 101 has an account number of 1001 and a balance of $45,000.00 Sam Overstreet with a customer id of 102 has an account number of 1002 and a balance of $45,000.00 Hank Jones with a customer id of 101 has an account number of 1003 and a balance of $48,000.00 and so on .....
I am trying to do a selection sort by the account holders last name. I understand how to do if the Arraylist holds integers, but my arraylist holds multiple fields. I am not allowed to use collections as this is a homework assignment.
here is the Account Class
public class Account implements Comparable<Account> { private int acctNum; private double balance; private Customer cust; // note we are putting a Customer object in the Account clas private static int nextAcct = 1000;// used to keep track of the next available account number
This is a lab for one of my CS classes, and the assignment is to create a randomly filled array (values 10-100) and use these values as the height of an array of rectangles (essentially a bar graph)that will be drawn on a page. After that's done, the code should use the selection sort method to sort the bars least to greatest, being repainted as it's sorted.
I'm receiving no errors, the original draws just fine, and the code sorts the first position and then...it just hangs. Like it's in an infinite loop but I have all of the modifiers in place (I think. I've been staring at this code for three days straight and I don't think I really see it anymore). I've tried talking to my professor and I get that her private life is really busy right now, but she just keeps blowing me off and I don't know what to do. Anyway, done with back story and whining so here's the code.
Rectangle class: import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Rectangle
I cannot use menu selection 4 5 6 7 8 9 10 ... Why NO_EXIT has been declared and used in defining the contents of the map array, rather than just directly using the value 99999 in the map array definition
I don't understand map[][], objectName[] and objectLocation[]
package Assignment; import java.util.Scanner; public class GameWorld { // the map array holds details on which paths lead to which other rooms. NO_EXIT indicates no valid exit. // each element holds the details of all paths leading out from a single-room in the order n ,e, s, w, ne, se, sw, nw private final int NO_EXIT = 99999; // indicates that there is no exit in that direction private int map[][] ={{NO_EXIT,NO_EXIT,NO_EXIT,1},{2,0,NO_EXIT,NO_EXIT},{NO_EXIT,3,1,NO_EXIT},{NO_EXIT,NO_EXIT,NO_EXIT,2}};
I have a question about selection sort. If I had an array of numbers, 1 2 3 4 100 0, and used the selection sort method (below) on the array,would the 0 slowly work it's way down to the end?
I'm making a simple game where there's a 10x10 grid and you can move around a selection box and you can move around. I've been trying to make the green selection box to move around but it won't move! I only have right movement in the code but it won't work so far. Here are the classes that have to do greatly with each other.
I have a ListView with ListCells that are complicated things containing other nodes. I want to turn of ListView selection behavior (so not allow selections) without turning of events to the ListCell nodes in the ListView.