1.4 Containere Flashcards

1
Q

Dupa ce versiune JDK nu mai este nevoie sa se specifice getContentPane() ?

A

dupa versiunea 1.4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Creati doua grupari separate de butoane:

  1. Gray, Button, Group ( 3 butoane )
  2. Green, Button, Group ( 3 butoane )

Dimensiunea fiecarei grupari trebuie sa fie de 100,100

A

this.setLayout(new FlowLayout());

    JPanel gray = new JPanel();

    gray. setBackground(Color.GRAY);
    gray. add(new JButton("Gray"));
    gray. add(new JButton("Button"));
    gray. add(new JButton("Group"));
    gray. setPreferredSize(new Dimension(100, 100));

    JPanel green = new JPanel();

    green. setBackground(Color.GREEN);
    green. add(new JButton("Green"));
    green. add(new JButton("Button"));
    green. add(new JButton("Group"));
    green. setPreferredSize(new Dimension(100, 100));

    this. add(gray);
    this. add(green);

    this. setSize(250, 150);
    this. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this. setVisible(true);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Ce putem face daca continutul containerului nostru depaseste marimea containerului ?

A

Putem folosi JScrollPane pentru a crea un scroll bar.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Care sunt setarile care se pot face pentru JScrollPane pentru ca aceasta sa fie mereu vizibila ?

A

Exista doua setari, una pentru scroll-bar-ul vertical iar alta pentru cel orizontal.

sp. setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
sp. setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Care sunt constantele pe care le are clasa ScrollPaneConstants ?

A

NEVER, ALWAYS, AS_NEEDED
HORIZONTAL_SCROLLBAR
VERTICAL_SCROLLBAR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

JScrollPane poate contine doua titluri, cum se pot seta acestea ?

A
  1. Column header care se seteaza folosind metoda:
    sp. setColumnHeaderView(“text”);
  2. Row header care se seteaza folosind metoda:
    sp. setRowHeaderView(“text”);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Exista un container care este capabil sa imparta continutul in doua, vertical sau orizontal, si apoi cu ajutorul unui control de manipulare, utilizatorul sa poata seta cat spatiu sa fie disponibil pentru fiecare continut.Cum se cheama acesta ?

A

JSplitPane

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Folosind JSplitPane creati o fereastra care sa contina doua zone, una gri si una verde, iar acestea sa fie despartite pe orizontala.

A

this.setLayout(new FlowLayout());

    JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
        JPanel leftP = new JPanel();
        leftP.setBackground(Color.gray);
        leftP.setPreferredSize(new Dimension(200,200));
        JPanel rightP = new JPanel();
        rightP.setBackground(Color.green);
        rightP.setPreferredSize(new Dimension(200,200));
    sp. add(leftP);
    sp. add(rightP);

    this.add(sp);

    this. setSize(450, 250);
    this. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this. setVisible(true);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Controlul de manipulare al containerului JSplitPane nu trebuie sa fie neaparat pe mijloc, cum se poate seta programabil ca la pornirea aplicatiei sa se afle la 50 de pixeli fata de marginea din stanga ?

A

sp.setDividerLocation(50);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Care este metoda care se foloseste pentru a reseta la default locatia dividerului ?

A

sp.resetToPreferedSizes();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Creati doua tab-uri de dimensiunea 300,100, unul rosu si unul galben.

A

JTabbedPane tp = new JTabbedPane();

    JPanel red = new JPanel();

    red. setBackground(Color.red);
    red. setPreferredSize(new Dimension(300, 100));

    JPanel yellow = new JPanel();

    yellow. setBackground(Color.YELLOW);
    yellow. setPreferredSize(new Dimension(300, 100));

    tp. addTab("Red", red);
    tp. addTab("Yellow", yellow);

    this.add(tp);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Denumirea tab-ului poate contine si o imagine, cum se poate realiza acest lucru ?

A

tp.addTab(“Yellow”,new ImageIcon(“icon.png”), yellow);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Cum putem afla care componenta ( tab ) este selectata in momentul actual ? si ce index are aceasta ?

A

Folosind metoda getSelectedComponent() si getSelectedIndex();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Pentru a adauga un listener pe JTabbedPane ce metoda se foloseste ?

A

addChangeListener

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Cum se poate prelua JTabbedPane din constructorul metodei addChangeListener(ChangeEvent e) ?

A

JTabbedPane tpp = (JTabbedPane) e.getSource();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Ce clasa se foloseste pentru a crea o fereastra sau mai multe in cadrul altei ferestre ?

A

JInternalFrame.

17
Q

Creati o fereastra interna de dimensiunea 100,100

A
JInternalFrame inF = new JInternalFrame();
        inF.setPreferredSize(new Dimension(100, 100));
        inF.setVisible(true);
18
Q

Care sunt metodele pentru a putea face o fereastra interna

  • sa se inchida
  • sa se maximizeze
  • sa se redimensioneze
A

internalFrame
.setClosable(true);
.setMaximizable(true);
.setResizable(true);