JCheckBox Highlighting
I have JcheckBox which has no label by itself , i mean
It will be shown like , following
LABEL : |_|
A JLabel is there in the left , so when the focus is on the tab , is there anyway to highlight the checkbox ?
since normally if we have a checkbox name or label on the right it will be highlighted.
"Highlight" is a bit diffuse...what kind of highlighting are you after?
How about checking for focusgained and when that happens change the background color?
/ k
Similar Messages
-
Scroll bar problems ..Please help!!!!!!
This is what the program looks like. topPanel has newItemPanel on top of it. when you click continue newItemPanel becomes invisible and newItemDescriptionPanel becomes visible. When you click continue newItemDescriptionPanel becomes invisible and priceEnterPanel becomes visible.
I want newItemDescriptionPanel and priceEnterPanel to have a scroll bar. but everything I have tried hasn't worked. I am new. You will see the code is ugly and there is an attempt to add a scrollbar.
Please help
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
import java.lang.System;
public class MainPanel extends JFrame implements ActionListener
private boolean firstRun = true;
private final int ITEM_PLAIN = 0; // Item types
private final int ITEM_CHECK = 1;
private final int ITEM_RADIO = 2;
private JPanel topPanel;
private JPanel newItemPanel;
private JRadioButton onlineAuctionRadio;
private JRadioButton fixedPriceRadio;
private ButtonGroup bg;
private JButton continueButton;
private JLabel blankLabel; //used to give space between things
private JPanel newItemDescriptionPanel;
private JPanel takeAdditionalSpacePanelCheckBox;
private JPanel takeAdditionalSpacePanel;
private JPanel takeAdditionalSpacePanelLabel;
private JPanel takeAdditionalSpacePanelLabel2;
private JPanel takeAdditionalSpacePanel2;
private JPanel takeAdditionalSpacePanel3;
private JPanel takeAdditionalSpacePanel4;
private JPanel takeAdditionalSpacePanel5;
JScrollPane displayScroller;
JEditorPane itemDescriptionTextArea;
GridBagLayout gridbag;
GridBagConstraints gbc;
private JCheckBox secondCategoryCheckBox;
private JLabel itemTitleLabel;
private JLabel requiredLabel, requiredLabel2;
private JLabel requiredStarLabel;
private JTextField itemTitleTextField;
private JLabel subtitleLabel;
private JTextField subtitleTextField;
private JLabel itemDescriptionLabel;
private JButton itemDescriptionContinueButton;
private JLabel percentageLabel;
//------- price enter page ----------------
private JLabel startingPriceLabel;
private JLabel dollarSignLabel;
private JTextField startingPriceTextField;
private JPanel fillUpSpacePanel;
private JPanel fillUpSpacePanel1;
private JPanel fillUpSpacePanel2;
private JLabel buyItNowLabel;
private JPanel fillUpSpacePanel3;
private JLabel dollarSignLabel2;
private JTextField buyItNowTextField;
private JPanel fillUpSpacePanel4;
private JPanel fillUpSpacePanel5;
private JPanel fillUpSpacePanel6;
private JPanel fillUpSpacePanel7;
private JPanel fillUpSpacePanel8;
private JPanel fillUpSpacePanel9;
private JPanel fillUpSpacePanel10;
private JPanel fillUpSpacePanel11;
private JPanel fillUpSpacePanel12;
private JPanel fillUpSpacePanel13;
private JPanel fillUpSpacePanel14;
private JPanel fillUpSpacePanel15;
private JPanel fillUpSpacePanel16;
private JPanel fillUpSpacePanel17;
private JPanel fillUpSpacePanel18;
private JLabel donatePercentageLabel;
private JTextField donatePercentageTextField;
private JPanel fSp; // fill space panel
private JPanel fSp1;
private JPanel fSp2;
private JPanel fSp3;
private JPanel fSp4;
private JPanel fSp5;
private JPanel fSp6;
private JPanel fSp7;
private JPanel fSp8;
private JPanel fSp9;
private JLabel numberOfPicturesLabel;
private JTextField numberOfPicturesTextField;
private JCheckBox superSizePicturesCheckBox;
private JLabel superSizePicturesLabel;
private JRadioButton standardPictureRadioButton;
private JRadioButton picturePackRadioButton;
private JCheckBox listingDesignerCheckBox;
private ButtonGroup bgPictures;
private JCheckBox valuePackCheckBox;
private JCheckBox galleryPictureCheckBox;
private JCheckBox subtitleCheckBox;
private JCheckBox boldCheckBox;
private JCheckBox borderCheckBox;
private JCheckBox highlightCheckBox;
private JCheckBox featuredPlusCheckBox;
private JCheckBox galleryFeaturedCheckBox;
private JLabel homePageFeaturedLabel;
private JComboBox homePageFeaturedComboBox;
private JCheckBox giftCheckBox;
JScrollPane priceEnterPanelScroll;
private JButton backToRadioButton;
private JButton backToItemDescriptionButton;
private JPanel priceEnterPanel;
private final static String RADIOPANEL = "JPanel with radios";
private final static String DESCRIPTIONPANEL = "JPanel with description";
private final static String PRICEENTERPANEL = "JPanel with price entering";
private JPanel cards;
private JMenuBar menuBar;
private JMenu menuFile;
private JMenu menuEdit;
private JMenu menuProperty;
private JMenuItem menuPropertySystem;
private JMenuItem menuPropertyEditor;
private JMenuItem menuPropertyDisplay;
private JMenu menuFileNew;
private JMenuItem menuFileNewAccount;
private JMenuItem menuFileNewItem;
private JMenuItem menuFileOpen;
private JMenuItem menuFileSave;
private JMenuItem menuFileSaveAs;
private JMenuItem menuFileExit;
private JMenuItem menuEditCopy;
private JMenuItem menuEditCut;
private JMenuItem menuEditPaste;
public MainPanel()
requiredLabel = new JLabel ("* Required");
requiredLabel.setForeground (Color.red);
requiredLabel2 = new JLabel ("* Required");
requiredLabel2.setForeground (Color.red);
requiredStarLabel = new JLabel ("*");
requiredStarLabel.setForeground (Color.green);
setTitle( "photo galleries" );
setSize( 310, 130 );
topPanel = new JPanel();
topPanel.setLayout( new BorderLayout() );
topPanel.setBorder (BorderFactory.createTitledBorder ("TopPanel"));
//topPanel.setPreferredSize(new Dimension (300,300));
getContentPane().add( topPanel );
topPanel.setVisible (false);
// For New Item Panel
ButtonListener ears = new ButtonListener();
blankLabel = new JLabel (" "); // used to give space between radio buttons and continue button
continueButton = new JButton ("Continue >");
continueButton.addActionListener (ears);
backToRadioButton = new JButton ("< back");
backToRadioButton.addActionListener (ears);
itemDescriptionContinueButton = new JButton ("Continue >");
itemDescriptionContinueButton.addActionListener (ears);
backToItemDescriptionButton = new JButton ("< back");
backToItemDescriptionButton.addActionListener (ears);
newItemPanel = new JPanel();
newItemPanel.setLayout (new BoxLayout(newItemPanel, BoxLayout.Y_AXIS));
//topPanel.add (newItemPanel, BorderLayout.NORTH);
newItemPanel.setBorder (BorderFactory.createTitledBorder ("NewItemPanel"));
newItemPanel.setVisible (false);
onlineAuctionRadio = new JRadioButton ("Sold item at online Auction" );
fixedPriceRadio = new JRadioButton ("Sold at a Fixed Price");
bg = new ButtonGroup();
bg.add(onlineAuctionRadio);
bg.add(fixedPriceRadio);
onlineAuctionRadio.addActionListener (ears);
fixedPriceRadio.addActionListener (ears);
newItemPanel.add (onlineAuctionRadio);
newItemPanel.add (fixedPriceRadio);
newItemPanel.add (blankLabel);
newItemPanel.add (continueButton);
// ------ After continue pressed ---------
newItemDescriptionPanel = new JPanel();
newItemDescriptionPanel.setLayout (new BoxLayout(newItemDescriptionPanel, BoxLayout.Y_AXIS));
newItemPanel.add (newItemDescriptionPanel, BorderLayout.NORTH);
newItemDescriptionPanel.setBorder (BorderFactory.createTitledBorder ("newItemDescriptionPanel"));
secondCategoryCheckBox = new JCheckBox ("The item was listed in a second category");
newItemDescriptionPanel.setVisible (false);
itemTitleLabel = new JLabel ("Item title");
itemTitleTextField = new JTextField (30);
subtitleLabel = new JLabel ("Subtitle ($0.50)");
subtitleTextField = new JTextField (30);
itemDescriptionLabel = new JLabel ("Item description");
itemDescriptionTextArea = new JEditorPane();
itemDescriptionTextArea.setContentType( "text/html" );
itemDescriptionTextArea.setEditable( false );
itemDescriptionTextArea.setPreferredSize(new Dimension (500,250));
itemDescriptionTextArea.setFont(new Font( "Serif", Font.PLAIN, 12 ));
itemDescriptionTextArea.setForeground( Color.black );
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 4;
displayScroller = new JScrollPane( itemDescriptionTextArea );
gridbag = new GridBagLayout ();
gridbag.setConstraints( displayScroller, gbc );
itemDescriptionTextArea.setEditable( true );
takeAdditionalSpacePanelCheckBox = new JPanel(new FlowLayout(FlowLayout.LEFT));
takeAdditionalSpacePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));//<--added, to take additional space
takeAdditionalSpacePanelLabel = new JPanel(new FlowLayout(FlowLayout.LEFT));//<--added, to take additional space
takeAdditionalSpacePanelLabel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));//<--added, to take additional space
takeAdditionalSpacePanel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));//<--added, to take additional space
takeAdditionalSpacePanel3 = new JPanel(new FlowLayout(FlowLayout.LEFT));//<--added, to take additional space
takeAdditionalSpacePanel4 = new JPanel(new FlowLayout(FlowLayout.LEFT));
takeAdditionalSpacePanel5 = new JPanel(new FlowLayout(FlowLayout.LEFT));
//takeAdditionalSpacePanel2.setBorder (BorderFactory.createTitledBorder ("Additonal 2"));
takeAdditionalSpacePanelCheckBox.add (secondCategoryCheckBox);
newItemDescriptionPanel.add (takeAdditionalSpacePanelCheckBox);
//newItemDescriptionPanel.add (blankLabel);
takeAdditionalSpacePanelLabel.add (itemTitleLabel);
takeAdditionalSpacePanelLabel.add (requiredLabel);
newItemDescriptionPanel.add (takeAdditionalSpacePanelLabel);
//newItemDescriptionPanel.add (itemTitleTextField);
takeAdditionalSpacePanel.add(itemTitleTextField);//<--add textfield to panel
newItemDescriptionPanel.add (takeAdditionalSpacePanel);//<--add panel to boxlayout panel
takeAdditionalSpacePanelLabel2.add (subtitleLabel);
newItemDescriptionPanel.add (takeAdditionalSpacePanelLabel2);
takeAdditionalSpacePanel2.add (subtitleTextField);
newItemDescriptionPanel.add (takeAdditionalSpacePanel2);
takeAdditionalSpacePanel4.add (itemDescriptionLabel);
//takeAdditionalSpacePanel4.add (requiredLabel2);
newItemDescriptionPanel.add (takeAdditionalSpacePanel4);
takeAdditionalSpacePanel3.add (displayScroller);
newItemDescriptionPanel.add (takeAdditionalSpacePanel3);
takeAdditionalSpacePanel5.add (backToRadioButton);
takeAdditionalSpacePanel5.add (itemDescriptionContinueButton);
newItemDescriptionPanel.add (takeAdditionalSpacePanel5);
//newItemDescriptionPanel.setLayout (new BoxLayout(newItemDescriptionPanel, BoxLayout.Y_AXIS));
//----------- Price Enter Page ----------------
priceEnterPanel = new JPanel();
priceEnterPanel.setLayout (new BoxLayout(priceEnterPanel, BoxLayout.Y_AXIS));
newItemDescriptionPanel.add (priceEnterPanel, BorderLayout.NORTH);
priceEnterPanel.setBorder (BorderFactory.createTitledBorder ("Price enter Panel"));
priceEnterPanel.setVisible (false);
priceEnterPanelScroll = new JScrollPane (priceEnterPanel);
topPanel.add (priceEnterPanelScroll);
standardPictureRadioButton = new JRadioButton ("Standard");
picturePackRadioButton = new JRadioButton ("Picture Pack ($1.00 for up to 6 pictures or $1.50 for 7 to 12 pictures)");
bgPictures = new ButtonGroup();
bgPictures.add(standardPictureRadioButton);
bgPictures.add(picturePackRadioButton);
standardPictureRadioButton.addActionListener (ears);
picturePackRadioButton.addActionListener (ears);
superSizePicturesCheckBox = new JCheckBox ("Supersize Pictures ($0.75)");
listingDesignerCheckBox = new JCheckBox ("Listing designer $0.10");
valuePackCheckBox = new JCheckBox ("Get the Essentials for less! Gallery, Subtitle, Listing Designer. $0.65 (save $0.30)");
superSizePicturesCheckBox.setEnabled (false);
superSizePicturesCheckBox.addActionListener (ears);
listingDesignerCheckBox.addActionListener (ears);
valuePackCheckBox.addActionListener (ears);
startingPriceLabel = new JLabel ("Starting Price");
dollarSignLabel = new JLabel ("$");
startingPriceTextField = new JTextField (10);
buyItNowLabel = new JLabel ("Buy It Now");
dollarSignLabel2 = new JLabel ("$");
buyItNowTextField = new JTextField (10);
donatePercentageLabel = new JLabel ("Donate percentage of sale");
donatePercentageTextField = new JTextField (2);
donatePercentageTextField.setText ("0");
percentageLabel = new JLabel ("%");
// Right-justify the text
donatePercentageTextField.setHorizontalAlignment(JTextField.RIGHT);
numberOfPicturesLabel = new JLabel ("Number of pictures used");
numberOfPicturesTextField = new JTextField (1);
numberOfPicturesTextField.setText ("0");
galleryPictureCheckBox = new JCheckBox ("Gallery ($0.35) [Requires a picture]");
subtitleCheckBox = new JCheckBox ("Subtitle ($0.50)");
boldCheckBox = new JCheckBox ("Bold ($1.00)");
borderCheckBox = new JCheckBox ("Border ($3.00)");
highlightCheckBox = new JCheckBox ("Highlight ($5.00)");
featuredPlusCheckBox = new JCheckBox ("Featured Plus! ($19.95)");
galleryFeaturedCheckBox = new JCheckBox ("Gallery Featured ($19.95) [Requires a picture]");
homePageFeaturedLabel = new JLabel ("Home Page Featured ($39.95 for 1 item, $79.95 for 2 or more items)");
homePageFeaturedComboBox = new JComboBox ();
homePageFeaturedComboBox.addItem (("None..."));
homePageFeaturedComboBox.addItem (("1 item"));
homePageFeaturedComboBox.addItem (("2 or more items"));
giftCheckBox = new JCheckBox ("Show as a gift ($0.25)");
fillUpSpacePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel4 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel5 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel6 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel7 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel8 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel9 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel10 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel11 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel12 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel13 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel14 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel15 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel16 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel17 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel18 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp4 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp5 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp6 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp7 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp8 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fSp9 = new JPanel(new FlowLayout(FlowLayout.LEFT));
fillUpSpacePanel.add (startingPriceLabel);
fillUpSpacePanel.add (requiredLabel2);
priceEnterPanel.add (fillUpSpacePanel);
fillUpSpacePanel2.add (dollarSignLabel);
fillUpSpacePanel2.add (startingPriceTextField);
priceEnterPanel.add (fillUpSpacePanel2);
// fillUpSpacePanel1.add (backToItemDescriptionButton);
// priceEnterPanel.add (fillUpSpacePanel1);
fillUpSpacePanel3.add (buyItNowLabel);
priceEnterPanel.add (fillUpSpacePanel3);
fillUpSpacePanel4.add (dollarSignLabel2);
fillUpSpacePanel4.add (buyItNowTextField);
priceEnterPanel.add (fillUpSpacePanel4);
fillUpSpacePanel1.add (donatePercentageLabel);
priceEnterPanel.add (fillUpSpacePanel1);
fillUpSpacePanel5.add (donatePercentageTextField);
fillUpSpacePanel5.add (percentageLabel);
priceEnterPanel.add (fillUpSpacePanel5);
fillUpSpacePanel6.add (numberOfPicturesLabel);
priceEnterPanel.add (fillUpSpacePanel6);
fillUpSpacePanel7.add (numberOfPicturesTextField);
priceEnterPanel.add (fillUpSpacePanel7);
fillUpSpacePanel8.add (standardPictureRadioButton);
priceEnterPanel.add (fillUpSpacePanel8);
fillUpSpacePanel10.add (blankLabel);
fillUpSpacePanel10.add (superSizePicturesCheckBox);
priceEnterPanel.add (fillUpSpacePanel10);
fillUpSpacePanel9.add (picturePackRadioButton);
priceEnterPanel.add (fillUpSpacePanel10);
fillUpSpacePanel11.add (picturePackRadioButton);
priceEnterPanel.add (fillUpSpacePanel11);
fillUpSpacePanel12.add (listingDesignerCheckBox);
priceEnterPanel.add (fillUpSpacePanel12);
fillUpSpacePanel13.add (valuePackCheckBox);
priceEnterPanel.add (fillUpSpacePanel13);
fSp.add (galleryPictureCheckBox);
priceEnterPanel.add (fSp);
fSp1.add (subtitleCheckBox);
priceEnterPanel.add (fSp1);
fSp2.add (boldCheckBox);
priceEnterPanel.add (fSp2);
fSp3.add (borderCheckBox);
priceEnterPanel.add (fSp3);
fSp4.add (highlightCheckBox);
priceEnterPanel.add (fSp4);
fSp5.add (featuredPlusCheckBox);
priceEnterPanel.add (fSp5);
fSp6.add (galleryFeaturedCheckBox);
priceEnterPanel.add (fSp6);
fSp7.add (homePageFeaturedLabel);
priceEnterPanel.add (fSp7);
fSp8.add (homePageFeaturedComboBox);
priceEnterPanel.add (fSp8);
fSp9.add (giftCheckBox);
priceEnterPanel.add (fSp9);
newItemDescriptionPanel.add (priceEnterPanelScroll);
//Create the panel that contains the "cards".
cards = new JPanel(new CardLayout());
cards.add(newItemPanel, RADIOPANEL);
cards.add(newItemDescriptionPanel, DESCRIPTIONPANEL);
cards.add(priceEnterPanel, PRICEENTERPANEL);
topPanel.add(cards, BorderLayout.NORTH);
// Create the menu bar
menuBar = new JMenuBar();
// Set this instance as the application's menu bar
setJMenuBar( menuBar );
// Build the property sub-menu
menuProperty = new JMenu( "Properties" );
menuProperty.setMnemonic( 'P' );
// Create property items
menuPropertySystem = CreateMenuItem( menuProperty, ITEM_PLAIN,
"System...", null, 'S', null );
menuPropertyEditor = CreateMenuItem( menuProperty, ITEM_PLAIN,
"Editor...", null, 'E', null );
menuPropertyDisplay = CreateMenuItem( menuProperty, ITEM_PLAIN,
"Display...", null, 'D', null );
//Build the File-New sub-menu
menuFileNew = new JMenu ("New");
menuFileNew.setMnemonic ('N');
//Create File-New items
menuFileNewItem = CreateMenuItem( menuFileNew, ITEM_PLAIN,
"Item", null, 'A', null );
menuFileNewAccount = CreateMenuItem( menuFileNew, ITEM_PLAIN,
"Account", null, 'A', null );
// Create the file menu
menuFile = new JMenu( "File" );
menuFile.setMnemonic( 'F' );
menuBar.add( menuFile );
//Add the File-New menu
menuFile.add( menuFileNew );
// Create the file menu
// Build a file menu items
menuFileOpen = CreateMenuItem( menuFile, ITEM_PLAIN, "Open...",
new ImageIcon( "open.gif" ), 'O',
"Open a new file" );
menuFileSave = CreateMenuItem( menuFile, ITEM_PLAIN, "Save",
new ImageIcon( "save.gif" ), 'S',
" Save this file" );
menuFileSaveAs = CreateMenuItem( menuFile, ITEM_PLAIN,
"Save As...", null, 'A',
"Save this data to a new file" );
// Add the property menu
menuFile.addSeparator();
menuFile.add( menuProperty );
menuFile.addSeparator();
menuFileExit = CreateMenuItem( menuFile, ITEM_PLAIN,
"Exit", null, 'X',
"Exit the program" );
//menuFileExit.addActionListener(this);
// Create the file menu
menuEdit = new JMenu( "Edit" );
menuEdit.setMnemonic( 'E' );
menuBar.add( menuEdit );
// Create edit menu options
menuEditCut = CreateMenuItem( menuEdit, ITEM_PLAIN,
"Cut", null, 'T',
"Cut data to the clipboard" );
menuEditCopy = CreateMenuItem( menuEdit, ITEM_PLAIN,
"Copy", null, 'C',
"Copy data to the clipboard" );
menuEditPaste = CreateMenuItem( menuEdit, ITEM_PLAIN,
"Paste", null, 'P',
"Paste data from the clipboard" );
public JMenuItem CreateMenuItem( JMenu menu, int iType, String sText,
ImageIcon image, int acceleratorKey,
String sToolTip )
// Create the item
JMenuItem menuItem;
switch( iType )
case ITEM_RADIO:
menuItem = new JRadioButtonMenuItem();
break;
case ITEM_CHECK:
menuItem = new JCheckBoxMenuItem();
break;
default:
menuItem = new JMenuItem();
break;
// Add the item test
menuItem.setText( sText );
// Add the optional icon
if( image != null )
menuItem.setIcon( image );
// Add the accelerator key
if( acceleratorKey > 0 )
menuItem.setMnemonic( acceleratorKey );
// Add the optional tool tip text
if( sToolTip != null )
menuItem.setToolTipText( sToolTip );
// Add an action handler to this menu item
menuItem.addActionListener( this );
menu.add( menuItem );
return menuItem;
public void actionPerformed( ActionEvent event )
CardLayout cl = (CardLayout)(cards.getLayout());
if (event.getSource() == menuFileExit)
System.exit(0);
if (event.getSource() == menuFileNewAccount)
System.out.println ("hlkadflkajfalkdjfalksfj");
if (event.getSource() == menuFileNewItem){
if (firstRun){
newItemPanel.setVisible (true);
topPanel.setVisible (true);
cl.show(cards,RADIOPANEL);
firstRun = false;
//System.out.println( event );
private class ButtonListener implements ActionListener
public void actionPerformed(ActionEvent event)
CardLayout cl = (CardLayout)(cards.getLayout());
// cl.show(cards, (String)evt.getItem());
if (event.getSource() == continueButton){
if (!(onlineAuctionRadio.isSelected()) && !(fixedPriceRadio.isSelected()))
JOptionPane.showMessageDialog(null, "You must select at least one.", "Error", JOptionPane.ERROR_MESSAGE);
else{
if (onlineAuctionRadio.isSelected()){
cl.show (cards, DESCRIPTIONPANEL);
//newItemPanel.setVisible (false);
//newItemDescriptionPanel.setVisible (true);
if (event.getSource() == itemDescriptionContinueButton){
if (itemTitleTextField.getText().trim().equalsIgnoreCase(""))
JOptionPane.showMessageDialog(null, "You must enter a title.", "Error", JOptionPane.ERROR_MESSAGE);
else
cl.show (cards, PRICEENTERPANEL);
if (event.getSource() == backToRadioButton){
cl.show (cards, RADIOPANEL);
if (event.getSource() == backToItemDescriptionButton){
cl.show(cards, DESCRIPTIONPANEL);
if (standardPictureRadioButton.isSelected()){
superSizePicturesCheckBox.setEnabled (true);
if (picturePackRadioButton.isSelected()){
superSizePicturesCheckBox.setEnabled (false);
} //end of action performed
}Mostly I see there is about 100 times as much code as I care to look at.
So you don't know how to get a panel in a scroll pane, and then get that scroll pane into your GUI? Then try doing that by itself, not encumbered with 10000 lines of irrelevant code. Once you have it working, plug it into the big lump of code. Or if you can't get it working, ask about the small problem here. -
Custom Cell Renderer containing JCheckBox
Hi,
I have a JTable..and I have the following cell renderer
private class MyCellRenderer extends JCheckBox implements TableCellRenderer {
public DeleteCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
setHorizontalAlignment(SwingConstants.CENTER);
setBackground(Color.WHITE);
setSelected(isSelected);
requestFocus(hasFocus);
return this;
// add the renderer to the right column
column = table.getColumnModel().getColumn(0);
column.setCellRenderer(new MyCellRenderer());basically.. when the checkbox is clicked in my cell...the whole cell turns grey (just like a JButton when it is pressed)..i dont want that to happen. Also, the checkbox is not staying selected / deselected.
what am i doing wrong? .... eventually i want to use my own JCheckBox implementation (which will have its own colors).
thanksOk, this is fully working.
One problem was that you were setting the check box based on the isSelected parameter instead of the
value parameter. IsSelected is used to indicate that the row highlight should be drawn.
Also, if you want to change the look of the component inside the square of the check box, you need to change the icon. If you look in com.sun.java.swing.plaf.windows.WindowIcon you can see how the default check box draws itself based on the state of the check box.
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.table.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import java.util.TreeSet;
public class BooleanTable extends JFrame
Object[][] data = {{Boolean.TRUE},{Boolean.TRUE},{Boolean.TRUE},{Boolean.TRUE},{Boolean.TRUE},{Boolean.TRUE}};
String[] header = {"CheckBoxes"};
public BooleanTable()
setDefaultCloseOperation( EXIT_ON_CLOSE );
TableModel model = new AbstractTableModel()
public String getColumnName(int column)
return header[column].toString();
public int getRowCount()
return data.length;
public int getColumnCount()
return header.length;
* Returns <code>Object.class</code> regardless of <code>columnIndex</code>.
* @param columnIndex the column being queried
* @return the Object.class
public Class getColumnClass(int columnIndex)
return( data[0][columnIndex].getClass() );
public Object getValueAt(int row, int col)
return data[row][col];
public boolean isCellEditable(int row, int column)
return true;
public void setValueAt(Object value, int row, int col)
data[row][col] = value;
fireTableCellUpdated(row, col);
JTable table = new JTable(model);
table.setDefaultRenderer( Boolean.class, new MyCellRenderer() );
table.setDefaultEditor( Boolean.class, new MyCellEditor() );
getContentPane().add( new JScrollPane( table ) );
pack();
setLocationRelativeTo( null );
setVisible( true );
public static void main( String[] a )
try
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
catch( Exception e )
new BooleanTable();
private class MyCellRenderer implements TableCellRenderer
protected Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
protected Border focusBorder = UIManager.getBorder("Table.focusCellHighlightBorder");
private JCheckBox checkBox;
public MyCellRenderer()
checkBox = new JCheckBox();
checkBox.setHorizontalAlignment(SwingConstants.CENTER);
checkBox.setBackground( Color.white);
public Component getTableCellRendererComponent(JTable
table, Object value, boolean isSelected, boolean
hasFocus, int row, int column)
checkBox.setSelected( Boolean.valueOf( value.toString() ).booleanValue() );
return checkBox;
private class MyCellEditor extends AbstractCellEditor implements TableCellEditor
JCheckBox checkBox;
public MyCellEditor()
checkBox = new JCheckBox();
checkBox.setHorizontalAlignment(SwingConstants.CENTER);
checkBox.setBackground( Color.white);
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
checkBox.setSelected( Boolean.valueOf( value.toString() ).booleanValue() );
return checkBox;
public Object getCellEditorValue()
return Boolean.valueOf(checkBox.isSelected()); -
Hi there,
i hope this has not been covered already, i searched this forum looking for all kind of JCheckBox posts but did not find what i was looking for. If i missed it i'm really sorry and would appreciate any kick that get's me into the right direction ;-)
I'm using some JCheckBoxes in my application and on all testsystems i ran it on everything worked fine. Now i got finally access to the machine it should run on in the end and of course it screws up. The selection icons for the JCheckboxes are not working correctly, more specific the IconBackground is black so i can only see if the box is checked when i highlight it. I really have no clue why it is behaving differently on this machine (same operating system, same jre-build). If anybody could give a hint what the problem could be or what work-arounds are known, it would be greatly appreciated. For now i try to mess with the UIManager, but i'm kinda stuck there because the documentation on how to use it for what purpose is not really rich ;-)
Thx in advance, ChrisHello,
Here is the content of the first note:
A hierarchical tree component is used within Forms. When the tree is populated with (ftree.populate_tree), it does not show the associated icons "from the icon column within the query". The icons are stored in a jar file.
The environment file and the web configuration file are correctly set. For example, an image in the jar file appears on an iconic button.
Cause
The cause of this issue is determined by the unpublished Bug 10410309: FTREE.POPULATE_TREE DOES NOT SHOW ICONS
Solution
If the icon node value is refreshed, then the associated image appears.
A simple loop like this will solve the problem:
DECLARE
htree ITEM;
node ftree.node;
state varchar2(30);
state2 varchar2(30);
BEGIN
-- Find the tree itself.
htree := Find_Item('TREE.TREE');
Ftree.Populate_Tree(htree);
go_item('TREE.TREE');
-- Find the root node of the tree.
node := Ftree.Find_Tree_Node(htree, '');
-- Loop through all nodes and refresh their icon value
WHILE NOT Ftree.ID_NULL(node) LOOP
state2 := Ftree.Get_Tree_Node_Property(htree, node, Ftree.NODE_ICON);
IF state2 is not null THEN
Ftree.Set_Tree_Node_Property(htree, node, Ftree.NODE_ICON, lower(state2));
END IF;
node := Ftree.Find_Tree_Node(htree, '', ftree.find_NEXT,Ftree.NODE_LABEL,'', node);
END LOOP;
END;
Now the icon image value will be read from the jar file containing the images.
The second note talks about not using subdirectories inside the jar file.
Kind regards,
Alex
If someone's answer is helpful or correct please mark it accordingly. -
Domesticating JCheckBox when used as editor in JTree
If you look at the way checkboxes are drawn in certain L&F's (say, 1.5's Metal), you'll see that upon arming (mouseover/hover) of the box, a highlight or focus is painted on the little square box. I believe this may be true in the XP L&F and know it is true in JGoodies Plastic XP.
This is caused by arming of the box occuring just by a mere mouseover which gives a fancy visual effect. However, when used as a cell editor in a JTree, this looks really bad and even inconsistent since the renderers don't have the same effect.
So I'd like to disable this, but after a long night of hacking through Swing code, it appears that this stuff is really tightly wrapped in. There are no per-instance flags that can be set to disable it. BUT, here is what gives me hope. I've got JCheckBoxes in all my JTables and NONE of them experience this visual feature. Somehow JTable must be trapping and consuming the mouse entered, exited, etc. events so that you never see the painting of the checkbox change when you hover over it. JTable has tamed this wicked beast and put him in his place. What is this great master's secret?What I meant to say was a table is a single component so once the mouse enters the table no more mouseOver events will be generated.
As you move the mouse around the table you are moving the mouse over rendered versions of a checkBox. Again since these are rendered versions you won't generate a mouseOver event.
When you generate a mousePressed event on a cell with a checkBox as an editor, the editor is invoked and the checkBox is painted in its "pressed" state, so again you won't see the rollover effect. When you release the mouse cell editing is stopped and the renderer is again displayed, so again you won't generate a mouseOver event on the checkBox.
So I don't think JTable is doing anything fancy to handle mouseOver or mouseExited events. Its just that they are only generated at the table level and not the cell level.
I haven't played with JTree or any fancy LAF's, so I'm not sure what to suggest. I'm surprised that JTree would work differently. -
How to highlight text in JLabel????
I m writing code for find functionality(similar to ctrl+f )..
I have a JTable with some of its cell contains JLabel...
I want to highlight some part of text from JLabel using using tableCellRenderer
(eg. text on JLabel is "India" & my search keyword is "In", then only first two letters of JLabel should get highlighted)..
It works, if Jtable contains string but not for any JComponent(like JLabel, JPanel, JCheckBox etc..) ..
Please help me out for this....
NOte: ---
I m posting some part of code that i have used to highlight string in a JTable cell..
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
// method to highlight WORD depending upon condition..
try {
high.addHighlight( i, j, highlight_painter ); // method to highlight word
catch (Exception e) {
e.printStackTrace();
return this;
}thanks in advance
suyogI am posting my code that i am using for highlighting text in JTable...
But this code is not working, if cell contains JLabel...
Can you please suggest me any solution to work this code for JLabel with plain text content & with hyperlink (formatted using HTML tags), with out affecting to its original functionality
(I am not getting what cramick want to suggest... )
public class TableCellRendererBug{
// code to highlight the specific WORD in JTable
Vector vrecord; // vector used in condition to highlight
JTable tab;
public DefaultHighlighter high ;
public void highlightWord(JTable table,Vector record){
tab=table;
vrecord =new Vector(1);
vrecord=record;
tab.setDefaultRenderer(Object.class, new CellHighlightRenderer());
class CellHighlightRenderer extends JTextField implements TableCellRenderer {
DefaultHighlighter.DefaultHighlightPainter highlight_painter =
new DefaultHighlighter.DefaultHighlightPainter(new Color(198,198,250));
public DefaultHighlighter high ;
public CellHighlightRenderer() {
high = new DefaultHighlighter();
setBorder( BorderFactory.createEmptyBorder() );
setHighlighter(high);
tab.updateUI();
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
// method to highlight WORD depending upon condition..
setFont(table.getFont());
setValue(value); // intialize object
* condition to execute addHighlight..
* Here i am using above mentioned Vector & all the things
if(condition){
try {
high.addHighlight( start, end, highlight_painter ); // method to highlight word
catch (Exception e) {
e.printStackTrace();
}//if
return this;
protected void setValue(Object value) {
// method to initialize value of object
setText((value == null) ? "" : value.toString());
}Thanks In advance..
Suyog -
Highlighting Text & Auto Text Options
I've recently migrated from MS Word to Pages, and I'm determined to make this new relationship work. In Word I used its highlighting text (as with a real highlighter--yellow, pink, etc.) feature, as well as its Auto Text feature, in which I had a number of prescribed, hyperlinked comments. (I'm a teacher, and I would auto text things like, "comma error," which would then be linked to a web page about comma errors.
Can anyone help me discover ways to do both of these in Pages? Also, is there anything for Pages like MS Word's macros?
Thanks in advance,
Brad CarpenterWelcome to the forums, Brad.
There is no direct analogue in Pages to Word's highlighting feature. However, you can use the Comments feature to add specific comments to a specific piece of text (with the advantage that the comments can be easily hidden, since you are not changing the characteristics of the actual text). Simply select a bit of text and click the Comment icon in the toolbar, or from the Insert menu select "Comment". The selected text will highlight in document, and a comments box will appear to the left of the page, in which you can type whatever you want. In the comments box you can select whatever text you want and make it a hyperlink, by going to the Hyperlink Inspector. Unfortunately, there is not an easy way to automate the creation of a hyperlink, at least as far as I know.
There are plenty of third-party applications that will let you store and add snippets of text easily to any Mac document, including Pages. These include TypeIt4Me, Butler, and even Quicksilver, which has a fanatical following and may be more than you need for this kind of task. I'm sure others here might be able to suggest other apps.
One caution, however: If you intend to be sharing documents with others, they must be using Pages themselves to take advantage of these features. Unless your students are also using Pages, these workarounds won't really help. -
How can I stop shared files in iBooks being highlighted by different family members?
I Have family sharing set up which is great for sharing apps and music however I have a problem with iBooks. My wife and I both use ePub files which a re study material. The great thing about these is that we can highlight and add notes to files.
THe problem is that our individual highlights and notes are shared with each other. So I get my wife's highlights and notes on top of mine.
We ha ve tried clearing all ePub files from my wife's ipad, and only syncing them to mine. She then downloads her own copy of the ePub file. So one has the original which is on our iMac and one has another copy. This makes no difference as iTunes recognises them as the same file.
We'd be happy to switch off family sharing for iBooks to prevent this but that doesn't seem possible. It's all or nothing. I can't turn off family sharing completely as my wife will lose access to our shared music library.
Does oes anyone have any suggestions? Basically, we want to share music and apps through family sharing but have a separate collection of books even though those books might be ide bridal before we annotate them.Have you tried going into the Preferences on iBooks on your Mac and unchecking the option for syncing across devices?
-
In previous versions of i Tunes I could highlight a song in my library and a genious list would show on the right side of the screen listing songs that were like the one highlighted. Now I do not get that list. Is there a way to get that back?
Hi again Bob,
I believe I've found the feature you were speaking about now. Information on the "In the Store" feature of iTunes can be found here:
Apple - iTunes - Inside iTunes - Using In the Store from within your iTunes Library.
http://www.apple.com/itunes/inside-itunes/2013/01/using-in-the-store-from-within -your-itunes-library.html
Thanks for using the Apple Support Communities. Have a good one!
-Braden -
Is there a way in Pages to show and print all the added "comments?" (those you add by highlighting text) I am a teacher, and I would like students to be able to view my comments on printed versions of their papers. I know word displays the comments off to the side of the document, and those comments can be viewed all at once and printed alongside the document.
There doesn't appear to be a way to print conmments in either Pages or Numbers in the Mavericks versions.
Jerry -
Why cant I highlight part of a document and print only what is selected in safari?
Why is it not possible to highlight and print the selection in Safari, thought the imac was supposed to do everything, WRONG.
I also have I.pad 2 and because it does not support adobe flash, I cannot open a magazine that I have each week, I have to do this on the imac, so when away from home it again doesnt do what I want it to. Does everything people say. WRONG AGAIN.
Should have stuck with the laptop, it actually does do these things mentioned above.I purchased the iPad first and waited a year HOPING Apple would fix this problem OR at the least provide something comparable to WINDOWS!
WRONG....and yes it is hard to believe for how ADVANCED Apple is.....that they don't have a simple easy program that allows you to HIGHLIGHT and PRINT ONLY what you highlight!
But....they are making leaps and bounds.....at least you can now cut & paste....thats a good thing!?
HOPEFULLY.......in the VERY,VERY NEAR FUTURE Apple will supply us with the simple software to do these simple time saving chores!
(highlight and print ONLY what you highlight)
Until then we have to cut and paste to several different apps or programs....hoping it will allow you to print ONLY WHAT THE USER WANTS TO PRINT! -
Highlighting multiple days in Month View?
Hello everyone & Happy Friday All !!!
I'm new to this forum, and VERY new to using ical -
Here's my question:
In my old method of using a calendar to do my schedule on my old PC -
I'd make a spreadsheet in MS Excel that would show me monthly views that I could highlight days,
weeks or entire months..... It's crude in comparison to ical, yet it IS effective for my needs......
I am used to highlighting either a single day or a string of days in my "month" view,
so... for example - let's say that Monday thru Thursday of next week I am going to be "out of the office in London - UK" -
I would simply highlight the four days of next week - and instead of leaving those cells "white"
like every other day in the month - I'd change those four cell's colored "fill" option from white to
bright yellow - (or any other color that signifies a specific action or function - like "green" for vacation days, or "blue" for a sick day or surgery, etc....
This way - that at a glance (literally) - I can tell that I'm "out of the office" on those days next week that are colored other than "white"..... NOTE: the ENTIRE CELL - Not Just the Day Title is colored......
(I wish I could insert a visual example of what I am trying to describe here...)
Is there a way of doing this same kind of function in ical - so that I can have an "at a glance" or
"heads up display" that I can see quickly and know I'm committed on those days next week - or
any week or group of days for that matter?
This would help me tremendously of there is a way of doing this...... Otherwise - I'll be STUCK
in the 90's using my improvised Excel Spreadsheet Calendar.....
Thanks in advance for your help
kevinWelcome to the discussions, azstoneconsulting.
In iCal colours are tied to specific calendars, so make a vacation calendar and a sick calendar (you forecast your sickness? Cool) and an out of office calendar and set the colours to whatever colour suits. Then when you are going to be in London select the out of office calendar and set it to last the four days. It will show as a coloured bar across those days in month view.
AK -
Hello :)
I am very happy when the Firefox browser suggests me sites I have already visited, when I just type one letter in the address bar, but I don't like that this letter gets highlighted in all the suggested urls,
I'd like Firefox always to offer me these suggestions, but if possible without highlighting the letter I type, and I don't know if I can (or how to if I can) change the settings of my browser to be so,
Can you please help me with that?
Thanks in advance :)The involved CSS code can be found in this file that you can open via the location bar.
* chrome://global/skin/autocomplete.css
Look for class .ac-emphasize-text and apply modified rules as you like.
You need to add the !important flag to override rules.
Add code to the <b>userChrome.css</b> file below the default @namespace line.
*http://kb.mozillazine.org/userChrome.css
<pre><nowiki>@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* only needed once */
@namespace html url("http://www.w3.org/1999/xhtml");
html|span.ac-emphasize-text {
box-shadow: none!important;
background-color: transparent !important;
border-radius: 0px;
text-shadow: none !important;
</nowiki></pre>
The customization files userChrome.css (user interface) and userContent.css (websites) are located in the <b>chrome</b> folder in the Firefox profile folder.
*http://kb.mozillazine.org/Editing_configuration
You can use this button to go to the currently used Firefox profile folder:
*Help > Troubleshooting Information > Profile Directory: Show Folder (Linux: Open Directory; Mac: Show in Finder)
* Create the chrome folder (lowercase) in the <xxxxxxxx>.default profile folder if this folder doesn't exist
* Use a plain text editor like Notepad to create a (new) userChrome.css file in this folder (the names are case sensitive)
* Paste the code in the userChrome.css file in the editor window and make sure that the userChrome.css file starts with the default @namespace line
* Make sure that you select "All files" and not "Text files" when you save the file via "Save file as" in the text editor as userChrome.css. Otherwise Windows may add a hidden .txt file extension and you end up with a not working userChrome.css.txt file -
How can I highlight more than one pic at a time?
First of all, THANKS for anyone that may answer since APPLE obviously has no desire to get off their ***** and help their customers.
About ten days ago I was prompted to install apples new operating system. So of course I clicked OK, idiot that I am!
Now I'm stuck with this new piece of **** operating system that I wish I could uninstall.
ANYWAY,
I upload a lot of pix for stuff I sell on EBay, sometimes 3-400 at a time. When I delete photos it's usually 1,000 at a time, and I assure you I'm not exaggerating. Up until now I was able to touch the END pic and swipe the whole horizontal row with two fingertips and the whole row of 7 would get checked. With the new ios7 I am unable to do it anymore (yet ANOTHER reason I don't want this 'improved' OS).
Does ANYONE know of a way to highlight more than one pic at a time?? Remember the old windows system where you could click one pic, then hit SHIFT and click a lower one and it would highlight them all, in between, for a quick delete?
There MUST be a way to delete, or rather highlight (or CHECK) more than one pic at a time? Anyone?
THANKS, RichYes, I know the photos stored on the device... But which app are you accessing the photos with? Which app do you want to be able to highlight more than one pic at a time in?
There are literally thosands of apps that access the iOS Photo Library - which one(s) are you using? -
In Pages 5.0 How do I change the highlight color?
In Pages 5.0 How do I change the highlight color?
Oh! I understand now. See screenshot below. It's called "Character Fill Color":
Maybe you are looking for
-
Inserted FLV files not playing in a published project.
The issue: Inserted FLV files display (play) when previewing a project but not in a published project. My setup: Windows XP and Captivate 5 Questions: 1) When in Filmstrip view only the movie playback bars show, not an image of the actual movie, i
-
Am Mac OS 10.4.11. Am trying to sync my iCal (2.0.5) using iTunes (7.6) to my 5G ipod video. When I click on 'Sync iCal Calendars' and hit apply a message comes up saying that I don't have any calendars available. I click on open iCal and it opens. I
-
Test Run Option in BAPI_REQUISITION_CREATE
Hi All, I want to run the BAPI BAPI_REQUISITION_CREATE in test mode, but BAPI doesn't have Test run field as input parameters as we have in some other BAPIs. Is there any way to run the BAPI_REQUISITION_CREATE in Test mode. Please guide me on this. T
-
Hi We have implemented a composite, where we are connecting to a systm using socket adapter. After moving to production we realize that our application is sending CLOSE_WAIT signal in the socket in predetermined interval, but the client application i
-
Yet another 10.4.7 Problem
Hello eveyone, please help... I've read through all the post about problems with the update and I fall into the category of "corrupted download" . -I re-downloaded the update and it was successful, -Ran the update, and it never came back. (spinning c