Swing/AWT/SWT :: JTable Using CTRL / Click For Multiple Row Selection

Jul 6, 2014

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.

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: JTable - Cell Keeps Focus After Clear Selection

May 7, 2014

I'm having a small problem using a jTable.

After calling the .clearSelection() methode of the table object, the cell clicked in when selecting the table row, keeps it's focus.

How do I remove the focus of the cell?

View Replies View Related

Swing/AWT/SWT :: Color To Persist In Cell Of Jtable After ComboBox Selection

May 29, 2014

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());
}

[code]....

View Replies View Related

How To Disable Ctrl Select Multiple Entries In A Dialog

Feb 18, 2015

I am using the following code to create a dialog , but my need is user can select only 1 entry . Using this code

can select multiple items by pressing Ctrl ... How it can avoid ... My current code is

Java Code:

SecureCloudStorage_Service service = new SecureCloudStorage_Service();
List<String> files = service.getSecureCloudStoragePort().listFiles();
SelectFileDialog dialog = new SelectFileDialog(this.getFrame(),true,files);
Toolkit toolkit = Toolkit.getDefaultToolkit();
Dimension screenSize = toolkit.getScreenSize();
int x = (screenSize.width - dialog.getWidth()) / 2;
int y = (screenSize.height - dialog.getHeight()) / 2;
dialog.setLocation(x, y);
dialog.setVisible(true); mh_sh_highlight_all('java');

View Replies View Related

Swing/AWT/SWT :: Listener Called Multiple Times On Single Click?

Jan 30, 2015

I have the following listener on a tableset of names:

ListSelectionListener singleListener=new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
int row=e.getFirstIndex();
if (row==previousRow) {
row=-1;

[Code] .....

The println shows that getValueIsAdjusting is called 4 times when I click a single selection from the list. Is this normal behavior? If so how do I determine which call to really use. If not, where can I look to see why it is being called 4 times on a single click?

View Replies View Related

JSF :: Multiple Tool Tips To Be Displayed On Same Page When Click Multiple Image Links

Dec 8, 2014

I have i am trying to implement tooltip through javascript, like when we click on an image link tooltip should be displayed and it should have close button/ close image to close that tooltip.like the same way i will have multiple images on page, when ever i click on the images all tooltips should be displayed on the page when ever i want to close that then only it should close through close button on tooltip.can we do it through java script or will go for jquery.

View Replies View Related

Using Multiple Selection Choices?

May 28, 2014

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

[Code]....

View Replies View Related

Create JTable When Click On New On Menu Bar

Dec 5, 2014

I want to create a Jtable when i click on "new" on the menu bar,but if i click on it, i still not see the table.Here is the code:

package mestint
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTable;
import javax.swing.border.BevelBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.*;

[code].....

View Replies View Related

JavaFX 2.0 :: Implement Multiple Selection Model?

Jul 16, 2014

I have tried to implement MultipleSelectionModel with mostly success in TreeView, but definitely with quirks. I've looked at the implementation in TreeView and it's off putting to say the least. Hopefully it doesn't need to be that complicated. For now, all I need is it to handle SINGLE SELECTION, but it needs to be solid. I've put in a lot of println's to see what gets called. Most don't seem to be called. I'm relying on TreeView to look up the object being selected, I'm not sure if that's appropriate. The internal implementation seems to worry about tree state a lot.
 
It baffles me as to why there isn't a base class from which to extend or reuse? I'm doing this so I can delay a selection (make it vetoable), also to handle drag/drop more cleanly (so target won't move because of drag action).
 
    private class VSelectionModel extends MultipleSelectionModel {
        List<Integer> baseSelectedIndexes = new ArrayList<>();
        ObservableList<Integer> selectedIndexes = FXCollections.observableList(baseSelectedIndexes);
        List<Object> baseItems = new ArrayList<>();
        ObservableList items = FXCollections.observableList(baseItems);
 
 [Code] ....

View Replies View Related

Jump Games - Put Images Into JTable For Organization And Character Selection Purposes

Jul 14, 2014

HTML Code:

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.border.Border;
import javax.imageio.ImageIO;
public class Main extends JApplet implements Runnable, ActionListener {

[Code] .....

I am making a game and there are two problems that I have and can't seem to solve. I never made on applet before, and I'm not good with the swing components, but I am decent programming in Java.

Problem #1: the start button is in the JPanel, I don't want that, I want it to be above the JPanel.
Problem #2: I want to put images in to a JTable for organization and character selection purposes, but I keep on getting a string. Do I have to use an ImageIcon to get it to work, or does it matter?

In case you were wonder what kind of game I'm making, I'm making one of those jump games where you jump on platforms and try to go as high as you can without missing a platform. There is going to be character selection for the jumper, and the jumpers are going to be food, like a potato, a banana, a strawberry, etc.

View Replies View Related

How To Fill Contents To Jtable Dynamically On Button Click

Dec 17, 2014

this is my code

private void showresultsActionPerformed(java.awt.event.ActionEv ent evt) {
Object dbs=db.getSelectedItem();
Object colls=coll.getSelectedItem();
String distances=distance.getText();
String skillss=skills.getText();
DefaultTableModel tb=new DefaultTableModel();
MongoClient m = null;

[Code]...

i have added the columns but how could i show up the change??

View Replies View Related

JavaFX 2.0 :: Cannot Set Divider Positions In Multiple Splitpanes At One Button Click

May 29, 2014

I have a problem with setting multiple splitpane divider positions. In my application there are multiple splitpanes (one inheriting the other). When resizing the scene (e.g. by double-click or mouse drag) the divider position default values (as set in the FXML) are not taken into account and the application therefore incorrectly displays the divider positions. For example, one pane that should be only 100px wide now spans over the half of the application. Its not very nice because one has to readjust the divider positions manually each time after resizing the window. At the same time, I dont want to set maximum values to keep the layout flexible.
 
I tried to solve this by adjusting the divider positions at a button click event (..setOnAction(new EventHandler<ActionEvent>()...) but when I click it only one splitpane at a time is adjusted. As I have 3 splitpanes I have to click the button 3 times to get all the adjustments. I am not sure whether this is because the click event is consumed after the first adjustment and subsequent repaint of the scene?
 
A sample code of what I have now would look like this:
 
adjustButton.setOnAction(new EventHandler<ActionEvent>(){
public void handle(ActionEvent e){
     pane1.setDividerPositions(0.9);
     pane2.setDividerPositions(0.8);
     pane3.setDividerPositions(0,075);
      }
});

View Replies View Related

Multiple Rows Into Database From JTable

Apr 12, 2014

How to insert multiple rows into a database from a jtable and also retrive the same details from database and show it in a jtable.

View Replies View Related

How To Use CTRL-D To Terminate Program (sentinel Value)

Mar 1, 2014

how to use the CTRL-D in my program. The program records the amount of times a positive and negative integer is typed. When the user decides to end the program, they will use the CTRL-D to terminate the program. After the button combination has been pressed, I spit out to the user the results. The problem is when I press CTRL-D the program just terminates and I can't even get it to read the next line of code. ....

View Replies View Related

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.

View Replies View Related

Swing/AWT/SWT :: How To Fill Text Fields With Selection From JList

May 2, 2015

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

ex) Name: Zoidberg, Address: Zoidberg, City: Zoidberg, etc....

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.

View Replies View Related

Swing/AWT/SWT :: How To Reduce Jlabel With Selection Border Around It At Run Time

Sep 14, 2014

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.

View Replies View Related

Swing/AWT/SWT :: How To Change Action After 1st JButton Click

Aug 3, 2014

I am relatively new to java. . I cannot...(actually do not know) how to change the actionlistener (actionPerformed) after the second click in an array of JButtons. This is how the program performs right now.

On the 1st click on the grid, the border of the button clicked will change to 'blue' and another button will change its boarder to 'red'. on the next click the same action is performed.

What I need is to change action when the 'red' bordered button is clicked, lets say change the color of the buttons from the 'red' to the 'blue' buttons.(x 3 buttons).

The logic about how to perform the final result I think I can do on my own but my problem is how to change the action when the red bordered button is clicked.

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;

[Code] .....

View Replies View Related

Swing/AWT/SWT :: Action Listener Does Not Work With Button Click

Feb 22, 2015

I have buttons created on a frame and then I register the listener from a controller in a controller-view relationship.

When I click the button on the face, the action never executes for some reason. I thought maybe there was a problem registering the listener but I can call the buttons doclick() method and it executes as it should. Perhaps I'm overlooking something really obvious here but I can't see it.

btnEight = new JButton( "8" );
// btnEight.addActionListener( controller );
btnEight.setBounds( 212, 90, 41, 23 );
frame.getContentPane().add( btnEight );

and then I add the listener

public void setController( ActionListener theController ) {
Component[] components = frame.getContentPane().getComponents();
for ( Component component : components ) {
if ( component instanceof JButton ) {
JButton button = ( JButton ) component;
button.addActionListener( theController );
}
}

again, when i click the button nothing happens. but if i add the following code

btnEight.doclick()

the actionPerformed invokes in theController as I intended.

You can see the entire project on GitHub so you can see the full context. The controller class contains the listener and the view class contains the buttons.

View Replies View Related

Swing/AWT/SWT :: Unable To Show Image When Click On Button

Oct 21, 2014

I've recently decided to learn Java on my own using internet material such as forums, blogs and you tube. Ive never programed before but through some research I concluded that Java is going to be on the mid spectrum of difficulty as far as verbiage goes. I ma in no way implying that Java is easy but instead closer to spoken English that c++ if my research is correct. So here is my attempt at a basic program where I click a button and it will make an image appear. Not sure where Im falling short

package clicktoimage;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Clicktoimage extends JFrame {
private JLabel label;
private ImageIcon image;

[Code]...

View Replies View Related

Swing/AWT/SWT :: How To Update / Refresh JPanel On JButton Click

Apr 14, 2015

I am trying to plot a graph and graph should display when JButton is clicked. To create data set, I am taking some value through JTextField and then created a chart and plotted it. I've got a problems: the chart doesn't refresh/update when I change the text field value.

public class Test2 extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
private JPanel contentPane;
private ChartPanel chartPanel;
private JTextField textField_1;
double a;

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Running Exe On Click Of Button Packaged As Resource In Jar

Mar 17, 2015

So this is my package structure:

Projectsrccom.mypackageMyClass.java
resourcesicon.pngmyexe.exe
Right now I have to run the exe like this : - It has hardcoded the path of the exe :command = "cmd /c start /b cmd.exe /K "cd " + outputFolderPath
+ " && C:myfoldermyexe.exe " + "param1=value1 param2=value2 " ;

Process p = Runtime.getRuntime().exec(command); This works fine. But, When I package it as a jar I want to give a relative path to my resources folder. How can I make this happen?

I tried:File f = new File("resources/myexe.exe");
String path = f.getAbsolutePath();
but this "path" did not work.

Another way would be to extract the exe to a local path on the server, but there is a possibility that I could face permission issues.

View Replies View Related

Swing/AWT/SWT :: CardLayout Switching Panels On Click Of Button

Jun 19, 2014

I am trying to switch panel on click of a button but nothing is happening.

package game.uno.swings;
import java.awt.EventQueue;
import javax.swing.JFrame;
import java.awt.CardLayout;
import javax.swing.JPanel;

[Code] ....

I read the oracle doc example, i understand the concept but still nothing is happening on show,first ,next method of CardLayout in ActionPerformed. Code is highlighted where I am facing problem.

View Replies View Related

Swing/AWT/SWT :: Add Buttons Dynamically In A New Jpanel On Click Of A Button

Jun 20, 2014

Am trying to add buttons dynamically in a new Jpanel on click of a button. i am getting new Jpanel but not able to see the buttons.

btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if((!(playerFirst.getText().equalsIgnoreCase("") ||playerSecond.getText().equalsIgnoreCase(""))&&(!playerFirst.getText().equalsIgnoreCase(playerSecond.getText())) ) ){
//unoGameController.playGame(playerFirst.getText(), playerSecond.getText());
CardLayout cardLayout=(CardLayout)(frmUno.getContentPane().getLayout());

[Code]...

prepareHandsForGuiCode is

public UNODeckMain prepareHandsForGui(UNODeckMain unoDeckMain){
JButton[] btnArr =new JButton[50];
for(int i=0;i<50;i++){
btnArr[i]=new JButton("hi");
panel_player1.add(btnArr[i]);
}return unoDeckMain; }

Am i skipping something ?

View Replies View Related

Swing/AWT/SWT :: Changing Panel In Jframe On Click Of A Button

Jun 22, 2014

I want to switch panel on click of a button and code for switching panels is written in update method (Which gets called from notify observer of another class as part of Observer pattern.

unoGameController.playGame(playerFirst.getText(), playerSecond.getText());

playGame in Panel 1 of class 1 calls another class (class 2)and data comes in update method of class 1(Observer interface).

Now for switching panels code is in gameControllerDataProcessing . I am not able to switch the panels when this functionality runs.

However if i dont call the unoGameController.playGame(playerFirst.getText(), playerSecond.getText() and directly call the update method or directly write the switching panel code . then it works fine.

btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if((!(playerFirst.getText().equalsIgnoreCase("") ||playerSecond.getText().equalsIgnoreCase(""))&&(!playerFirst.getText().equalsIgnoreCase(playerSecond.getText())) ) ){
unoGameController.playGame(playerFirst.getText(), playerSecond.getText());

[Code] .....

View Replies View Related

Swing/AWT/SWT :: Wait For Mouse Click Before Running While Loop

Oct 7, 2013

I've got the game working just fine, but I don't like the way it starts playing the second you hit the "Run Last Class" button in Eclipse, and would really like to have the game start, then wait for the user to click a button before running the core WHILE loop. Everything is implemented in a single class, and here is the playGame method that starts the ball moving:

private void playGame(){
while (!gameover){
moveBall();
checkForCollisions();
}

All I want to do is pause before the WHILE loop until the users clicks the mouse button, nothing fancier than that! I've done quite a bit of reading, and it looks like ActionEvent may be the way to go, but I'm not clear on how to use it correctly in this scenario.

View Replies View Related







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