How to set JList Orientation to horizontal (Netbeans) - java

I need to make a list of runners that arrive each at a different time. So basically what i want is to show in a Jlist the name of the runner, his team and the time he took to finish the race all in a single row. Is there a method for this?
So far i've only found [list.setLayoutOrientation(JList.HORIZONTAL_WRAP);] but i'm not sure if i'm using it correctly or if its even a solution to my problem.
Any help is appreciated :)

Related

JComboBox: arrow-button should be shown at any time

If a JComboBox is not selected, the arrow-button on the right is not shown. This leads to the fact that a combo-box cannot be distinguished from a normal textfield.
The question is now: how is it possible to show the arrow-button permanently? I alrady came across BasicComboBoxUI.createArrowButton() etc., but I did not find out the mechanism of hiding / showing the arrow-button.
Can anyoune give me a hint how to show the arrow-button permanently ?
Can you add below code as first line in your main method.
Toolkit.getDefaultToolkit().setDesktopProperty("win.xpstyle.themeActive",Boolean.FALSE);
and then check your program.
sorry for the inconvenience. Everything is clear now. In have been told that we use a special framework which changes the behaviour. This information would have been useful if given to me earlier... :-(

How do I make one component visible in more than one pane in a JTabbedPane?

I was wondering if there was a way to make one component (in this case a JPanel) visible in more than one of the tabs.
I have a simple JFrame which is completely filled with a JTabbedPane. Each tab has a slightly different function, which is why they're in different tabs. However, they each output the same type of information. I was wondering if there was a way to make it so the same output panel could be seen in all the tabs, without having to create one panel for each tab.
I realize that it is impossible to add one component multiple times (and have it display independently each time), which is why I'm not optimistic about this being possible, however if it is, it would make my code much cleaner. In the case that this is not possible, I am completely open to alternate suggestions that achieve a similar result. I am in the very beginning of my project, so it won't be too difficult to change things.
This image gives a rough idea of what I'm trying to make it look like:
I have searched around for anyone dealing with this issue, however I have had little luck finding anything relevant. If I missed something, I apologize for wasting your time.

Java setting button values on memory game

I have been working on a memory game i asked a question about yesterday, I got some brilliant suggestions but none of them seem to be helping my problem i can get the buttons to shuffle around the grid layout fine, but i cannot figure out how to keep the set values i tried using "setActionCommand" but i don't think this is the way i can do it for matching the values of two buttons within my memory game.
gameBtn[0].setActionCommand("1");
gameBtn[1].setActionCommand("2");
gameBtn[2].setActionCommand("3");
gameBtn[3].setActionCommand("4");
gameBtn[4].setActionCommand("5");
gameBtn[5].setActionCommand("6");
gameBtn[6].setActionCommand("7");
gameBtn[7].setActionCommand("8");
gameBtn[8].setActionCommand("1");
gameBtn[9].setActionCommand("2");
gameBtn[10].setActionCommand("3");
gameBtn[11].setActionCommand("4");
gameBtn[12].setActionCommand("5");
gameBtn[13].setActionCommand("6");
gameBtn[14].setActionCommand("7");
gameBtn[15].setActionCommand("8");
above is how i used the setActionCommand but i cant find out how you would compare them to each other to find a match for example matching club1 to diamond1 and club2 to diamond2. would this not mean i would have to do something like this for every single match i wanted?.
if (gameBtn[0].getActionCommand().equals(gameBtn[8].getActionCommand())){
sameValues();
}
if (gameBtn[1].getActionCommand().equals(gameBtn[9].getActionCommand())){
sameValues();
}
although the above might seem to work as it does not throw any errors im left thinking there must be a more efficient better way to do it i accomplished this at first before i added the shuffle to move the buttons on the grid i was using another list of values, but know its randomized the card on the button no longer actually matches the buttons set value.
have a look at the link at the bottom of the question if you need more information from my last question, Any help would be much appreciated as this has been bugging me for a while know thank you.
link: Java concentrate is there a way to shuffle jbuttons

Programmatically Scroll an SWT Table horizontally

Similar question, but not exactly the same.
table.showColumn() is helpful, but the scrolling only has the granularity of the column width. But I want a more precise control of the scroll location.
Consider the following use case. I have two tables that I know are of the same width and have the same column widths. And I want to implement some kind of a scroll synchronizer so that when the user scrolls one table (horizontally), the other table scrolls to the same location.
EDIT:
On the Eclipse forum there seems to be the same question and some working ideas, but no resolution.
EDIT:
I discovered this behavior on Windows
The method setOrigin(x,y) in ScrolledComposite should help:
Scrolls the content so that the specified point in the content is in the top left corner. If no content has been set, nothing will occur. Negative values will be ignored. Values greater than the maximum scroll distance will result in scrolling to the end of the scrollbar.
I'm afraid I can't get a satisfying result in Windows Vista/7 either, but felt I was getting close.
I believe you will have to grab the Table's horizontal scroll bar by using table.getHorizontalBar(). Then, you can specify scrollbar.setSelection() to make it move to a specified position.
This is where I get stuck. Somehow, you have to notify either the Table or the ScrollBar that the value has changed. I've tried everything from update() to notifyListener(), but no dice. It seems that it is merely a matter of laying out, but layout() doesn't have any effect, either.
Incidentally, bear in mind that the ScrollBar's parent (type Scrollable) is not a ScrolledComposite like I had expected, but is actually the Table itself.
I hope this gives you some ideas and helps you find a solution. If so, please let me know, since it's bugging me now, too!
Having poked around in the ScrollBar source a bit, it looks like there are numerous (windows) bugs that have been overcome at one point or another. This may be another, though you didn't mention your OS, nor did Paul, so it's hard to tell.
All the "change the scroll bar position" functions end up calling SetScrollInfo which is package private. I suspect that the intention is for this to actually update things the way you want.
None of that solves your problem. Thankfully the same source also hints at a solution:
Slider.
You'd have to reimplement all the scrollbar behavior within slider, but once done, that should give you the control (har) you want. Hopefully. OTOH, you may run into exactly the same OS bug (if bug it be), and be back at square one.
At THAT point, you definitely register it as an Eclipse UI bug.
PS: Have you searched the Eclipse Bugzilla for anything similar? Poking around a bit turned up this bug related to the scroll bar being out of sync with a tree view in the Navigator (on PC Linux-Motif, but working fine in Windows). I suspect you'll find similar issues if you dig a bit more.

Rendering Dragged object during drag

I have been stuck on this problem for a while now. I want to drag a row in a jtable to reorder it. But I really want the user to see the row while dragging it and not just the default "drag" rectangle symbol. So I took a look at the java DnD tutorial finding it very useful, but..
The problem is that I still dont know which method I should override to get this going.
Can somebody help me out?
You might be interested in this question Drag and Drop with an Image. However as far as I know this only works on Mac.

Categories