Editable JComboBox and left display
My JComboBox is editable and when a selection is made the selection is shown. When the value (String) is to large for the field, only the final part of the String is shown.
I tried to set or move the caret position to 0 for the related JTextField obtained by
((JTextField) (TransferComboBox.getEditor()).getEditorComponent();).
I tried as well to left align by doing
JLabel jl = (JLabel) TransferComboBox.getRenderer();
jl.setHorizontalAlignment(SwingConstants.LEFT);
Nothing worked.
Where did you set the caret position? You will need to do it every time you select something from the list. I tried the following and it worked:
JComboBox cb=new JComboBox();
cb.setEditable(true);
cb.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
JComboBox cb=(JComboBox)e.getSource();
JTextField editor=(JTextField)cb.getEditor().getEditorComponent();
editor.setCaretPosition(0);
getContentPane().add(cb, BorderLayout.NORTH);
cb.addItem(longString1);
cb.addItem(longString2);
Similar Messages
-
Using KeyMap in Editable JComboBoxes and JTable
I am using Keymapping for JTextFields. It works fine ! I am interested in extending the keymap feature to JComboBoxes and JTable.
if you want to do the keymapping inside the editable component of the combobox or the table, make sure you apply it on the editor component.e.g. comboBox.getEditor().getEditorComponent() and table.getCellEditor().getTableCellEditorComponent().
-
There is a small white light in the retina display on my ipad 3. Is this a dead pixel/light leak and how do I fix it? (Located at the bottom left side between home button and left corner)
Maybe this will show up better in green.
-
ORacle 10g - Display database data, edit it and write back to database
Hi!
I would like to find an application which allows me to read data from a database (object-relational database schema), display it visually, make it editable and offer me the opportunity to write changed data to the database.
Does anyone have experience with Visio or some other tool?
TimoHi,
thank you for your replies!
I am not sure if the mentioned applications really are what I am looking for. It seems to me that they are developing tools rather than presentation and editing tools. I don't want to present or change the schema but the data of the database. The objects in my database are business processes and the user should be able to get all the information he/she desires about them, be able to edit them and also to create new processes. It's more like a GUI for end users.
Timo -
I encounter a strange problem with the column chart in PowerPoint 2010 (or maybe the combinations of Excel 2010 and PowerPoint 2010). The directions of the arrows in Series Lines display in the reverse direction between the edit mode and the Slide
Show.
Here are the steps to recreate this phenomenon:
Open a new Presentation > Insert > Chart > Column > Stacked Column > Press OK
Excel pops up. Close Excel and return to PowerPoint.
Click on the chart > Layout > Lines > Select "Series Lines"
Right click on the lines and select "Format Series Lines"
Line Style > End Type > Choose "Stealth Arrow"
(well, could not paste an image yet... arrows display like <--)
When F5 was pressed (Slide Show)
(well, could not paste an image yet... arrows display like -->)
If you look closely at the directions of the arrows, they are display in the reverse directions. Anyone is having the same issue?
Thanks!
ChenHi,
Based on my tested both of the PowerPoint 2010 and
PowerPoint 2013, I reproduced the issue in my environment.
If I choose the End Type> Stealth Arrow(---->), it showed "<-----" in "Normal mode", but showed the "---->" in "Slide Show mode". It seems display correctly in "Slide Show mode".
We have definitely heard your frustration, and we're thinking about ways to make this scenario work better for our customers. Please wait for the issue is fixed. Thanks.
Regards,
George Zhao
TechNet Community Support -
Not Updating the Values in the JComboBox and JTable
Hi Friends
In my program i hava Two JComboBox and One JTable. I Update the ComboBox with different field on A Table. and then Display a list of record in the JTable.
It is Displaying the Values in the Begining But when i try to Select the Next Item in the ComboBox it is not Updating the Records Eeither to JComboBox or JTable.
MY CODE is this
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.DefaultComboBoxModel.*;
import javax.swing.table.*;
import java.sql.*;
import java.util.*;
public class SearchBook extends JDialog implements ActionListener
private JComboBox comboCategory,comboAuthor;
private JSplitPane splitpane;
private JTable table;
private JToolBar toolBar;
private JButton btnclose, btncancel;
private JPanel panel1,panel2,panel3,panel4;
private JLabel lblCategory,lblAuthor;
private Container c;
//DefaultTableModel model;
Statement st;
ResultSet rs;
Vector v = new Vector();
public SearchBook (Connection con)
// Property for JDialog
setTitle("Search Books");
setLocation(40,110);
setModal(true);
setSize(750,450);
// Creating ToolBar Button
btnclose = new JButton(new ImageIcon("Images/export.gif"));
btnclose.addActionListener(this);
// Creating Tool Bar
toolBar = new JToolBar();
toolBar.add(btnclose);
try
st=con.createStatement();
rs =st.executeQuery("SELECT BCat from Books Group By Books.BCat");
while(rs.next())
v.add(rs.getString(1));
catch(SQLException ex)
System.out.println("Error");
panel1= new JPanel();
panel1.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
lblCategory = new JLabel("Category:");
lblCategory.setHorizontalAlignment (JTextField.CENTER);
c.gridx=2;
c.gridy=2;
panel1.add(lblCategory,c);
comboCategory = new JComboBox(v);
comboCategory.addActionListener(this);
c.ipadx=20;
c.gridx=3;
c.gridwidth=1;
c.gridy=2;
panel1.add(comboCategory,c);
lblAuthor = new JLabel("Author/Publisher:");
c.gridwidth=2;
c.gridx=1;
c.gridy=4;
panel1.add(lblAuthor,c);
lblAuthor.setHorizontalAlignment (JTextField.LEFT);
comboAuthor = new JComboBox();
comboAuthor.addActionListener(this);
c.insets= new Insets(20,0,0,0);
c.ipadx=20;
c.gridx=3;
c.gridy=4;
panel1.add(comboAuthor,c);
comboAuthor.setBounds (125, 165, 175, 25);
table = new JTable();
JScrollPane scrollpane = new JScrollPane(table);
//panel2 = new JPanel();
//panel2.add(scrollpane);
splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,panel1,scrollpane);
splitpane.setDividerSize(15);
splitpane.setDividerLocation(190);
getContentPane().add(toolBar,BorderLayout.NORTH);
getContentPane().add(splitpane);
public void actionPerformed(ActionEvent ae)
Object obj= ae.getSource();
if(obj==comboCategory)
String selecteditem = (String)comboCategory.getSelectedItem();
displayAuthor(selecteditem);
System.out.println("Selected Item"+selecteditem);
else if(obj==btnclose)
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
else if(obj==comboAuthor)
String selecteditem1 = (String)comboAuthor.getSelectedItem();
displayavailablity(selecteditem1);
//System.out.println("Selected Item"+selecteditem1);
System.out.println("Selected Author"+selecteditem1);
private void displayAuthor(String selecteditem)
try
{ Vector data = new Vector();
rs= st.executeQuery("SELECT BAuthorandPublisher FROM Books where BCat='" + selecteditem + "' Group By Books.BAuthorandPublisher");
System.out.println("Executing");
while(rs.next())
data.add(rs.getString(1));
//((DefaultComboBoxModel)comboAuthor.getModel()).setVectorData(data);
comboAuthor.setModel(new DefaultComboBoxModel(data));
catch(SQLException ex)
System.out.println("ERROR");
private void displayavailablity(String selecteditem1)
try
Vector columnNames = new Vector();
Vector data1 = new Vector();
rs= st.executeQuery("SELECT * FROM Books where BAuthorandPublisher='" + selecteditem1 +"'");
ResultSetMetaData md= rs.getMetaData();
int columns =md.getColumnCount();
String booktblheading[]={"Book ID","Book NAME","BOOK AUTHOR/PUBLISHER","REFRENCE","CATEGORY"};
for(int i=1; i<= booktblheading.length;i++)
columnNames.addElement(booktblheading[i-1]);
while(rs.next())
Vector row = new Vector(columns);
for(int i=1;i<=columns;i++)
row.addElement(rs.getObject(i));
data1.addElement(row);
//System.out.println("data is:"+data);
((DefaultTableModel)table.getModel()).setDataVector(data1,columnNames);
//DefaultTableModel model = new DefaultTableModel(data1,columnNames);
//table.setModel(model);
rs.close();
st.close();
catch(SQLException ex)
}Please check my code and give me some Better Solution
Thank youYou already have a posting on this topic:
http://forum.java.sun.com/thread.jspa?threadID=5143235 -
DWCS3 Template Editable Regions and Editable Attributes?
Using DWCS3 / WIN XP
New to DWCS3 and templates AND CSS but I'm managing I
think....
QUESTION:
is there a way to allow the end user to edit the content of
an editable region and also the attributes of the cell in which the
editable region resides?
SITUATION:
I'm building templates for pages (styled with external CSS)
that will be editable by the end user via Contribute. I've put
editable and repeating regions (imgs and navigation menus) in
particular tds and would like the end user to be able to change the
color of the background of the cells in which the editable regions
reside.....
Of course I get "cannot place an editable region inside an
editable region" .......understandable...i've read more than a few
help/tutorial docs......
So I thought that I should click the tag selector for that td
and Make Attribute Editable.....
That's not working either....I know I'm missing something
because I haven't used DW in years and I'm just not getting some
big picture logic......
EXAMPLE: In the .html page attached for viewing, the upper
left image SRC is in an editable region. I would like the
background color of the cell it is in to be editable as well. Same
goes for the background color of the left navigation menu which
resides in a nested table by the way...........but i still want the
color to be editable.....
Thanks so much for any help you can give....
CoCo
PAGE based on Template:
http://www.methods.com/npsbweb/schools/NPSB_school_lev_1.html
CSS and TEMPLATE CODE: BELOW
@charset "utf-8";
p {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10pt;
font-weight: normal;
h1 {
font-size: 16px;
color: #999966;
font-family: "Times New Roman", Times, serif;
h2 {
font-size: 18px;
color: #333366;
font-family: Verdana, Arial, Helvetica, sans-serif;
text-align: center;
margin: 0px;
h3 {
font-size: 14px;
color: #333366;
font-family: Verdana, Arial, Helvetica, sans-serif;
h4 {
font-size: 12pt;
color: #999966;
font-family: "Times New Roman", Times, serif;
text-align: center;
letter-spacing: 1px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 5px;
margin-left: 0px;
h5 {
font-size: 12px;
color: #999966;
font-family: Verdana, Arial, Helvetica, sans-serif;
h6 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 8pt;
color: #333366;
text-align: center;
#tdDivideLineTop {
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #999966;
height: 2px;
#tdMainImgTop {
text-align: center;
vertical-align: middle;
height: 175px;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #D5D5AA;
background-color: #ffffff;
border-right-width: 1px;
border-right-style: solid;
border-right-color: #D5D5AA;
#tdTitleRow {
height: 175px;
vertical-align: middle;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #D5D5AA;
#tdRightLineTop {
border-left-width: 1px;
border-left-style: solid;
border-left-color: #CACAFF;
#tdMainNavigation {
display: block;
font-size: 9pt;
background-color: #D5D5AA;
#tdRightNavigation {
border-left-width: 1px;
border-left-style: solid;
border-left-color: #D5D5AA;
background-color: #FFFFFF;
#tdMainNavigation a:link {
color: #333366;
text-decoration: none;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9pt;
text-align: center;
vertical-align: middle;
margin: 25px;
padding: 2px;
display: block;
border-left-style: solid;
border-left-width: 1px;
border-left-color: #333366;
border-right-width: 1px;
border-right-style: solid;
border-right-color: #333366;
background-color: #FFFFFF;
#tdMainNavigation a:visited {
color: #333366;
text-decoration: none;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9pt;
text-align: center;
vertical-align: middle;
margin: 25px;
padding: 2px;
display: block;
border-left-style: solid;
border-left-width: 1px;
border-left-color: #333366;
border-right-width: 1px;
border-right-style: solid;
border-right-color: #333366;
background-color: #FFFFFF;
#tdMainNavigation a:hover {
color: #FFFFFF;
text-decoration: none;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9pt;
text-align: center;
vertical-align: middle;
display: block;
margin: 25px;
padding: 2px;
border-left-width: 1px;
border-left-style: solid;
border-left-color: #333366;
background-color: #999966;
border-right-width: 1px;
border-right-style: solid;
border-right-color: #333366;
#tdMainNavigation a:active {
color: #333366;
text-decoration: none;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9pt;
text-align: center;
vertical-align: middle;
display: block;
margin: 25px;
padding: 2px;
font-weight: normal;
border-left-width: 1px;
border-left-style: solid;
border-left-color: #333366;
background-color: #D5D5AA;
border-right-width: 1px;
border-right-style: solid;
border-right-color: #333366;
#tdRightNavigation a:link {
font-family: "Times New Roman", Times, serif;
font-size: 9pt;
font-variant: normal;
color: #999900;
text-decoration: underline;
text-align: center;
display: block;
margin: 0px;
letter-spacing: 1px;
float: none;
line-height: 22px;
#tdRightNavigation a:visited {
font-family: "Times New Roman", Times, serif;
font-size: 9pt;
font-variant: normal;
color: #999900;
text-decoration: underline;
text-align: center;
display: block;
margin: 0px;
letter-spacing: 1px;
float: none;
line-height: 22px;
#tdRightNavigation a:hover {
font-family: "Times New Roman", Times, serif;
font-size: 9pt;
font-variant: normal;
color: #333399;
text-decoration: underline;
text-align: center;
display: block;
margin: 0px;
letter-spacing: 1px;
float: none;
line-height: 22px;
#tdRightNavigation a:active {
font-family: "Times New Roman", Times, serif;
font-size: 9pt;
font-variant: normal;
color: #666633;
text-decoration: underline;
text-align: center;
display: block;
margin: 0px;
letter-spacing: 1px;
float: none;
line-height: 22px;
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
a {
font-size: 10pt;
color: #333366;
a:visited {
color: #330066;
a:hover {
color: #999966;
a:active {
color: #999900;
body,td,th {
font-size: 10pt;Using DWCS3 / WIN XP
New to DWCS3 and templates AND CSS but I'm managing I
think....
QUESTION:
is there a way to allow the end user to edit the content of
an editable region and also the attributes of the cell in which the
editable region resides?
SITUATION:
I'm building templates for pages (styled with external CSS)
that will be editable by the end user via Contribute. I've put
editable and repeating regions (imgs and navigation menus) in
particular tds and would like the end user to be able to change the
color of the background of the cells in which the editable regions
reside.....
Of course I get "cannot place an editable region inside an
editable region" .......understandable...i've read more than a few
help/tutorial docs......
So I thought that I should click the tag selector for that td
and Make Attribute Editable.....
That's not working either....I know I'm missing something
because I haven't used DW in years and I'm just not getting some
big picture logic......
EXAMPLE: In the .html page attached for viewing, the upper
left image SRC is in an editable region. I would like the
background color of the cell it is in to be editable as well. Same
goes for the background color of the left navigation menu which
resides in a nested table by the way...........but i still want the
color to be editable.....
Thanks so much for any help you can give....
CoCo
PAGE based on Template:
http://www.methods.com/npsbweb/schools/NPSB_school_lev_1.html
CSS and TEMPLATE CODE: BELOW
@charset "utf-8";
p {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10pt;
font-weight: normal;
h1 {
font-size: 16px;
color: #999966;
font-family: "Times New Roman", Times, serif;
h2 {
font-size: 18px;
color: #333366;
font-family: Verdana, Arial, Helvetica, sans-serif;
text-align: center;
margin: 0px;
h3 {
font-size: 14px;
color: #333366;
font-family: Verdana, Arial, Helvetica, sans-serif;
h4 {
font-size: 12pt;
color: #999966;
font-family: "Times New Roman", Times, serif;
text-align: center;
letter-spacing: 1px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 5px;
margin-left: 0px;
h5 {
font-size: 12px;
color: #999966;
font-family: Verdana, Arial, Helvetica, sans-serif;
h6 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 8pt;
color: #333366;
text-align: center;
#tdDivideLineTop {
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #999966;
height: 2px;
#tdMainImgTop {
text-align: center;
vertical-align: middle;
height: 175px;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #D5D5AA;
background-color: #ffffff;
border-right-width: 1px;
border-right-style: solid;
border-right-color: #D5D5AA;
#tdTitleRow {
height: 175px;
vertical-align: middle;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #D5D5AA;
#tdRightLineTop {
border-left-width: 1px;
border-left-style: solid;
border-left-color: #CACAFF;
#tdMainNavigation {
display: block;
font-size: 9pt;
background-color: #D5D5AA;
#tdRightNavigation {
border-left-width: 1px;
border-left-style: solid;
border-left-color: #D5D5AA;
background-color: #FFFFFF;
#tdMainNavigation a:link {
color: #333366;
text-decoration: none;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9pt;
text-align: center;
vertical-align: middle;
margin: 25px;
padding: 2px;
display: block;
border-left-style: solid;
border-left-width: 1px;
border-left-color: #333366;
border-right-width: 1px;
border-right-style: solid;
border-right-color: #333366;
background-color: #FFFFFF;
#tdMainNavigation a:visited {
color: #333366;
text-decoration: none;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9pt;
text-align: center;
vertical-align: middle;
margin: 25px;
padding: 2px;
display: block;
border-left-style: solid;
border-left-width: 1px;
border-left-color: #333366;
border-right-width: 1px;
border-right-style: solid;
border-right-color: #333366;
background-color: #FFFFFF;
#tdMainNavigation a:hover {
color: #FFFFFF;
text-decoration: none;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9pt;
text-align: center;
vertical-align: middle;
display: block;
margin: 25px;
padding: 2px;
border-left-width: 1px;
border-left-style: solid;
border-left-color: #333366;
background-color: #999966;
border-right-width: 1px;
border-right-style: solid;
border-right-color: #333366;
#tdMainNavigation a:active {
color: #333366;
text-decoration: none;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9pt;
text-align: center;
vertical-align: middle;
display: block;
margin: 25px;
padding: 2px;
font-weight: normal;
border-left-width: 1px;
border-left-style: solid;
border-left-color: #333366;
background-color: #D5D5AA;
border-right-width: 1px;
border-right-style: solid;
border-right-color: #333366;
#tdRightNavigation a:link {
font-family: "Times New Roman", Times, serif;
font-size: 9pt;
font-variant: normal;
color: #999900;
text-decoration: underline;
text-align: center;
display: block;
margin: 0px;
letter-spacing: 1px;
float: none;
line-height: 22px;
#tdRightNavigation a:visited {
font-family: "Times New Roman", Times, serif;
font-size: 9pt;
font-variant: normal;
color: #999900;
text-decoration: underline;
text-align: center;
display: block;
margin: 0px;
letter-spacing: 1px;
float: none;
line-height: 22px;
#tdRightNavigation a:hover {
font-family: "Times New Roman", Times, serif;
font-size: 9pt;
font-variant: normal;
color: #333399;
text-decoration: underline;
text-align: center;
display: block;
margin: 0px;
letter-spacing: 1px;
float: none;
line-height: 22px;
#tdRightNavigation a:active {
font-family: "Times New Roman", Times, serif;
font-size: 9pt;
font-variant: normal;
color: #666633;
text-decoration: underline;
text-align: center;
display: block;
margin: 0px;
letter-spacing: 1px;
float: none;
line-height: 22px;
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
a {
font-size: 10pt;
color: #333366;
a:visited {
color: #330066;
a:hover {
color: #999966;
a:active {
color: #999900;
body,td,th {
font-size: 10pt; -
Blank values for editable JComboBox
Hello,
I have a editable JComboBox that the user can erase its current value and if they simple change focus (like click on a text field on the same panel) the combo box is left blank. i would like to have it so that if the user leaves focus of the box and its blank that current value goes back to what it was before they erased it.
Many thanks,
Jonathanimport java.awt.FlowLayout;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
public class NonBlankCombo {
JComboBox comboBox;
Object previousContent;
void makeUI() {
Object[] data = {"One", "Two", "Three", "Four", "Five"};
previousContent = data[0];
comboBox = new JComboBox(data);
comboBox.setEditable(true);
comboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED
&& !((String) comboBox.getSelectedItem()).trim().isEmpty()) {
previousContent = comboBox.getSelectedItem();
comboBox.getEditor().getEditorComponent().addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
previousContent = comboBox.getSelectedItem();
public void focusLost(FocusEvent e) {
if (((String)comboBox.getSelectedItem()).trim().isEmpty()) {
comboBox.setSelectedItem(previousContent);
JFrame frame = new JFrame("Non-blank Combo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 100);
frame.setLayout(new FlowLayout());
frame.add(comboBox);
frame.add(new JButton("Click"));
frame.setLocationRelativeTo(null);
frame.setVisible(true);
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new NonBlankCombo().makeUI();
}db -
JComboBox setSelectedIndex not displaying correct value
Hi,
Not sure if this is a bug or implementation issue.
When trying to use the setSelectedItem(int) method of JComboBox, what's being displayed in the panel is not the same item that is selected when you open the dropdown.
If you run the example code below a few times in a row you'll see that it eventually displays something other than "Item 2". However, if you open the combobox it will always display the correct value. So, just on a whim I surrounded the setSelectedIndex(int) call with the SwingUtilities.invokeLater method and it all started to work. I was able to run it 6 times in a row and always displayed the correct value. Whereas without it usually by the 3rd run, I'd see the issue.
So, my question is - Should I be putting all setSelectedXXX() methods in SwingUtilities.invokeLater methods? We originally found this issue in our JApplets. I made the code below so I could post it, but essentially it's the same thing. We do use Javascript to call back into the JApplet to set the indexes. I'm guessing I DO need to since we're dealing with different Threads and Swing?
Thanks,
- Tim
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
* To change this template, choose Tools | Templates
* and open the template in the editor.
* @author tmulle
public class Test {
public static void main(String[] args) {
// Create the Frame
JFrame f = new JFrame();
final JComboBox combo = new JComboBox();
// Add some items to the combo
for (int x = 0; x < 20; x++) {
combo.addItem("Item " + x);
// Create a scrollpane
JScrollPane pane = new JScrollPane(combo);
f.getContentPane().add(pane);
f.setSize(300, 200);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Tester thread
Thread t = new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(5000);
} catch (InterruptedException ex) {
Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
// Uncomment this and things seem to work consistently
// SwingUtilities.invokeLater(new Runnable() {
// public void run() {
// combo.setSelectedIndex(2);
// Comment this out when uncommenting above
// This is supposed to select the 2 index in the list
// However, run running the example multiple times you'll see
// that it sometimes displays something other than the correct
// value. But the correct items is selected in the dropdown
combo.setSelectedIndex(2);
// Start the thread
t.start();
// Show the frame
f.setVisible(true);
}You do need to set the selected index from the EDT, as shown in the code you commented out. Or, the SwingWorker class is very useful for simplifying your threading code.
Also, if I may, I think Darryl is suggesting you also create the gui components in the EDT as well. People often use this construct in the main method since the main method is run in a separate thread from the EDT, just like the threads you create. It is technically not safe to make Swing calls from the main() method.
public static void main(String args[])
SwingUtilities.invokeLater(new Runnable()
public void run()
createAndShow();
}Edited by: mpmarrone on Apr 27, 2010 1:08 PM -
JComboBox is not displaying the down arrow..
jComboBox is not displaying the down arrow..
I was first using the "choice" component but was having problems with the size only on Unix. So I changed it to a jComboBox and I'm having problems on both NT and UNIX. First the down arrow doesn't show up on NT....and the drop down doesn't even show up on UNIX.
Any ideas?
Thanks!
ptcould be coz you have not left enough room for it on the layout of your JPanel?
-
How to create a report in Form line Style and can display Image field?
Hi,
In Report builder 10g, I would like to create a Report with Form Line Style and this report included a Image field.
I can choose this Style only when Select Report type is Paper Layout. Because, If I choose Create both Web & Paper Layout or Create Web Layout only then in the next Style tab 03 option Form, Form letter and Mailing Label be Disabled.
But in Paper Layout, my report can not display Image field.
I tried with Web layout and all the other Styles (Except 03 mentioned be Disabled) then all Styles are displayed Imager field OK.
How to create a report in Form line Style and can display Image field?
I was change File Format property of my Image field from text to Image already in Property Inspector. But report only showed MM for my Image field.
Thanks & regards,
BACH
Message was edited by:
bachnpHere you go..Just follow these steps blindly and you are done.
1) Create a year prompt with presentation variable as pv_year
2) Create a report say Mid report with year column selected 3 times
- Put a filter of pv_year presentation variable on first year column with a default value say @{pv_year}{2008}
- Rename the second time column say YEAR+1 and change the fx to CAST(TIME_DIM."YEAR" AS INT)+1
- Rename the second time column say YEAR-1 and change the fx to CAST(TIME_DIM."YEAR" AS INT)-1
Now when you will run Mid Report, this will give you a records with value as 2008 2009 2007
3) Create your main report with criteria as Year and Measure col
- Change the fx for year column as CAST(TIME_DIM."YEAR" AS INT)
- Now put a filter on year column with Filter based on results of another request and select these:
Relationship = greater than or equal to any
Saved Request = Browse Mid Report
Use values in Column = YEAR-1
- Again,put a filter on year column with Filter based on results of another request and select these:
Relationship = less than or equal to any
Saved Request = Browse Mid Report (incase it doesn't allow you to select then select any other request first and then select Mid Report)
Use values in Column = YEAR+1
This will select Year > = 2007 AND Year < = 2009. Hence the results will be for year 2007,2008,2009
This will 100% work...
http://i56.tinypic.com/wqosgw.jpg
Cheers -
Problem with XMLTABLE and LEFT OUTER JOIN
Hi all.
I have one problem with XMLTABLE and LEFT OUTER JOIN, in 11g it returns correct result but in 10g it doesn't, it is trated as INNER JOIN.
SELECT * FROM v$version;
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
"CORE 11.2.0.1.0 Production"
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
--test for 11g
CREATE TABLE XML_TEST(
ID NUMBER(2,0),
XML XMLTYPE
INSERT INTO XML_TEST
VALUES
1,
XMLTYPE
<msg>
<data>
<fields>
<id>g1</id>
<dat>data1</dat>
</fields>
</data>
</msg>
INSERT INTO XML_TEST
VALUES
2,
XMLTYPE
<msg>
<data>
<fields>
<id>g2</id>
<dat>data2</dat>
</fields>
</data>
</msg>
INSERT INTO XML_TEST
VALUES
3,
XMLTYPE
<msg>
<data>
<fields>
<id>g3</id>
<dat>data3</dat>
</fields>
<fields>
<id>g4</id>
<dat>data4</dat>
</fields>
<fields>
<dat>data5</dat>
</fields>
</data>
</msg>
SELECT
t.id,
x.dat,
y.seqno,
y.id_real
FROM
xml_test t,
XMLTABLE
'/msg/data/fields'
passing t.xml
columns
dat VARCHAR2(10) path 'dat',
id XMLTYPE path 'id'
)x LEFT OUTER JOIN
XMLTABLE
'id'
passing x.id
columns
seqno FOR ORDINALITY,
id_real VARCHAR2(30) PATH '.'
)y ON 1=1
ID DAT SEQNO ID_REAL
1 data1 1 g1
2 data2 1 g2
3 data3 1 g3
3 data4 1 g4
3 data5 Here's everything fine, now the problem:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
"CORE 10.2.0.1.0 Production"
TNS for HPUX: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
--exactly the same environment as 11g (tables and rows)
SELECT
t.id,
x.dat,
y.seqno,
y.id_real
FROM
xml_test t,
XMLTABLE
'/msg/data/fields'
passing t.xml
columns
dat VARCHAR2(10) path 'dat',
id XMLTYPE path 'id'
)x LEFT OUTER JOIN
XMLTABLE
'id'
passing x.id
columns
seqno FOR ORDINALITY,
id_real VARCHAR2(30) PATH '.'
)y ON 1=1
ID DAT SEQNO ID_REAL
1 data1 1 g1
2 data2 1 g2
3 data3 1 g3
3 data4 1 g4As you can see in 10g I don't have the last row, it seems that Oracle 10g doesn't recognize the LEFT OUTER JOIN.
Is this a bug?, Metalink says that sometimes we can have an ORA-0600 but in this case there is no error returned, just incorrect results.
Please help.
Regards.Hi A_Non.
Thanks a lot, I tried with this:
SELECT
t.id,
x.dat,
y.seqno,
y.id_real
FROM
xml_test t,
XMLTABLE
'/msg/data/fields'
passing t.xml
columns
dat VARCHAR2(10) path 'dat',
id XMLTYPE path 'id'
)x,
XMLTABLE
'id'
passing x.id
columns
seqno FOR ORDINALITY,
id_real VARCHAR2(30) PATH '.'
)(+) y ;And is giving me the complete output.
Thanks again.
Regards. -
What is the difference between list display and grid display in alv report
Hai genious
i am a new of the abap, i dont know the alv report, i have a small doubt, can u please tell me what is the main difference between list display and grid display in alv report
thanks®ards
chinnuHi ,
1. For all practical purposes, they are the same.
2. Some differences:
a) from abap coding point of view,
alv list is done with Function modules,
alv gris can also be done with FM,
but can also be done using OO concepts.
b) Alv grid (using oo concept) requires
designing the screen layout .
Hence, in one screen, we can show more
then one alv grid
(we cannot show more than
one alv list on one screen)
c) ALV grid uses ActiveX controls
present on the Presentation Server.
Hence, it consumes More Memory
on the presentation server.
d) ALV LIST is Display Only.
Whereas
ALV Grid Can Be made EDITABLE for entry purpose.
e) In alv grid, these options are possible,
but not in alv list.
without horizontal lines
without vertical lines
without cell merging during sorts
display total lines above the entries
I hope it helps.
Regards,
Mamta
Edited by: Mamta Verma on Nov 27, 2008 6:41 AM -
How can I use a FocusEvent to distinguish among editable JComboBoxes?
Hi,
I have a Frame with multiple editable JComboBoxes, but I am at a loss as to how to sort them out in the focusGained() method.
It is easy when they are not editable, because the FocusEvent getSource() Method returns the box that fired the event. That lets me read an instance variable that is set differently for each box.
But with editable boxes, the FocusEvent is not fired by the box. It is fired by a Component object returned by getEditor().getEditorComponent(). So far I cannot find a way to query that object to find the box it it tied to. (I hope this isn't going to be painfully embarassing.).
Anyway, the code below produces a frame with four vertical components: a JTextField (textField), a NON-Editable JComboBox (comboBox1) and two Editable JComboBoxes (comboBox2 & comboBox3).
This is the command screen produced by :
- Running the class
- Then tabbing through all the components to return to the text field.
I am not sure why, but it gives the last component added the foucus on startup.Focus Gained - Begin: *****
This is the comboBox that Is Not Editable
Focus Gained - End: *******
Focus Gained - Begin: *****
This Is The TextField
Focus Gained - End: *******
Focus Gained - Begin: *****
Class: class javax.swing.plaf.metal.MetalComboBoxEditor$1
Name: javax.swing.plaf.metal.MetalComboBoxEditor$1
Focus Gained - End: *******
Focus Gained - Begin: *****
Class: class javax.swing.plaf.metal.MetalComboBoxEditor$1
Name: javax.swing.plaf.metal.MetalComboBoxEditor$1
Focus Gained - End: *******
Focus Gained - Begin: *****
This is the comboBox that Is Not Editable
Focus Gained - End: *******
Focus Gained - Begin: *****
This Is The TextField
Focus Gained - End: *******As you can see, the FocusEvent source for both editable boxes is a MetalComboBoxEditor. Both have identical names.
Can anyone help me get from there back to the actual combo box so I can read the instance variable to see which one fired the event?
The (painfully tedious and inelegant ) code that produced the above output is:import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
public class TestListeners extends JFrame
implements ActionListener, DocumentListener,
FocusListener, ItemListener {
// Constructor
TestListeners () {
super ();
panel.setLayout (new GridLayout (4, 1));
textField.addActionListener (this);
textField.getDocument ().addDocumentListener (this);
textField.addFocusListener (this);
panel.add(textField);
comboBox2.addActionListener (this);
comboBox2.getEditor().getEditorComponent ().addFocusListener (this);
comboBox2.addItemListener (this);
comboBox2.setEditable (true);
panel.add (comboBox2);
comboBox3.addActionListener (this);
comboBox3.getEditor().getEditorComponent ().addFocusListener (this);
comboBox3.addItemListener (this);
comboBox3.setEditable (true);
panel.add (comboBox3);
comboBox1.addActionListener (this);
comboBox1.addFocusListener (this);
comboBox1.addItemListener (this);
comboBox1.setEditable (false);
panel.add (comboBox1);
this.getContentPane ().add(panel);
this.setVisible (true);
pack ();
// Nested class
public class CB extends JComboBox {
// Nested Constructor
public CB (Vector items, String str) {
super (items);
this.type = str;
public String type;
// Instance Members
JTextField textField = new JTextField ("Test Listener TextField");
JPanel panel = new JPanel ();
String[] str = {"one", "two", "three"};
Vector items = new Vector (Arrays.asList (str));
CB comboBox1 = new CB (items, "Is Not Editable");
CB comboBox2 = new CB (items, "Is Editable 2");
CB comboBox3 = new CB (items, "Is Editable 3");
// Methods
public static void main(String args[]) {
TestListeners frame = new TestListeners ();
public void actionPerformed (ActionEvent ae) {
System.out.print ("ActionEvent: This is ");
if (ae.getSource ().getClass () == CB.class) {
System.out.print ( ((CB) ae.getSource ()).type + " ");
System.out.println (" "+ae.getActionCommand() + "\n" );
public void focusGained (FocusEvent fge) {
System.out.println ("Focus Gained - Begin: ***** ");
if (fge.getSource ().getClass () == CB.class) {
System.out.println ( " This is the comboBox that "+((CB) fge.getSource ()).type);
} else if (fge.getSource ().getClass () == JTextField.class) {
System.out.println ( " This Is The TextField");
} else {
System.out.println (" Class: "+fge.getSource ().getClass());
System.out.println (" Name: "+fge.getSource ().getClass ().getName ());
System.out.println ("Focus Gained - End: *******\n*\n");
public void focusLost (FocusEvent fle) { }
public void changedUpdate (DocumentEvent de) { }
public void insertUpdate (DocumentEvent de) { }
public void removeUpdate (DocumentEvent de) { }
public void itemStateChanged (ItemEvent ie) { }
}I added the following in your focusGained() method and it seemed to work:
Component c = ((Component)fge.getSource ()).getParent();
if (c instanceof JComboBox)
JComboBox cb = (JComboBox)c;
System.out.println("Selected: " + cb.getSelectedItem());
} -
I use Preview to edit photos, and would like to know if there are any updates to this program in the works. It seems Apple is constantly updating its software, except for Preview. I find it crashes all too often, and also takes forever to "catch up" with me (as in spinning beachball of death) when I'm editing a lrge amount of photos. Yes, I know I should be using Photoshop or somesuch, but it's just too **** confusing, and I don't have the time to figure it out. Thanks!!
Launch the Console application in any of the following ways:
☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
Step 1
Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
View ▹ Show Log List
from the menu bar.
Enter the name of the crashed application or process in the Filter text field. Select the messages from the time of the last crash, if any. Copy them to the Clipboard (command-C). Paste into a reply to this message (command-V).
When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
Please do not indiscriminately dump thousands of lines from the log into this discussion.
Important: Some private information, such as your name, may appear in the log. Anonymize before posting.
Step 2
In the Console window, look under User Diagnostic Reports for crash reports related to the crashed process. The report name starts with the name of the process, and ends with ".crash". Select the most recent report and post the entire contents — again, the text, not a screenshot. In the interest of privacy, I suggest that, before posting, you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if it’s present (it may not be.) Please don’t post shutdownStall, spin, or hang logs — they're very long and not helpful.
Maybe you are looking for
-
CC desktop app in un responsive
First off, some apps do not load, like DW CC and the desktop app does not load, uninstall, reinstall or anything. When I attempt to install the apps it just spins. I am on a mac pro, os 10.7.5. Can you help? Thanks
-
Windows/ iTunes/ iPod Updater Don't See The Nano
Well, here's the story. I got a refurbished nano after my first broke. Plugged it in, didn't work. Went back 2 an Apple Store, they told me it was a software problem, the guy even had it working. I came back home, uninstalled iTunes, Quicktime, and t
-
None of the information from the iphone calendar has uploaded?
I have been able to upload all my contacts, (with full postal addresses) from my iphone4 to icloud...but none of the information from the iphone calendar has uploaded? Can anyone please advise? Regards, Laurance
-
Is There Any Software Available To REMOVE DRM From WMA Fil
if so please let me know! email all info to [email][email protected]][email protected][/url] if you don't post here, thanks!
-
Greetings all, I'm building a shared library that uses some STL code. All objects are built -KPIC, and the link is being done by CC. We're not building compat, and the lib is built to be dlopen'd by an application later. This occurs on Solaris 2.6, a