Displaying a matrix in swing----HELP!! :)

Hello I want to print out values from a matrix in some sort of table.
javax.swing.JTable is almost what I want, but you can't do row labels (only column labels, I think)--
Are there any classes like JTable, but a little more like an Excel spreadsheet where you have labels on the columns and rows???
Or any other suggestions for displaying matrix values with swing would be helpful!!
THANKS!!!!

.

Similar Messages

  • Displaying a matrix in Swing

    Hi all,
    Is there anybody who knows a easy way of displaying a matrix in Swing. It can be done by declaring a lot of buttons (64 buttons in a 8x8 matrix) and than displaying them, but there has to be a better way. Any suggestions
    Greetings.
    Vincent

    You could use AWT or Java2D graphics to display them within a JPanel. Just override the paintComponent(Graphics g) method (don't forget to call super.paintComponent(g) first) and do the drawing in there.
    If you need interaction, you could implement a MouseMotionListener and MouseListener to see over which element the mouse is over and in which a mouse button was clicked (or even double-clicked).
    class MyMatrixPanel extends JPanel implements MouseListener, MouseMotionListener {
    public void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.setColor(Color.white);
    g.fillRect(0,0,this.getWidth(),this.getHeight());
    g.setColor(Color.black);
    for(int i = 0; i < number_of_rows+1; i++) {
    g.drawLine(x1,y1,x2,y2);
    g.drawString("m00",x,y);
    for(int i = 0; i < number_of_columns+1; i++)
    g.drawLine(x1,y1,x2,y2);
    The JPanel will need to be added to a JFrame, JDialog, or similar. You'll have to supply the coordinates, and of course this is skeletal. Let me know if this helps and if you need more info.
    Robert Templeton

  • Display Unicode Character in Swing Objects

    I am trying to display Chinese Characters using Swing GUI.
    I created Unicode strings using escape character \uXXXX
    I displayed \u4e00 successfully
    However when I tried to display \ub8db i got a square box displayed instead.
    I am using: Winnt ver 4 ,RichWin 97
    private Object listData[] = {
    new String("\ucfe3\ub8db"), // Two boxes displayed in list
    new String("\u4e01\u4e00"), // Characters displayed correctly
    new String("Third selection")
    To hope to get some replies ASAP. Thanks!!!
    Regards,
    Patrick

    Hi Patrick,
    Yeh, fonts are rather ubiquitous when it comes to internationalization. The fact that the font.properties files still exist confuses a lot of people. In reality, Sun doesn't support them any more, and they aren't all that useful if you're actually deploying your code onto other machines.
    So, to answer your questions... :D
    1) Each component will have a font set on it. To start with, each component will end up with the JDK default, usually the Dialog font in Java. From memory, I think this maps to Arial on Windows systems, though I'm not sure if RichWin alters this in anyway, as I haven't used it myself.
    You can check the available fonts on your machine by calling:
    GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
    This returns an array of strings. You can basically create a new font from any of the names that appear in here. For instance, if one of the strings was "Arial Bold", you could create the following font:
    Font myFont = new Font("Arial Bold", Font.PLAIN, 12);
    2) The best way is to simply create the font you want on startup. If you can't rely on the font
    you need being installed on every machine you plan to run your program on, the best solution is to either install it on startup, or carry it around with you.
    Have a look at Font.createFont(), as it allows you to create a new Font object from a *.TTF file (a TrueType font). In JDK1.3, this is buggy, leaving a large temp file behind every time you run it, but I've already tried this under Merlin Beta, and it's fixed and working fine.
    The reason this is handy is because the font we keep talking about on here, Arial Unicode MS, is a TrueType font. So you can carry the font around with you, and load it on startup using this call.
    Arial Unicode MS is a 23Mb font, but it's capable of displaying just about any character you could imagine.
    The trick from there, once you've loaded your font, is to make sure you call setFont() on just about any component you create. Menus are a cow - you've got to listen for events, as the dropdown menus don't always get the font straight away. But other than that, it's fairly simple.
    3) The short answer is to call the getAvailableFontFamilyNames() call above, and look for any familiar font names. If you can't find any, you know you're not going to be able to display anything.
    Windows seems to have standard fonts for the international languages. In Chinese, this is SimHei for Simplified (mainland) Chinese, and MingLiU for Traditional (Taiwanese) Chinese. Simplified covers about 30,000 Kanji, while Traditional covers around 80,000.
    So for Chinese, you would look for "SimHei" and "MingLiU", plus any of the fonts capable of displaying anything, like "Arial Unicode MS". If none of these strings are in the array, you may want to carry the Arial Unicode MS installer around with you and execute it. This file is about 11Mb, and is available as a download off the Microsoft website.
    4) Probably about the most useful thing I've come across is the Sun I18N tutorial on this very website. There isn't a heck of a lot out there, unfortunately. About the only other things I can recommend are http://www.unicode.org for the Unicode character codes, and http://www.njstar.com for NJStar Communicator, which you'll find useful if you're working with Chinese.
    Oh, and watch this forum, of course. ;D
    Hope that helps!
    Martin Hughes

  • Displaying image on the swings application

    Hi All,
    I want to display images onto my swing application. I was using ImageIcon and Class to getResource(filename). It can only provide me images that i have placed in my package not outside my package.
    Please help me, how to to do?
    Thanks in advance.

    [url http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html]How to Use Icons

  • The status bar is pushed up at about 3/4 of the screen, so I can view onlu firefox at about 1/4, good thing there is a scroll bar, but below the status bar is white display? can u please help me, I want to drag down the status bar so I can have a full vi

    The status bar is pushed up at about 3/4 of the screen, so I can view only Firefox at about 1/4, good thing there is a scroll bar, but below the status bar is white display? can u please help me, I want to drag down the status bar so I can have a full view
    == This happened ==
    Every time Firefox opened

    Your code is absolutely unreadable - even if someone was willing to
    help, it's simply impossible. I do give you a few tips, though: If you
    understand your code (i.e. if it really is YOUR code), you should be
    able to realize that your minimum and maximum never get set (thus they
    are both 0) and your exam 3 is set with the wrong value. SEE where
    those should get set and figure out why they're not. Chances are you
    are doing something to them that makes one 'if' fail or you just
    erroneously assign a wrong variable!

  • HT201263 I Have an iPhone 5 runnig ios 7.0.4. It wont start as the apple logo keeps on blinking when i connect to wall charger or itunes. I even tried to restore it but an error 21 is being displayed. Any one can help me in this situation

    I Have an iPhone 5 runnig ios 7.0.4. It wont start as the apple logo keeps on blinking when i connect to wall charger or itunes. I even tried to restore it but an error 21 is being displayed. Any one can help me in this situation

    Read http://support.apple.com/kb/ts3694#

  • I installed CS6 on my new retina MacBook pro laptops. InDesign and Acrobat display document pixilated. I ran the updates and it fixed Illustrator and Photosho, but not InDesign and Acrobat. What can I do to make them display in high resolution? HELP!

    I installed CS6 on my new retina MacBook pro laptops. InDesign and Acrobat display document pixilated. I ran the updates and it fixed Illustrator and Photosho, but not InDesign and Acrobat. What can I do to make them display in high resolution? HELP!

    InDesign CS6 is not optimized for retina displays. You’ll need to move to Creative Cloud for retina compatibility.

  • Hello My ipads Power button is not working properly when I press it once it shows option to turn off instead of locking and some other display problems like it suddenly lockes down or display disappears ...Please help. Thank You

    Hello My ipads Power button is not working properly when I press it once it shows option to turn off instead of locking and some other display problems like it suddenly lockes down or display disappears ...Please help. Thank You

    Thanks for that information!
    I'm sure I will be calling AppleCare, but the problem is, they charge for the phone calls don't they? Because I don't have money to be spending to be on the phone with a support service.
    In other things, it seemed like the only time my MacBook was working was when I had Snow Leopard without the 10.6.8 update download that was supposed to be done to prepare for OS X Lion.
    When I look at the information of my HD it says that I have 10.6.8 but that was the install that it claimed to have failed and caused me to restart resulting in all of the repeated problems.
    Also, because my computer is currently down, and I've lost all files how would that effect the use of my iPhone? Because if it doesn't get fixed by the time OS 5 is released, how would I be able to upgrade?!

  • Banner image will not display in Dreamweaver; can you help?

    Banner image will not display in Dreamweaver; can you help?

    If the banner image is not displaying, it is either not in an acceptable web file format (optimized for web as jpg, gif or png). Or it is corrupted.  Or the path to the image file on server is broken. 
    It's impossible to say more without a link to your problem page.
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/

  • I just updated to 10.8.4 and my mail program is showing a series of boxes with AAAAs inside them instead of the email addresses. Also when on Safari web pages are displaying the same AAAAAs instead of type. Firefox displays fine. Can someone help me?

    I just updated to 10.8.4 and my mail program is showing a series of boxes with AAAAs inside them instead of the email addresses. Also when on Safari web pages are displaying the same AAAAAs instead of type. Firefox displays fine. Can someone help me?

    Restart your Mac and immediately hold down the Shift key when you hear the startup chime to boot into Safe Mode. Keep holding the Shift key until you see a progress bar towards the bottom of the screen. You can let go of the Shift key at that point.
    OS X asks you to log in (you will get this screen on a Safe Mode boot even if your Mac is set to automatically log in). Let the Mac finish booting to the desktop and then restart normally. This will clear Font Book's database and the cache files of the user account you logged into in Safe Mode.
    Next, close all running applications. From an administrator account, open the Terminal app and enter the following command. You can also copy/paste it from here into the Terminal window:
    sudo atsutil databases -remove
    Terminal will then ask for your admin password. As you type, it will not show anything, so be sure to enter it correctly.
    This removes all font cache files. Both for the system and the current user font cache files. After running the command, close Terminal and immediately restart your Mac.

  • Displaying a matrix on a Forms 6 form

    Guys:
    I'm trying to figure out a way to display
    a matrix on a form with three fields
    2 text items and 1 check box eg.
    Dept
    ====
    Emp Finance Projects Transport ...
    ===
    John X
    Tom X
    Sam X
    Pete X X
    Any ideas???
    Thanks!
    Abhay

    Hi
    I had similar problem. May be my dicision will be helpfull for you.
    There are table (for simplicity) sheet(emp, day, job) with the primary key(emp, day). It's needed matrix with X axis as 'emp', Y axis as 'day' (for a one month) and 'job' as the cell.
    I created block SHEET_BLOCK with the items: EMP, DAY_01, DAY_02, ..., DAY_31. 'Query Data Souce Name' is:
    SELECT emp FROM sheet;
    EMP is the 'Database Item', but another (DAY_??) aren't 'Database Item'.
    Cteated POST_QUERY trigger for populating fields DAY_??:
    DECLARE
    v_dest_item VARCHAR2(80);
    v_rec_num NUMBER;
    CURSOR c_emp_day_job IS
    SELECT day, job
    FROM sheet
    WHERE emp = :SHEET_BLOCK.EMP
    BEGIN
    IF :System.Mode != 'QUERY' THEN
    RETURN;
    END IF;
    FOR v_emp_day_job IN c_emp_day_job LOOP
    v_dest_item := ':SHEET_BLOCK.DAY_' &#0124; &#0124; v_emp_day_job.day;
    COPY( v_emp_day_job.job, v_dest_item );
    END LOOP;
    END;
    Andrew.

  • Displaying a matrix onto screen

    hi guys, i'm trying to make a game. i'm going to load a two dimensional array with images and then display the whole matrix onto the screen and then add stuff to it like mouselistener.
    static Object image[][] = new Object[300][300];
    i only have a frame now. Can anyone teach me how to display the matrix?

    If you know the 2D API, full screen mode only involves a few more method calls, and a switch to active rendering:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import java.io.*;
    import java.net.*;
    import javax.imageio.*;
    public class FlipExample extends Window {
        public static void main(String[] args) throws Exception {
            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice gd = ge.getDefaultScreenDevice();
            try {
                FlipExample w = new FlipExample();
                gd.setFullScreenWindow(w);
                w.animate();
            } catch(Exception e) {
                e.printStackTrace();
                throw e;
            } finally {
                gd.setFullScreenWindow(null);
                System.exit(0);
        private boolean quit = false;
        private BufferedImage orig;
        private int offset = 0, x, dx=2, y, dy=2, UBX, UBY;
        public FlipExample() throws IOException {
            super(new Frame());
            setIgnoreRepaint(true);
            addMouseListener(new MouseAdapter(){
                public void mousePressed(MouseEvent e) {
                    if (e.getClickCount() > 1)
                        quit = true;
            orig = ImageIO.read(new URL("http://today.java.net/jag/bio/JagHeadshot-small.jpg"));
        public void animate() {
            createBufferStrategy(2);
            BufferStrategy bs = getBufferStrategy();
            UBX = getWidth()-orig.getWidth();
            UBY = getHeight()-orig.getHeight();
            for(int times=0; !quit && times<10000; ++times)
                render(bs);
        private void render(BufferStrategy bs) {
            Graphics2D g = (Graphics2D) bs.getDrawGraphics();
            g.fillRect(0, 0, getWidth(), getHeight());
            g.drawRenderedImage(orig, AffineTransform.getTranslateInstance(x, y));
            bs.show();
            x += dx;
            if (x<0 | x>UBX)
                dx *= -1;
            y += dy;
            if (y<0 | y>UBY)
                dy *= -1;

  • Have problems with Mail on MacBook running OS X Mavericks. It suddenly became stuck: won't quit and won't display any messages. Please help.

    Have problems with Mail on MacBook running OS X Mavericks. It suddenly became stuck: won't quit and won't display any messages. Please help.

    Select Force Quit from under the Apple menu and select Mail (it may say that it isn't responding).
    Clinton

  • How to Display an Image in swing

    I Want to display an image in swing using the scrollPane, so I can scroll an image in a box

    A very simple way is to use a JLabel :
    JLabel label = new JLabel(new ImageIcon("myImage.jpg"));
    JScrollPane scroller = new JScrollPane(label);

  • TS3700 I am facing this issues that music stops playing when the display goes...Please help me with this...:)

    I am facing this issues that music stops playing when the display goes...Please help me with this...:)

    Did you see the article linked at the top of this page?
    iPod nano (6th generation): Music stops when display turns off
    B-rock

Maybe you are looking for

  • Jabber not support p2p audio on WebEx Connect.

    Hi, everyone. We have received complaints from customers in the WebEx Connect Client peer-to-peer audio functionality. We know Cisco's announcement, after April 3, 2015, a customer has to use Jabber on WebEx Connect. But Jabber doesn't have the peer

  • Expiration of messages in Queue  + OSB (part 2)

    I am working on a prototype and I have the following scenario : I have on ALSB (OSB) a JMS based Proxy Service that uses a queue in order to get the messages. On the queue are put SOAP messages that are secured on message level. There is a digest exp

  • Simple Delete messages in XI/PI

    We have scheduled these jobs to simple delete and it's working fine. One of the questions arrived that why Moni messages are still there, even though it's not required. Can we delete any trace of messages after 30 days? Is it duable? Please let me kn

  • Bootcamp not giving me an option to use a usb drive

    Bootcamp 5.0.3 on OS 10.8.4 is not giving me an option to use a usb drive to install windows. It worked on my Macbook Pro but not on my IMac. And it's not recognizing the dvd with the windows ISO on it. Any suggestions?

  • Connected Monitor/Projector - Multiple Resolutions

    Is it possible to have two different resolutions on a MacBook Pro and an external monitor? Right now, the MacBook always downgrades the resolution to match the video projector.