Swing flat button

Is there a way to render JButtons in swing as flat buttons? For a JToolbar you can use
JToolBar toolBar = new JToolBar();
toolBar.setRollover(true);So there's certainly some code to do this rendering already. But I don't find any such option on a JButton.
It's not my intention to create my own extension of a JButton to handle this.
If the toolbar can render buttons like this without changes, it should also be possible to render a plain button exactly the same without changes.
Thanks in advance

Fjoerie wrote:
Is there a way to render JButtons in swing as flat buttons? For a JToolbar you can use
JToolBar toolBar = new JToolBar();
toolBar.setRollover(true);So there's certainly some code to do this rendering already. But I don't find any such option on a JButton.
It's not my intention to create my own extension of a JButton to handle this.
If the toolbar can render buttons like this without changes, it should also be possible to render a plain button exactly the same without changes.
Thanks in advanceHi,
I noticed the same problem. The API doc says:
"The implementation of a look and feel may choose to ignore this property."
And I think the Metal Look & Feel does ignore it! :-(
I've written a controller to support this. Maybe you find it usefull (the library is Open Source):
[http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/CoolButtonController.html|http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/CoolButtonController.html]
Or use one of the XAction utility methods:
[http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/action/XActions.html|http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/action/XActions.html]
Homepage:
[http://www.softsmithy.org|http://www.softsmithy.org]
Download:
[http://sourceforge.net/project/showfiles.php?group_id=64833|http://sourceforge.net/project/showfiles.php?group_id=64833]
Source:
[http://sourceforge.net/svn/?group_id=64833|http://sourceforge.net/svn/?group_id=64833]
[http://softsmithy.svn.sourceforge.net/viewvc/softsmithy/trunk/lib/src/org/softsmithy/lib/|http://softsmithy.svn.sourceforge.net/viewvc/softsmithy/trunk/lib/src/org/softsmithy/lib/]
API:
[http://softsmithy.sourceforge.net/lib/docs/api/index.html|http://softsmithy.sourceforge.net/lib/docs/api/index.html]
-Puce

Similar Messages

  • Flat Buttons on the Firefox

    When i play certain Text based games using Firefox 7 , I see that all clickable buttons in that game are flattened , eg .. the button is like ""Try again"" "Do now" ""Attack"" "Run" "Do Crime"" all these clickable icons are as flat as the whole page . But when i use my Friend PC , he is using old firefox like 3.6 , there i saw all these clickable buttons or icons are distinctly elevated ones . So i totally have no idea how can i play my games with these old style elevated clickable link . Is it something to do with about:config or what ? Do think about my problem here .
    Thank you so much for the help.
    PS...I added 2 links for the icons i mentioned to make you all see clearly.
    1.This is the flat button that i dont like.
    http://img845.imageshack.us/img845/5690/flatbutton.jpg
    2.This is the elevated button that i want to use.
    http://img266.imageshack.us/img266/2159/elevated.jpg

    cor-el ! I have checked that color ..and yes it allowed pages to choose their own colors .
    1 clue i observed after reading ur links , i changed View -->Page Style ---> No style and yes these buttons turn as elevated ones but i cant use ""No style "" only for the sake of Elevated button coz page is too ugly..:P
    2nd clue i found out is .... it is nothing to do with Windows 7 or XP (already tested)
    Flat buttons has changed since Firefox 4. (Elevated buttons on old firefox)
    3rd clue is ....when i refresh that page which contains these buttons , i just quickly saw Elevated Buttons (in the middle of page loading) But once page loading has complete , it turns to Flat buttons.
    I will be so much impressed with the one who can find out this problem.

  • Java Swing GUI Button Image

    Hi, I really need help with this one, I have tried many things and looked at many pages for this but to no avail as of yet.
    I have a Swing GUI in which I want to display an image. The way I am displaying it at the moment is as a button icon as I do not need to be able to alter the images. I can also use the button functionality as displaying something when the image is clicked. So I have an array of image paths which are accesed to load an image into the button and a "Next" button to change the image as required.
    My problem is that when I load an image into the button it moves from it's original location. When there is no image displayed the button is where I want it to be, but when I load an image it moves, this cannot happen. Any ideas.
    Also, when I am trying to click thru the array of images, it starts at the 1st image in the array but then skips to the last image in the array. Here is the code for that.
    // Handle events that arise from the "Next" button being clicked
    private void jButton5MouseClicked(java.awt.event.MouseEvent evt) {
    if (jComboBox1.getSelectedIndex() == 1)
         for (int i = 1; i < juniorImageIndex.length; i++)
         jButton8.setIcon(new javax.swing.ImageIcon(juniorImageIndex));
    else if (jComboBox1.getSelectedIndex() == 2)
         for (int i = 1; i < seniorImageIndex.length; i++)
         jButton8.setIcon(new javax.swing.ImageIcon(seniorImageIndex[i]));
    juniorImageIndex and seniorImageIndex are obviuosly the arrrays with the file paths for the images. The reason I start at index 1 is that I use the 0 index image as the starting image for each part.
    Any help gratefully appreciated, I really hope someone can help, Thanks.

    // Handle events that arise from the "Next" button
    being clicked
    private void
    jButton5MouseClicked(java.awt.event.MouseEvent evt) {
      myImageIndex =(myImageIndex + 1) % imageArray.size();
      resetButtonImage();
    private void resetButtonImage() {
    if (jComboBox1.getSelectedIndex() == 1)
    {//take this out
    //> for (int i = 1; i < juniorImageIndex.length; i++)
    //> {
    jButton8.setIcon(new//> javax.swing.ImageIcon(array[myImageIndex]));
    //> }
    else if (jComboBox1.getSelectedIndex() == 2)
    {//this too
    //> for (int i = 1; i < seniorImageIndex.length; i++)
    //> {
    jButton8.setIcon(new
    javax.swing.ImageIcon(array2[myImageIndex]));//> }

  • Swing Odd Button , Label , Tab sizes with JRE1.4.1

    Hi,
    In some machines with Windows 2000 Professional Service Pack 3, we
    are observing the following problem:
    The Swing components become too large and the GUI looks disfigured.
    We are able to reproduce with in only one system with the following
    display driver configuration: nvidia vanta
    Has someone came across this problem ?
    It does not happen with 1.3.1 in the same machine.
    Any help will be appreciated.
    Thanks,
    Karthik

    We're having similar problem on one of the machine with Windows 2000 SP5. Did you find out what the problem was and how to fix it?
    Thanks,
    Kiran

  • Menus & Buttons

    Hi!
    I'd like to change my Java Swing program buttons. Now they sit on the button bar surface and kind of "stick out". Basically each of them is graphically separate. I'd like to make them all melted into the surface without the "stick out" effect, just like it is in, for example Internet Explorer 6.0. They should stick out only then, when the mouse pointer is over them. Can you tell me how to change this apparance?
    Thanks
    PS. The same with the menu.

    Because my poor english I don't understand the appearence of your buttons. But you can change the appearance of the buttons by creating a new UI class. I've already done another ButtonUI class for our application. I copy hier, just to see an example without comments because of the language for the javadoc is not english. It follows the appearance of the Metal L&F, the flat style.
    public class CoreButtonUI
    extends BasicButtonUI
    public CoreButtonUI() { }
    private final static CoreButtonUI buttonUI = new CoreButtonUI();
    private boolean defaults_initialized = false;
    protected int dashedRectGapX;
    protected int dashedRectGapY;
    protected int dashedRectGapWidth;
    protected int dashedRectGapHeight;
    protected Color focusColor;
    public static ComponentUI createUI(JComponent jcomponent)
    return buttonUI;
    public void installDefaults(AbstractButton button)
    super.installDefaults(button);
    if (!defaults_initialized)
    String pp = getPropertyPrefix();
    focusColor = UIManager.getColor(pp + "focus");
    dashedRectGapX = UIManager.getInt(pp + "dashedRectGapX");
    dashedRectGapY = UIManager.getInt(pp + "dashedRectGapY");
    dashedRectGapWidth = UIManager.getInt(pp + "dashedRectGapWidth");
    dashedRectGapHeight = UIManager.getInt(pp + "dashedRectGapHeight");
    defaults_initialized = true;
    public void uninstallDefaults(AbstractButton button)
    super.uninstallDefaults(button);
    defaults_initialized = false;
    protected void paintButtonPressed(Graphics g, AbstractButton abstractbutton)
    setTextShiftOffset();
    protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect)
    JButton button = (JButton)b;
    int width = b.getWidth();
    int height = b.getHeight();
    if (!button.isRolloverEnabled())
    g.setColor(focusColor);
    BasicGraphicsUtils.drawDashedRect(g, dashedRectGapX, dashedRectGapY,
    width - dashedRectGapWidth, height - dashedRectGapHeight);

  • Can we develop cells or push buttons with increaseing number  auotmatically

    hi all
       I am customizing a sinario which contains different number of  flats in different appartments. Sianrio is to customize Flat nos. as a blocks. 
    So if we give no.of Flats in an Appartment, can we get blocks with numbering with increase order. Is it possible to develop Text areas or Push buttons in GUI programming.
    if so please explain me.
      For example :  if we give number 10  then it should dispaly 10 blocks.
    thankyou,
    regards
    Hanuma

    Not sure if you can dynamically create buttons on a screen, however, you could use an ALV Grid and show a number of "flats" per line and react to each one as a hotspot.
    i.e.  Put up to 10 flats on a line.  then read the line and determine the one pushed by Field Name.
    you may be able to create a button in each cell of the grid, and perhaps name each one individually.
    The crude way would be to put the max number of buttons on a screen and simply set unavailable "Flats" button to active.= 0.
    Edited by: Paul Chapman on Dec 5, 2008 2:09 PM

  • JComboBox: Background color of button different to the popup

    Hello,
    I want to have a combo box in wich the background color of the arrow button would be different to the color of popup menu.
    I did this, but it didn't take the effect.
    setUI(new MetalComboBoxUI(){
                protected javax.swing.JButton createArrowButton() {
                    javax.swing.JButton button = new MetalComboBoxButton( comboBox,
                            icon,
                            comboBox.isEditable(),
                            currentValuePane,
                            popupList );
                    button.setMargin( new java.awt.Insets( 0, 10, 10, 30 ) );
                    button.setBorder(null);
                    button.setBackground(Color.green);
                    return button;
            });thanks in advance.

    Try this:import java.awt.Color;
    import java.awt.FlowLayout;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    import javax.swing.UIDefaults;
    import javax.swing.UIManager;
    import javax.swing.plaf.ColorUIResource;
    import javax.swing.plaf.basic.BasicComboBoxUI;
    public class ComboWithGreenButton {
       String [] data = {"option0", "option1", "option2", "option3"};
       JComboBox combo;
       void makeUI() {
          combo = new JComboBox(data);
          combo.setUI(new BasicComboBoxUI());
          JFrame frame = new JFrame("Combo with green button");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setSize(100, 60);
          frame.setLayout(new FlowLayout());
          frame.add(combo);
          frame.setLocationRelativeTo(null);
          frame.setVisible(true);
       public static void main(String[] args) {
          SwingUtilities.invokeLater(new Runnable() {
             public void run() {
                UIDefaults defaults = UIManager.getDefaults();
                defaults.put("ComboBox.buttonBackground",
                      new ColorUIResource(Color.GREEN));
                new ComboWithGreenButton().makeUI();
    }luck, db

  • How to set up a great Photoshop machine

    How to set up a great Photoshop machine
    From the blog of John Nack, [former?*] Photoshop Principal Program Manager
    At Photoshop World this week, performance testing lead Adam Jerugim
    presented a performance guide with hardware recommendations and
    information about the CS5 performance preferences.  I’ve put his notes
    in this post’s extended entry.
    http://blogs.adobe.com/jnack/2010/09/how-to-set-up-a-great-photoshop-machine.html#more-271 2
    Operating Systems: Mac OS 10.6.4 and Windows 7 64-bit
    CPU: Intel Core i7/Xeon or AMD Phenom II/Opteron with 4 cores. More than 4 cores gives diminishing returns.
    RAM: Enough to keep Efficiency readout at  100%. If Efficiency is low (<95%), adding RAM will provide biggest  benefit. 4GB will cover most digital photography uses. 8GB leaves room  for other apps and fits huge documents in RAM.
    Video Card: Any modern card with at least 512MB VRAM; 1GB if doing heavy 3D work.
    Disk: Use a separate disk for Photoshop  scratch. If you spend a lot of time opening / saving large data  files, another separate disk for data files will speed that up. Faster  disks are better. RAID0 is faster. SSD is faster yet. RAID0 of SSDs is  fastest but super expensive. If you have plenty of RAM (meaning your  Efficiency readout is 95% or more), separate/faster disks for scratch  provide minimal benefit. If Efficiency readout is low, a separate SSD  for Photoshop scratch will be a big win. SSD boot volume will speed  booting and app launch, but not Photoshop operations.
    Memory Usage: this should be no higher than  70% on systems running 32bit Photoshop or with less than 4GB of total  physical RAM. On systems with 8GB or more, use 70% if you plan on  running other applications at the same time as PS, or higher (up to 90%)  if you only plan on using PS on your system.
    Efficiency %: can be found in the document window drop-down options. Operations fit in RAM when this 95% or greater.
    History & Cache: if you work with small  documents with lots of layers, start with the Tall and Thin  button (which will set cache levels = 2, tile size = 128K/132K). If you  work with large documents with few layers, try the Big and Flat button  (which will set cache levels = 6, tile size = 1024K/1028K). Using more  history states uses more scratch disk space.  More history states may  also use more RAM, particularly when running actions or scripts on  large documents. If you see Efficiency drop below 95%, especially after  running actions, try reducing history states or adding RAM.
    Scratch Disks: a separate drive for Photoshop  scratch disk will avoid slowdowns from Photoshop and the OS trying  to access the disk at the same time. If your Efficiency number often  drops below 95%, the gain can be large. Faster disks are better. A RAID0  array is faster, an SSD faster still. If using a RAID or SSD, try  setting the Tile Size to 1024K – AMD CPUs prefer 132K / 1028K sizes, but  128K and especially 1024K are more efficient for RAID and SSD use  regardless of CPU type.
    GPU Settings: you can change GPU settings by  clicking on the Advanced Settings button. For more more modern  video cards there will be three options: Basic, Normal, Advanced.  Changes to this setting will only take effect after PS restart, and  would be worth experimenting with if painting performance is sluggish.
    Posted by John Nack          at 7:10 AM on September 03, 2010
    * I understand Mr. Nack may have moved to a different area of Adobe management?
    Wo Tai Lao Le
    我太老了

    Nice of you to point it out here as I at least don’t follow Mr.Nash’s blog regularly.

  • Can some one help me with this problem with my frame???

    i have gt a veri strange problem with my program,that is teh graphic changes only when i resize the the frame,if i dun resize,it will remain the same.However what i intended is that when i click on the radio button,it will change immediately to the respective pages.A simple version of my code is below,can someone helpl me solve it??(there is 3 different class)
    import java.awt.event.*;
    import javax.swing.*;
    public class MainPg extends JFrame implements ActionListener{
         private javax.swing.JPanel jContentPane = null;
         private javax.swing.JPanel buttons = null;
         private javax.swing.JRadioButton one = null;
         private javax.swing.JRadioButton two = null;
         private javax.swing.JPanel change = null;
         public MainPg() {
              super();
              initialize();
         private void initialize() {
              this.setSize(300, 200);
              this.setContentPane(getJContentPane());
              this.setName("mainClass");
              this.setVisible(true);
         private javax.swing.JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new javax.swing.JPanel();
                   jContentPane.setLayout(new java.awt.BorderLayout());
                   jContentPane.add(getButtons(), java.awt.BorderLayout.WEST);
                   jContentPane.add(getChange(), java.awt.BorderLayout.CENTER);
              return jContentPane;
         private javax.swing.JPanel getButtons() {
              if(buttons == null) {
                   buttons = new javax.swing.JPanel();
                   java.awt.GridLayout layGridLayout1 = new java.awt.GridLayout();
                   layGridLayout1.setRows(2);
                   layGridLayout1.setColumns(1);
                   ButtonGroup group=new ButtonGroup();
                   group.add(getOne());
                   group.add(getTwo());
                   buttons.setLayout(layGridLayout1);
                   buttons.add(getOne(), null);
                   buttons.add(getTwo(), null);
              return buttons;
         private javax.swing.JRadioButton getOne() {
              if(one == null) {
                   one = new javax.swing.JRadioButton();
                   one.setText("One");
                   one.setSelected(true);
                   one.addActionListener(this);
                   one.setActionCommand("one");
              return one;
         private javax.swing.JRadioButton getTwo() {
              if(two == null) {
                   two = new javax.swing.JRadioButton();
                   two.setText("Two");
                   two.addActionListener(this);
                   two.setActionCommand("two");
              return two;
         private javax.swing.JPanel getChange() {
              if(change == null) {
                   change = new javax.swing.JPanel();
              change.add(new One());
              return change;
         public static void main(String[] args){
              new MainPg();
         public void actionPerformed(ActionEvent e) {
              change.removeAll();
              if("one".equals(e.getActionCommand())){
                   change.add(new One());
              else{
                   change.add(new Two());
              change.repaint();
    import javax.swing.*;
    public class One extends JPanel {
         private javax.swing.JPanel jPanel = null;
         private javax.swing.JLabel jLabel = null;
         private javax.swing.JPanel jPanel1 = null;
         private javax.swing.JLabel jLabel1 = null;
         private javax.swing.JLabel jLabel2 = null;
         public One() {
              super();
              initialize();
         * This method initializes this
         * @return void
         private void initialize() {
              this.setLayout(new java.awt.BorderLayout());
              this.add(getJPanel(), java.awt.BorderLayout.NORTH);
              this.add(getJPanel1(), java.awt.BorderLayout.WEST);
              this.setSize(300, 200);
         * This method initializes jPanel
         * @return javax.swing.JPanel
         private javax.swing.JPanel getJPanel() {
              if(jPanel == null) {
                   jPanel = new javax.swing.JPanel();
                   jPanel.add(getJLabel(), null);
              return jPanel;
         * This method initializes jLabel
         * @return javax.swing.JLabel
         private javax.swing.JLabel getJLabel() {
              if(jLabel == null) {
                   jLabel = new javax.swing.JLabel();
                   jLabel.setText("one");
              return jLabel;
         * This method initializes jPanel1
         * @return javax.swing.JPanel
         private javax.swing.JPanel getJPanel1() {
              if(jPanel1 == null) {
                   jPanel1 = new javax.swing.JPanel();
                   java.awt.GridLayout layGridLayout2 = new java.awt.GridLayout();
                   layGridLayout2.setRows(2);
                   layGridLayout2.setColumns(1);
                   jPanel1.setLayout(layGridLayout2);
                   jPanel1.add(getJLabel2(), null);
                   jPanel1.add(getJLabel1(), null);
              return jPanel1;
         * This method initializes jLabel1
         * @return javax.swing.JLabel
         private javax.swing.JLabel getJLabel1() {
              if(jLabel1 == null) {
                   jLabel1 = new javax.swing.JLabel();
                   jLabel1.setText("one");
              return jLabel1;
         * This method initializes jLabel2
         * @return javax.swing.JLabel
         private javax.swing.JLabel getJLabel2() {
              if(jLabel2 == null) {
                   jLabel2 = new javax.swing.JLabel();
                   jLabel2.setText("one");
              return jLabel2;
    import javax.swing.*;
    public class Two extends JPanel {
         private javax.swing.JLabel jLabel = null;
         public Two() {
              super();
              initialize();
         * This method initializes this
         * @return void
         private void initialize() {
              this.setLayout(new java.awt.FlowLayout());
              this.add(getJLabel(), null);
              this.setSize(300, 200);
         * This method initializes jLabel
         * @return javax.swing.JLabel
         private javax.swing.JLabel getJLabel() {
              if(jLabel == null) {
                   jLabel = new javax.swing.JLabel();
                   jLabel.setText("two");
              return jLabel;
    }

    //change.repaint();
    change.revalidate();

  • Java Graphics -- Drawing Strings on JFrame

    Hello and thank you. I'm relatively young and I apologize for asking noob questions. The problem I am having is that I realized after 3 hours of research and then writing this code that when multiple JPanels are added to a JFrame, they overlap (I think) over each other. As a result, the output of this program below is at the bottom right of the frame, the number 841 appears (the last number in my array) and everything else is blank.
    And I could not at all understand how to create graphics objects. It kept giving me an error of not being able to be instantiated. And to be honest, I don't even really understand whats going on when I add the text to my JPanel. I never call paintComponents. And definately I could never even make a graphics object to provide it the parameter required. Anyway, I resolved to use Jpanels because they can be removed using the remove function of the JFrame. And It is vitally important that I can delete the strings off my frame. Here is my code:
    package main;
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    public class VisualFrame extends JFrame{
        ArrayList<JPanel> numbers = new ArrayList<JPanel>();
        public VisualFrame(){
            setSize(1000, 500);
            setTitle("Binary Search");
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setVisible(true);
        public void createPanels(int[] array){
            int x = 10;
            int y = 20;
            int xOffset = 50;
            int yOffset = 50;
            for(int i=0; i<array.length; i++){
                String num = Integer.toString(array);
    numPanel panel = new numPanel(num, x, y);
    numbers.add(panel);
    add(panel);
    x = x+xOffset;
    if(x>this.getWidth()){
    x = 10;
    y = y+yOffset;
    class numPanel extends JPanel{
    String num;
    int x;
    int y;
    public numPanel(String str, int x, int y){
    num = str;
    this.x = x;
    this.y = y;
    public void paintComponent(Graphics g){
    g.setColor(Color.black);
    g.setFont(new Font("Times", Font.BOLD, 12));
    g.drawString(num, x, y);
    My main method is inside of a different class:
        public static void main(String[] args){
            VisualFrame frame = new VisualFrame();
            frame.createPanels(array);
        }Firstly, do I even have the problem I'm having right? If so,
    Is there a way to restrict the size of the panels to the length and width of what it contains?
    Or can someone give me a good, very detailed link to how to use Graphics? Or perhaps someone could prove to me a good method.
    Edited by: 989946 on Mar 8, 2013 6:45 PM

    Why don't you start by learning from the experts?
    The Java Tutorial has sections that show how to use Java functionality.
    http://docs.oracle.com/javase/tutorial/
    The Graphiics section covers GUI and Swing
    http://docs.oracle.com/javase/tutorial/uiswing/index.html
    >
    Creating Graphical User Interfaces
    Creating a GUI with Swing — A comprehensive introduction to GUI creation on the Java platform.
    >
    And that section has links for trails such as how to use ALL of the different swing components including frames and panels
    http://docs.oracle.com/javase/tutorial/uiswing/components/index.html
    >
    Using Swing Components tells you how to use each of the Swing components — buttons, tables, text components, and all the rest. It also tells you how to use borders and icons.

  • In LabVIEW6i, is there a way to make particular elements of an array invisible while the others stay visible (without losing any element's info.)?

    I have an array of clusters. Each cluster pertains to a certain oscilloscope I am controlling. There is another control which specifies which oscilloscopes I have "on".
    If a particular oscilloscope is "on" I want its cluster to be VISIBLE in the array. If a particular oscilloscope is "off" I want its cluster to be INVISIBLE in the array.
    How can I implement this in my program without losing ANY of the info. in my array?

    I suggest to use two arrays; one for user interface holding the ON clusters,
    and one for internal use holding all clusters. The diagram periodically
    updates the internal array with user interface array data.
    By INVISIBLE do you mean "skipped from the array" or displayed as an empty
    placeholder? To hide an OFF cluster you could put in the cluster a flat
    button boolean that is small and transparent when ON and large enough to
    cover the whole cluster area (and other controls) when OFF.
    Jean-Pierre Drolet
    Scientech R&D
    "mcmastal" a écrit dans le message news:
    [email protected]..
    > In LabVIEW6i, is there a way to make particular elements of an array
    > invisible while the others stay visible (without losing any element's
    > info.)?
    >
    > I have an array of clusters. Each cluster pertains to a certain
    > oscilloscope I am controlling. There is another control which
    > specifies which oscilloscopes I have "on".
    > If a particular oscilloscope is "on" I want its cluster to be VISIBLE
    > in the array. If a particular oscilloscope is "off" I want its
    > cluster to be INVISIBLE in the array.
    > How can I implement this in my program without losing ANY of the
    > info. in my array?
    LabVIEW, C'est LabVIEW

  • Looking for a specific QuickTime player

    Hi,
    I'm looking for a specific QuickTime player. The one that has the interface with round buttons like tear drops and not the flat buttons the we have today. I think it is in version 6 of QuickTime but I'm not sure. If someone could send me only the player. If you need a picture of the buttons, I can send you one...
    Regards,
    Harmonium
    iMac G5   Mac OS X (10.4.4)  

    Well, is controlling Audacious from the tray all that... needed?
    I use Global Hotkeys and have quite a few bindings set up. They work surprisingly well.
    The list as it appears in the hotkey editor window:
    Previous Track: Control + Alt + Prior (PgUp)
    Play: Control + Alt + Return
    Pause/Resume: Pause
    Stop: Control + Alt + End
    Next Tracks: Control + Alt + Next (PgDn)
    Forward 5 seconds: Control + Alt + Right
    Rewind 5 seconds: Control + Alt + Left
    Volume Up: Control + Alt + Up
    Volume Down: Control + Alt + Down
    Pause/Resume: Control + Alt + Insert
    Stop: Control + Shift + F11
    Pause/Resume: Control + Shift + F12
    Next Track: Control + Shift + F10
    Forward 5 seconds: Control + Shift + F6
    Rewind 5 seconds: Control + Shift + F5
    Previous Track: Control + Shift + F9
    Toggle Player Windows: Super + e
    -dav7

  • I can't get ArrayList to work in my JTable

    I want to be able to dynamically add and remove data (and rows) from my JTable, and so I wanted to just Lists when I implemented it. I've tried 2 ways and they both didn't work. Can someone show me some sample code to do this?
    I tried 2 different methods:
    method 1:
    JTable Data_Table = new  JTable(data_Vector, Collumn_Names_Vector);when I started the applet I got an error saying Applet init error
    But the error could also have happened in 2 other places here. 1, I created 2 Lists instead of Vectors and converted them to Vectors when passing them to JTable using:
    new Vector(data)
    and 2, I may have created my 2 dimensional data List incorrectly. I tried:
    List Parent = new ArrayList();
    List child1 = new ArrayList();
    List child2 = new ArrayList();
    child1.add(data1)
    child2 ...
    Parent.add(child1)
    Parent.add(child2)and I tried:
    List Parent = new ArrayList();
    Object[] temp = { new Integer(); new Integer()};
    Parent.add(temp.asList);But as I said method 1 did not work.
    method 2:
    I tried creating my own TableModel.
    In this way, the applet would start, and I can see my collumn names, but the data is blank and all cells are invisible or nonexistent, I don't know which. How do I initialize the Table values? I'd like to have one row with all 0's when the Applet opens? I'd also like to see a row so I can edit it.
    then I used this code (inside my model):
            public int getColumnCount() {
                return Analog_columnNames.length;
            public int getRowCount() {
                return Analog_data.size();
            public String getColumnName(int col) {
                return Analog_columnNames[col];
            public Object getValueAt(int row, int col) {
                java.util.List aRow = (ArrayList)Analog_data.get(row);
             return  aRow.get(col);
            public void setValueAt(Object value, int row, int col) {
                if (getValueAt(0,col) instanceof Integer                       
                        && !(value instanceof Integer)) {                 
                    try {
                         java.util.List tmp =  (java.util.List) Analog_data.get(row);
                  tmp.set(col, (Object)new Integer(value.toString()));
                  fireTableCellUpdated(row, col);
                    } catch (NumberFormatException e) {
                } else {
                     java.util.List tmp =  (java.util.List) Analog_data.get(row);
              tmp.set(col, (Object)new Integer(value.toString()));
                    fireTableCellUpdated(row, col);
            }Analog_columnNames is a normal array

    this may help You have to remove the button from the columns
    otherwise You need som other classes.
           jTable1.addextrarowtotable(Name, aantal , prijs);CopyCalcTable.java
    import javax.swing.*;
    import java.util.Vector;
    import javax.swing.table.*;
    import java.text.DecimalFormat;
    public class CopyCalcTable extends JTable{
        protected CopyCalcTableModel model;
        CopyCalcTable(){
            super();
            Vector columns= new Vector();
            columns.add("Type");
            columns.add("Omschrijving");
            columns.add("P/S");
            columns.add("Aantal");
            columns.add("Prijs");
            columns.add("Verwijderen");
            model = new CopyCalcTableModel(columns,1);
            setModel(model);
        public void setColumSize(){
            TableColumn column;
            int width = getWidth();
            column = getColumnModel().getColumn(0);
            column.setResizable(false);
            column.setMinWidth((width*2)/14);
            column.setPreferredWidth((width*2)/14);
            column = getColumnModel().getColumn(1);
            column.setResizable(false);
            column.setMinWidth((width*6)/12);
            column.setPreferredWidth((width*2)/14);
            column = getColumnModel().getColumn(2);
            column.setMinWidth((width*1)/14);
            column.setResizable(false);
            column.setPreferredWidth((width*1)/14);
            column = getColumnModel().getColumn(3);
            column.setResizable(false);
            column.setMinWidth((width*1)/14);
            column.setPreferredWidth((width*1)/14);
            column = getColumnModel().getColumn(4);
            column.setResizable(false);
            column.setMinWidth((width*1)/14);
            column.setPreferredWidth((width*1)/14);
            column = getColumnModel().getColumn(5);
            column.setResizable(false);
            column.setMinWidth((width*2)/14);
            column.setPreferredWidth((width*2)/14);
        public void HideColum(){
            TableColumn column;
            int width = getWidth();
            column = getColumnModel().getColumn(0);
            column.setResizable(false);
            column.setMinWidth((width*2)/14);
            column.setPreferredWidth((width*2)/14);
            column = getColumnModel().getColumn(1);
            column.setResizable(false);
            column.setMinWidth((width*6)/12);
            column.setPreferredWidth((width*2)/14);
            column = getColumnModel().getColumn(2);
            column.setMinWidth((width*1)/14);
            column.setResizable(false);
            column.setPreferredWidth((width*1)/14);
            column = getColumnModel().getColumn(3);
            column.setResizable(false);
            column.setMinWidth((width*1)/14);
            column.setPreferredWidth((width*1)/14);
            column = getColumnModel().getColumn(4);
            column.setResizable(false);
            column.setMinWidth((width*1)/14);
            column.setPreferredWidth((width*1)/14);
            column = getColumnModel().getColumn(5);
            column.setResizable(false);
            column.setMinWidth(0);
            column.setPreferredWidth(0);
        public void removefirstrow(){
            model.removeRow(0);
        public void removeTotalrow(){
            model.removeRow(model.getRowCount()-1);
        public void addTotalrow(){
            Vector data;
            String Col_Bediening = "";
            String Col_Uitboek ="";
            String Col_Rectoverso="";
            String Col_Formaat="";
            String Col_Kleur="";
            String Col_Gewicht="";
            Double Col_PS;
            String Col_Aantal;
            Double Col_Prijs;
            data = new Vector();
            Col_Prijs = new Double("0.00");
            double totaal= Col_Prijs.doubleValue();
            // number of extra's
            java.text.NumberFormat nf =  java.text.NumberFormat.getInstance();
            // set whether you want commas (or locale equivalent) inserted
            nf.setGroupingUsed(true );
            // set how many places you want to the right of the decimal.
            nf.setMinimumFractionDigits(2 );
            nf.setMaximumFractionDigits(2 );
            // set how many places you want to the left of the decimal.
            nf.setMinimumIntegerDigits(1 );
            int rows = model.getRowCount();
            for (int i = 0;i < rows; i++){
                Double d = new Double((String) model.getValueAt(i, 4));
                totaal += d.doubleValue();
            Col_Prijs = new Double(totaal*1.00);
            data.add("Totaal : EUR");
            data.add("");
            data.add(new String(""));
            data.add("");
            data.add(nf.format(Col_Prijs));
            //data.add(Col_Prijs.toString());
            javax.swing.JButton button = new javax.swing.JButton("EUR");
            data.add(button);
            model.addRow(data);
            setColumSize();
        public void addkopierowtotable(Integer aantal, double prijs, String omschrijving){
            Vector data;
            CopyCalcTableModel model = (CopyCalcTableModel) getModel();
            Double Col_PS;
            String Col_Aantal;
            Double Col_Prijs;
            //model.addColumn("Verwijderen");
            data = new Vector();
            Col_PS = new Double(prijs);
            Col_Aantal = new String(aantal.toString());
            Col_Prijs = new Double(prijs*aantal.intValue());
            data.add("Kopie�n");
            data.add(omschrijving);
            data.add(Col_PS.toString());
            data.add(Col_Aantal);
            data.add(Col_Prijs.toString());
            javax.swing.JButton button = new JButton("Verwijderen");
            button.addMouseListener(new MyJButtonMouseListener(this));
            data.add(button);
            removeTotalrow();
            model.addRow(data);
            addTotalrow();
        public void addextrarowtotable(String Name, Integer aantal, double prijs){
            Vector data;
            Double Col_PS;
            String Col_Aantal;
            Double Col_Prijs;
            data = new Vector();
            Col_PS = new Double(prijs);
            Col_Aantal = new String(aantal.toString());
            Col_Prijs = new Double(prijs*aantal.intValue());
            data.add("Extra");
            data.add(Name);
            data.add(Col_PS.toString());
            data.add(Col_Aantal);
            data.add(Col_Prijs.toString());
            javax.swing.JButton button = new javax.swing.JButton("Verwijderen");
            button.addMouseListener(new MyJButtonMouseListener(this));
            data.add(button);
            removeTotalrow();
            model.addRow(data);
            addTotalrow();
        public void addspiraalrowtotable(String Name, Integer aantal, double prijs){
            Vector data;
            Double Col_PS;
            String Col_Aantal;
            Double Col_Prijs;
            //model.addColumn("Verwijderen");
            data = new Vector();
            Col_PS = new Double(prijs);;
            Col_Aantal = new String(aantal.toString());
            Col_Prijs = new Double(prijs*aantal.intValue());
            data.add("Spiraal");
            data.add(Name);
            data.add(Col_PS.toString());
            data.add(Col_Aantal);
            data.add(Col_Prijs.toString());
            javax.swing.JButton button = new javax.swing.JButton("Verwijderen");
            button.addMouseListener(new MyJButtonMouseListener(this));
            data.add(button);
            removeTotalrow();
            model.addRow(data);
            addTotalrow();
        public void addklemrugrowtotable(String Name, Integer aantal, double prijs){
            Vector data;
            Double Col_PS;
            String Col_Aantal;
            Double Col_Prijs;
            //model.addColumn("Verwijderen");
            data = new Vector();
            Col_PS = new Double(prijs);
            Col_Aantal = new String(aantal.toString());
            Col_Prijs = new Double(prijs*aantal.intValue());
            data.add("Klemrug");
            data.add(Name);
            data.add(Col_PS.toString());
            data.add(Col_Aantal);
            data.add(Col_Prijs.toString());
            javax.swing.JButton button = new javax.swing.JButton("Verwijderen");
            button.addMouseListener(new MyJButtonMouseListener(this));
            data.add(button);
            removeTotalrow();
            model.addRow(data);
            addTotalrow();
        public void addplastificerenrowtotable(String Name, Integer aantal, double prijs){
            Vector data;
            Double Col_PS;
            String Col_Aantal;
            Double Col_Prijs;
            //model.addColumn("Verwijderen");
            data = new Vector();
            Col_PS = new Double(prijs);
            Col_Aantal = new String(aantal.toString());
            Col_Prijs = new Double(prijs*aantal.intValue());
            data.add("Plastcificeren");
            data.add(Name);
            data.add(Col_PS.toString());
            data.add(Col_Aantal);
            data.add(Col_Prijs.toString());
            javax.swing.JButton button = new javax.swing.JButton("Verwijderen");
            button.addMouseListener(new MyJButtonMouseListener(this));
            data.add(button);
            removeTotalrow();
            model.addRow(data);
            addTotalrow();
        public int getRowCount() {
            if ( model == null ){
                return 0;
            }else {
                return model.getRowCount();
    class CopyCalcTableModel extends AbstractTableModel {
        Vector data;
        Vector columnNames;
        CopyCalcTableModel(Vector head_vec, int rows) {
            columnNames = (Vector) head_vec.clone();
            //    coldata = new Vector(columnNames.size());
            data = new Vector(rows);
        CopyCalcTableModel(Vector head_vec) {
            columnNames = (Vector) head_vec.clone();
            //    coldata = new Vector(columnNames.size());
            data = new Vector();
        CopyCalcTableModel(Vector col_vec, Vector head_vec) {
            Vector coldata;
            columnNames = (Vector) head_vec.clone();
            data = (Vector) col_vec.clone();
        public int getColumnCount() {
            //        System.out.println(columnNames);
            return columnNames.size();
        public int getRowCount() {
            //        System.out.println(data);
            return data.size();
        public void removeRow(int row) {
            //        System.out.println(data);
            data.removeElementAt(row);
            fireTableStructureChanged();
        public String getColumnName(int col) {
            return (String) columnNames.elementAt(col);
        public Object getValueAt(int row, int col) {
            Vector v_row;
            Vector v_col;
            v_row = (Vector) data.elementAt(row);
            return v_row.elementAt(col);
         * JTable uses this method to determine the default renderer/
         * editor for each cell.  If we didn't implement this method,
         * then the last column would contain text ("true"/"false"),
         * rather than a check box.
        public Class getColumnClass(int c) {
            // return getValueAt(0, c).getClass();
            int rowIndex = 0;
            Object o = getValueAt(rowIndex, c);
            if (o == null) {
                return Object.class;
            } else {
                // System.out.println(o.getClass());
                return o.getClass();
         * Don't need to implement this method unless your table's
         * editable.
        public boolean isCellEditable(int row, int col) {
            //Note that the data/cell address is constant,
            //no matter where the cell appears onscreen.
            /*Vector v_row;
            v_row = (Vector) data.elementAt(row);
            if (col == 10 ) {
                return true;
            } else {
                return false;
            return false;
         * add collumn
        public void addColumn(String label, Object value){
            columnNames.add(label);
            for ( int i=0;data.size()>i;i++){
                Vector row = (Vector) data.elementAt(i);
                row.add(value);
                data.setElementAt(row, i);
            fireTableStructureChanged();
        public void addRow(Vector values){
            data.add(values);
            fireTableStructureChanged();
         * Don't need to implement this method unless your table's
         * data can change.
        public void setValueAt(Object value, int lrow, int lcol) {
    }

  • How can I have acces to a component of a window from a menu

    In a JInternalFrame, I have one Button.
    I try to access to this Button from a ActionListener of a JMenuBar.
    In the ActionListener of the JMenuBar, I have use the function "MyActiveFrame = MyDesktop.getSelectedFrame();" for having a pointer to my JInternalFrame.
    But I don't arrive to access to a component of my JInternalFrame.
    I have try "Button Boutton1 = MyDesktop.Boutton1;" but that don't work. It always say :
         java:56: cannot resolve symbol
         symbol : variable Boutton1
         location: class javax.swing.JDesktopPane
                        Button Boutton1 = MyDesktop.Boutton1;
    ^
    Is someone can tell my how I can have acces of this Button (and to the others component of my JInternalFrame from my JMenuBar).
    dank you in advance.

    No, that's not the problem. The problem is:
        JInternalFrame MyActiveFrame;
        MyActiveFrame = MyDesktop.getSelectedFrame();
        Button Boutton1 = MyActiveFrame.Boutton1;You are declaring MyActiveFrame as a JInternalFrame, not as the class you defined that extends JInternalFrame. Since JInternalFrame has no member named Boutton1, then MyActiveFrame.Boutton1 will cause the error.
    For example:
        public class MyFrame extends JInternalFrame {
            public Button Boutton1 = ...;
        };If you did something like:
        JInternalFrame frame = getOneOfMyFrames();
        Button b = frame.Boutton1;You would get an error. You need to do:
        MyFrame frame = getOneOfMyFrames();
        Button b = frame.Boutton1;Know what I mean?
    Jason

  • File chooser internationalization problem

    Hello All!
    I'm trying to have Armenian texts on Swing components.
            Locale hay = new Locale("hy", "HY");
            Locale.setDefault(hay);
            UIManager.put("FileChooser.openDialogTitleText", "&#1330;&#1377;&#1409;&#1381;&#1388;");
            UIManager.put("FileChooser.saveDialogTitleText", "&#1354;&#1377;&#1392;&#1381;&#1388;");
            UIManager.put("FileChooser.lookInLabelText", "&#1363;&#1398;&#1407;&#1408;&#1381;&#1388;");
            UIManager.put("FileChooser.saveInLabelText", "&#1354;&#1377;&#1392;&#1381;&#1388;");
            UIManager.put("FileChooser.upFolderToolTipText", "&#1348;&#1387; &#1348;&#1377;&#1391;&#1377;&#1408;&#1380;&#1377;&#1391; &#1358;&#1381;&#1408;&#1415;");
            UIManager.put("FileChooser.homeFolderToolTipText", "&#1329;&#1399;&#1389;&#1377;&#1407;&#1377;&#1383;&#1391;&#1408;&#1377;&#1398;");
            UIManager.put("FileChooser.newFolderToolTipText", "&#1357;&#1407;&#1381;&#1394;&#1390;&#1381;&#1388; &#1350;&#1400;&#1408; &#1354;&#1377;&#1398;&#1377;&#1391;");
            UIManager.put("FileChooser.listViewButtonToolTipText", "&#1361;&#1400;&#1410;&#1409;&#1377;&#1391;");
            UIManager.put("FileChooser.detailsViewButtonToolTipText", "&#1348;&#1377;&#1398;&#1408;&#1377;&#1396;&#1377;&#1405;&#1398;&#1381;&#1408;");
            UIManager.put("FileChooser.fileNameHeaderText", "&#1329;&#1398;&#1400;&#1410;&#1398;");
            UIManager.put("FileChooser.fileSizeHeaderText", "&#1342;&#1377;&#1406;&#1377;&#1388;");
            UIManager.put("FileChooser.fileTypeHeaderText", "&#1359;&#1381;&#1405;&#1377;&#1391;");
            UIManager.put("FileChooser.fileDateHeaderText", "&#1363;&#1400;&#1411;&#1400;&#1389;&#1396;&#1377;&#1398; &#1329;&#1396;&#1405;&#1377;&#1385;&#1387;&#1406;");
            UIManager.put("FileChooser.fileAttrHeaderText", "&#1344;&#1377;&#1407;&#1391;&#1377;&#1398;&#1387;&#1399;&#1398;&#1381;&#1408;");
            UIManager.put("FileChooser.fileNameLabelText", "&#1350;&#1399;&#1400;&#1409;&#1387; &#1329;&#1398;&#1400;&#1410;&#1398;");
            UIManager.put("FileChooser.filesOfTypeLabelText", "&#1350;&#1399;&#1400;&#1409;&#1398;&#1381;&#1408;&#1387; &#1359;&#1381;&#1405;&#1377;&#1391;&#1398;&#1381;&#1408;");
            UIManager.put("FileChooser.openButtonText", "&#1330;&#1377;&#1409;&#1381;&#1388;");
            UIManager.put("FileChooser.openButtonToolTipText", "&#1330;&#1377;&#1409;&#1381;&#1388; &#1336;&#1398;&#1407;&#1408;&#1406;&#1377;&#1390; &#1350;&#1399;&#1400;&#1409;&#1384;");
            UIManager.put("FileChooser.saveButtonText", "&#1354;&#1377;&#1392;&#1381;&#1388;");
            UIManager.put("FileChooser.saveButtonToolTipText", "&#1354;&#1377;&#1392;&#1381;&#1388; &#1336;&#1398;&#1407;&#1408;&#1406;&#1377;&#1390; &#1350;&#1399;&#1400;&#1409;&#1384;");
            UIManager.put("FileChooser.directoryOpenButtonText", "&#1354;&#1377;&#1392;&#1381;&#1388;");
            UIManager.put("FileChooser.directoryOpenButtonToolTipText", "&#1354;&#1377;&#1392;&#1381;&#1388; &#1336;&#1398;&#1407;&#1408;&#1406;&#1377;&#1390; &#1350;&#1399;&#1400;&#1409;&#1384;");
            UIManager.put("FileChooser.cancelButtonText", "&#1332;&#1377;&#1380;&#1377;&#1408;&#1381;&#1409;&#1398;&#1381;&#1388;");
            UIManager.put("FileChooser.cancelButtonToolTipText", "&#1332;&#1377;&#1380;&#1377;&#1408;&#1381;&#1409;&#1398;&#1381;&#1388; &#1350;&#1399;&#1400;&#1409; &#1336;&#1398;&#1407;&#1408;&#1396;&#1377;&#1398; &#1333;&#1408;&#1391;&#1389;&#1400;&#1405;&#1400;&#1410;&#1385;&#1397;&#1377;&#1398; &#1354;&#1377;&#1407;&#1400;&#1410;&#1392;&#1377;&#1398;&#1384;");
            UIManager.put("FileChooser.newFolderErrorText", "&#1350;&#1400;&#1408; &#1354;&#1377;&#1392;&#1400;&#1409;&#1387; &#1357;&#1407;&#1381;&#1394;&#1390;&#1396;&#1377;&#1398; &#1357;&#1389;&#1377;&#1388;");
            UIManager.put("FileChooser.acceptAllFileFilterText", "&#1330;&#1400;&#1388;&#1400;&#1408; &#1350;&#1399;&#1400;&#1409;&#1398;&#1381;&#1408;");Only DialogTitleText is working. And if I'm trying to internationalize other Swing components: buttons and so on, the only problem with JFrame title is.
    I'm working on WindowsXP, and java version is 1.6.0_17.
    Thanks in advance!
    Astghik

    The quick answer:
    You can't use JFileChooser unless you sign the applet.

Maybe you are looking for