I want to use SWT tab compnent and make it be multiline,but I fail.please
see the class TabFolderExampl e.
Can aneone help me? - import java.awt.BorderLayout;
-
import java.awt.event.WindowAdapter;
-
import java.awt.event.WindowEvent;
-
-
import javax.swing.JDialog;
-
import javax.swing.JLabel;
-
import javax.swing.JPanel;
-
import javax.swing.JTabbedPane;
-
-
-
public class swingtab extends JDialog {
-
-
/**
-
* Launch the application
-
* @param args
-
*/
-
public static void main(String args[]) {
-
try {
-
swingtab dialog = new swingtab();
-
dialog.addWindowListener(new WindowAdapter() {
-
public void windowClosing(WindowEvent e) {
-
System.exit(0);
-
}
-
});
-
dialog.setVisible(true);
-
} catch (Exception e) {
-
e.printStackTrace();
-
}
-
}
-
-
/**
-
* Create the dialog
-
*/
-
public swingtab() {
-
super();
-
getContentPane().setLayout(null);
-
this.setBounds(20, 10, 400, 325);
-
-
final JTabbedPane tabPane = new JTabbedPane();
-
-
JPanel basicPanel = new JPanel();
-
basicPanel.setLayout(null);
-
basicPanel.setBounds(10, 10, tabPane.getWidth() - 30,
-
-
tabPane.getHeight());
-
-
JLabel lbl1 = new JLabel("this is tab 1");
-
lbl1.setBounds(5, 5, 100, 25);
-
basicPanel.add(lbl1);
-
-
tabPane.addTab("Basics", basicPanel);
-
-
JPanel advancedPanel = new JPanel();
-
advancedPanel.setLayout(null);
-
advancedPanel.setBounds(tabPane.getX(), tabPane.getY(),
-
-
tabPane.getWidth() - 30, tabPane.getHeight());
-
-
JLabel lbl2 = new JLabel("this is tab 2");
-
lbl2.setBounds(5, 5, 100, 25);
-
advancedPanel.add(lbl2);
-
-
tabPane.addTab("Advanced ", advancedPanel);
-
-
JPanel panel = new JPanel();
-
panel.setLayout(null);
-
-
JLabel lbl3 = new JLabel("this is tab 3");
-
lbl3.setBounds(5, 5, 100, 25);
-
panel.add(lbl3);
-
-
tabPane.addTab("New Instance ", panel);
-
-
// JPanel panel1 = new JPanel();
-
// panel.setLayout(null);
-
// tabPane.addTab("Playback ", panel1);
-
//
-
// JPanel panel2 = new JPanel();
-
// panel.setLayout(null);
-
// tabPane.addTab("Green Info Display ", panel2);
-
-
tabPane.setBounds(10, 35, 130, 250);
-
this.add(tabPane);
-
//
-
}
-
}
-
-
import org.eclipse.swt.SWT;
-
import org.eclipse.swt.layout.FillLayout;
-
import org.eclipse.swt.layout.GridData;
-
import org.eclipse.swt.layout.GridLayout;
-
import org.eclipse.swt.widgets.Button;
-
import org.eclipse.swt.widgets.Composite;
-
import org.eclipse.swt.widgets.Display;
-
import org.eclipse.swt.widgets.Label;
-
import org.eclipse.swt.widgets.Shell;
-
import org.eclipse.swt.widgets.TabFolder;
-
import org.eclipse.swt.widgets.TabItem;
-
import org.eclipse.swt.widgets.Text;
-
-
public class TabFolderExample {
-
-
public static void main(String[] args) {
-
Shell shell = new Shell(Display.getCurrent(), SWT.SHELL_TRIM);
-
shell.setLayout(new FillLayout());
-
TabFolder tabFolder = new TabFolder(shell, SWT.TOP);
-
-
for (int tab = 0; tab < 9; tab++) {
-
-
TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
-
tabItem.setText("Tab" + (tab + 1));
-
Composite composite = new Composite(tabFolder, SWT.NONE);
-
composite.setLayout(new GridLayout(2, false));
-
tabItem.setControl(composite);
-
-
for (int item = 0; item < 10; item++) {
-
Label label = new Label(composite, SWT.LEFT);
-
label.setFocus();
-
label.setText("Label &" + (item + 1));
-
label.setLayoutData(new GridData());
-
Text text1 = new Text(composite, SWT.LEFT | SWT.BORDER);
-
text1.setText("Text " + (item + 1));
-
GridData textData = new GridData();
-
textData.grabExcessHorizontalSpace = true;
-
textData.widthHint = 200;
-
text1.setLayoutData(textData);
-
}
-
}
-
-
Display display = Display.getCurrent();
-
shell.pack();
-
shell.setVisible(true);
-
shell.setFocus();
-
while (!shell.isDisposed()) {
-
if (!display.readAndDispatch()) {
-
display.sleep();
-
}
-
}
-
display.dispose();
-
}
-
}
-
1 3175
What is the problem? What errors are you getting? What shows up when you compile/run this?
Put your code in code brackets please (look at the "Reply Guidelines" box that appears when you're replying on the right side of the screen).
-blazed
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Hal Vaughan |
last post by:
I'm testing a GUI app on a couple Linux boxen and one Win2k box. I'm using
Java 1.4.2 on each (or the closest on Win2k -- whatever version comes
close). On one Linux box and the Win2k box the line spacing is very close
(for example, when I use HTML in JLabels, or even in JTextAreas), but on
the other Linux box, the line spacing is much wider.
I'm using default Swing fonts -- I'm not setting anything. I can't find a
field or function...
|
by: David Van D |
last post by:
Hi there,
A few weeks until I begin my journey towards a degree in Computer
Science at Canterbury University in New Zealand,
Anyway the course tutors are going to be teaching us JAVA wth bluej and
I was wondering if anyone here would be able to give me some tips for
young players such as myself, for learning the language.
Is this the best Newsgroup for support with JAVA?
|
by: freegnu |
last post by:
hi all, i want to modify a class's interface, that will reference many classes which inherit it
is there any advice to me?
thanks
|
by: jhhbr549 |
last post by:
I need my result to print out only in the box created with a scroll bar. It has to look like this.
The Twelve Days of It
by John H. Howard
On the First day of It
My true LOVE of Computers
sent to me:
A one Gig Jump drive
|
by: Nuwang |
last post by:
Hai,
I'm using a swing to connect database with swing application...
1. How this swing connect with access database...
2. Important thing is how change Button size and Font size
Still I couldn't manage my swing in proper layout pls run and check
Code:
| |
by: javateam |
last post by:
Hi all,
I have a situation where I need to be able to display foreign characters (asian languages) in a text area in my program.
I have no idea on how to do this.
http://www.code2000.net/keybkann.htm
I need to produce something like this, using java Swing...
Can anyone please advice?
|
by: dmjpro |
last post by:
Now a days I am working in Swing.
So guys please help me to do my project.
Actually the time is short to read out those things.
What i have a confusion ..that .....
DefaultTableModel tab_model = new DefaultModel(...);
JTable tab = new JTable(tab_model);
//Now if I change to tab_model then automatically updation notification goes to tab??
|
by: r035198x |
last post by:
I have put together this article to give people starting Swing an awareness of issues that need to be considered when creating a Swing application. Most of the Swing tutorials that I have seen just help people display some nice widgets quickly without explaining some issues that need to be tackled when a full application needs to be developed. This article does not go into full implementation details because those can be found by reading the...
|
by: phpuser123 |
last post by:
I have a class test2 containing a button.When I press this button, I want to instantiate an object from Test3 and display the image in a panel on the newly created object..
test2 class
public class test2 extends javax.swing.JFrame {
/** Creates new form test2 */
public test2() {
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |